From 82931fcb8b4fdc89cfeafad562eac47414d3dbdd Mon Sep 17 00:00:00 2001
From: Akash Kothari <akashk4@tyler.cs.illinois.edu>
Date: Mon, 17 Feb 2020 15:08:22 -0600
Subject: [PATCH] Fixed compilation error in NVPTX HPVM backend

---
 llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
index d8be759932..c0cbd4df14 100644
--- a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
+++ b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
@@ -1123,6 +1123,7 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
 
 
   // Go through all the instructions
+  std::vector<CallInst *> CItoRemove;
   for (inst_iterator i = inst_begin(F_nvptx), e = inst_end(F_nvptx); i != e; ++i) {
     Instruction *I = &(*i);
     // Leaf nodes should not contain VISC graph intrinsics or launch
@@ -1484,6 +1485,12 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
     DEBUG(errs() << "Erasing: " << **ri << "\n");
     (*ri)->eraseFromParent();
   }
+  for(auto *CI : reverse(CItoRemove)) {
+    DEBUG(errs() << "Erasing: " << *CI << "\n");
+    CI->eraseFromParent();
+
+  }
+
 
   addCLMetadata(F_nvptx);
   kernel->KernelFunction = F_nvptx;
-- 
GitLab