From 3b008a3a65d2e66362e2391d29290a8f4707d32a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 2 Oct 2009 15:59:52 +0000 Subject: [PATCH] Fix a use-after-free in post-ra-scheduling. MI->addOperand invalidates references to it's operands, avoid touching the operand after a new one was added. llvm-svn: 83249 --- llvm/lib/CodeGen/PostRASchedulerList.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/PostRASchedulerList.cpp b/llvm/lib/CodeGen/PostRASchedulerList.cpp index 902f50517c5f..662ab01a37cf 100644 --- a/llvm/lib/CodeGen/PostRASchedulerList.cpp +++ b/llvm/lib/CodeGen/PostRASchedulerList.cpp @@ -884,6 +884,7 @@ bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI, // If any subreg of MO is live, then create an imp-def for that // subreg and keep MO marked as killed. + MO.setIsKill(false); bool AllDead = true; const unsigned SuperReg = MO.getReg(); for (const unsigned *Subreg = TRI->getSubRegisters(SuperReg); @@ -898,7 +899,8 @@ bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI, } } - MO.setIsKill(AllDead); + if(AllDead) + MO.setIsKill(true); return false; } -- GitLab