diff --git a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp index d8be759932c4d08038a6dc1e8337672f2617c3d4..c0cbd4df1451b981e43a2e7593d703b15c555765 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;