Skip to content

Commit edf7657

Browse files
gbaraldiZentrik
andauthored
Apply debug_compile_units hack also in remove-addrspaces (#58365)
This fixes the issues seen in the LLVM 20 PR Co-authored-by: Zentrik <[email protected]>
1 parent 24d2f4a commit edf7657

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/llvm-remove-addrspaces.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
334334

335335
GV->setInitializer(nullptr);
336336
}
337-
337+
// Same workaround as in CloneCtx::prepare_vmap to avoid LLVM bug when cloning
338+
auto &MD = VMap.MD();
339+
for (auto cu: M.debug_compile_units()) {
340+
MD[cu].reset(cu);
341+
}
338342
// Similarly, copy over and rewrite function bodies
339343
for (Function *F : Functions) {
340344
Function *NF = cast<Function>(VMap[F]);
@@ -414,6 +418,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
414418
}
415419
}
416420

421+
417422
return true;
418423
}
419424

0 commit comments

Comments
 (0)