1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

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.
This commit is contained in:
Daniel Sanders 2020-04-17 10:24:35 -07:00
parent 9d5348b366
commit a8cde5881b
2 changed files with 8 additions and 2 deletions

View File

@ -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?");

View File

@ -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;) {