From 39711ce4cd617cbb065f3ba84839799c4e315f60 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Thu, 5 Dec 2024 01:49:15 +0000 Subject: [PATCH] Replace DICompileUnit in DISubprogram scopes Without this, the Module can fail to verify with "dicompileunit not listed in llvm.dbg.cu" since the old DICompileUnit will be retained by the dangling reference. --- DebugIR.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DebugIR.cpp b/DebugIR.cpp index 6a7c3b972..fbf3f5b26 100644 --- a/DebugIR.cpp +++ b/DebugIR.cpp @@ -292,6 +292,10 @@ class DIUpdater : public InstVisitor { NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); NMD->clearOperands(); NMD->addOperand(CU); + + for (DISubprogram *S : Finder.subprograms()) { + S->replaceUnit(CU); + } } DIScope *getBlockScope(DIScope *ParentScope, const BasicBlock *B) {