From 14ad8dc0761a1e440304a03a1f4828280cf112e2 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 17 Apr 2020 10:24:35 -0700 Subject: 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. --- llvm/lib/CodeGen/MachineDebugify.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineDebugify.cpp') diff --git a/llvm/lib/CodeGen/MachineDebugify.cpp b/llvm/lib/CodeGen/MachineDebugify.cpp index bee9b6346757..bc607cabcc68 100644 --- a/llvm/lib/CodeGen/MachineDebugify.cpp +++ b/llvm/lib/CodeGen/MachineDebugify.cpp @@ -27,7 +27,10 @@ using namespace llvm; namespace { bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI, DIBuilder &DIB, Function &F) { - MachineFunction &MF = MMI.getOrCreateMachineFunction(F); + MachineFunction *MaybeMF = MMI.getMachineFunction(F); + if (!MaybeMF) + return false; + MachineFunction &MF = *MaybeMF; DISubprogram *SP = F.getSubprogram(); assert(SP && "IR Debugify just created it?"); -- cgit v1.2.3