[llvm] 14ad8dc - Don't accidentally create MachineFunctions in mir-debugify/mir-strip-debugify
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 14:28:57 PDT 2020
Author: Daniel Sanders
Date: 2020-04-17T14:28:41-07:00
New Revision: 14ad8dc0761a1e440304a03a1f4828280cf112e2
URL: https://github.com/llvm/llvm-project/commit/14ad8dc0761a1e440304a03a1f4828280cf112e2
DIFF: https://github.com/llvm/llvm-project/commit/14ad8dc0761a1e440304a03a1f4828280cf112e2.diff
LOG: 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.
Added:
Modified:
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/CodeGen/MachineStripDebug.cpp
Removed:
################################################################################
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?");
diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp
index 48b50ceb092a..a1cb12f91275 100644
--- a/llvm/lib/CodeGen/MachineStripDebug.cpp
+++ b/llvm/lib/CodeGen/MachineStripDebug.cpp
@@ -45,7 +45,10 @@ struct StripDebugMachineModule : public ModulePass {
bool Changed = false;
for (Function &F : M.functions()) {
- MachineFunction &MF = MMI.getOrCreateMachineFunction(F);
+ MachineFunction *MaybeMF = MMI.getMachineFunction(F);
+ if (!MaybeMF)
+ continue;
+ MachineFunction &MF = *MaybeMF;
for (MachineBasicBlock &MBB : MF) {
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
I != E;) {
More information about the llvm-commits
mailing list