Skip to content

Commit

Permalink
Merge pull request #140 from frasercrmck/fix-llvm-17-dbg
Browse files Browse the repository at this point in the history
[compiler] Clear retained nodes from artificial sub-programs
  • Loading branch information
frasercrmck authored Sep 21, 2023
2 parents a66a613 + 2c68035 commit 5b6a50d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/compiler/utils/source/pass_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,17 @@ static llvm::Function *createKernelWrapperFunctionImpl(
// copy debug info for function over
if (auto *SP = F.getSubprogram()) {
llvm::DIBuilder DIB(*F.getParent());
auto *NewSP = DIB.createArtificialSubprogram(SP);
llvm::DISubprogram *const NewSP = DIB.createArtificialSubprogram(SP);
#if LLVM_VERSION_GREATER_EQUAL(17, 0)
// Wipe the list of retained nodes, as this new function is a wrapper over
// the old one and does not itself contain/retain any of the wrapped
// function's nodes.
NewSP->replaceRetainedNodes({});
#else
// This does the same as the above, but there's no cleaner API with which
// to do it.
NewSP->replaceOperandWith(7, nullptr);
#endif
NewFunction.setSubprogram(NewSP);
}

Expand Down

0 comments on commit 5b6a50d

Please sign in to comment.