summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-10-05 13:15:06 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-10-05 13:15:06 +0000
commite7c72cdbb0ba7f1ac3ef85b972ad524f79c46af9 (patch)
treef8b4a2cc13062fb08a61c2aeb08f858b71ca0ef8 /llvm/lib/CodeGen
parent9e43ccfe682868e9bd5bcae0be92d4fcbf281395 (diff)
downloadbcm5719-llvm-e7c72cdbb0ba7f1ac3ef85b972ad524f79c46af9.tar.gz
bcm5719-llvm-e7c72cdbb0ba7f1ac3ef85b972ad524f79c46af9.zip
Fix machine operand traversal in ScheduleDAGInstrs::fixupKills
llvm-svn: 283315
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/ScheduleDAGInstrs.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
index c147424cf7b..ba9bf906294 100644
--- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -1309,7 +1309,13 @@ void ScheduleDAGInstrs::fixupKills(MachineBasicBlock *MBB) {
// register is used multiple times we only set the kill flag on
// the first use. Don't set kill flags on undef operands.
killedRegs.reset();
- for (MachineOperand &MO : MI.operands()) {
+
+ // toggleKillFlag can append new operands (implicit defs), so using
+ // a range-based loop is not safe. The new operands will be appended
+ // at the end of the operand list and they don't need to be visited,
+ // so iterating until the currently last operand is ok.
+ for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = MI.getOperand(i);
if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
unsigned Reg = MO.getReg();
if ((Reg == 0) || MRI.isReserved(Reg)) continue;
@@ -1333,7 +1339,6 @@ void ScheduleDAGInstrs::fixupKills(MachineBasicBlock *MBB) {
if (MO.isKill() != kill) {
DEBUG(dbgs() << "Fixing " << MO << " in ");
- // Warning: toggleKillFlag may invalidate MO.
toggleKillFlag(&MI, MO);
DEBUG(MI.dump());
DEBUG({
OpenPOWER on IntegriCloud