Skip to content

Commit 14ad8dc

Browse files
committed
Don't accidentally create MachineFunctions in mir-debugify/mir-strip-debugify
We should only modify existing ones. Previously, we were creating MachineFunctions for externally-available functions. AFAICT this was benign in tree but ultimately led to asan bugs in our out of tree target.
1 parent ef49b1d commit 14ad8dc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/CodeGen/MachineDebugify.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ using namespace llvm;
2727
namespace {
2828
bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
2929
DIBuilder &DIB, Function &F) {
30-
MachineFunction &MF = MMI.getOrCreateMachineFunction(F);
30+
MachineFunction *MaybeMF = MMI.getMachineFunction(F);
31+
if (!MaybeMF)
32+
return false;
33+
MachineFunction &MF = *MaybeMF;
3134

3235
DISubprogram *SP = F.getSubprogram();
3336
assert(SP && "IR Debugify just created it?");

llvm/lib/CodeGen/MachineStripDebug.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ struct StripDebugMachineModule : public ModulePass {
4545

4646
bool Changed = false;
4747
for (Function &F : M.functions()) {
48-
MachineFunction &MF = MMI.getOrCreateMachineFunction(F);
48+
MachineFunction *MaybeMF = MMI.getMachineFunction(F);
49+
if (!MaybeMF)
50+
continue;
51+
MachineFunction &MF = *MaybeMF;
4952
for (MachineBasicBlock &MBB : MF) {
5053
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
5154
I != E;) {

0 commit comments

Comments
 (0)