summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-06-15 18:22:43 +0000
committerNate Begeman <natebegeman@mac.com>2005-06-15 18:22:43 +0000
commit1bf89275184bffbe69f302d2680fd43327b9f3b6 (patch)
treed2791b574748f068ba3da8123d4c7250d9bf42bc
parent31e5579fbff868523ce9b3743a90cf299418c2e8 (diff)
downloadbcm5719-llvm-1bf89275184bffbe69f302d2680fd43327b9f3b6.tar.gz
bcm5719-llvm-1bf89275184bffbe69f302d2680fd43327b9f3b6.zip
Commit fix for generating conditional branch pseudo instructions that
avoids dereferencing the end() iterator when selecting the fallthrough block. This requires an ilist change. llvm-svn: 22212
-rw-r--r--llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
index 5b4c6e58d5c..eaf7b09cb0c 100644
--- a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
+++ b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
@@ -1232,9 +1232,9 @@ void ISel::SelectBranchCC(SDOperand N)
Select(N.getOperand(0)); //chain
CCReg = SelectCC(N.getOperand(1), Opc, Inv, Idx);
- // Iterate to the next basic block, unless we're already at the end of the
- ilist<MachineBasicBlock>::iterator It = BB, E = BB->getParent()->end();
- if (++It == E) It = BB;
+ // Iterate to the next basic block
+ ilist<MachineBasicBlock>::iterator It = BB;
+ ++It;
// If this is a two way branch, then grab the fallthrough basic block argument
// and build a PowerPC branch pseudo-op, suitable for long branch conversion
@@ -1256,6 +1256,11 @@ void ISel::SelectBranchCC(SDOperand N)
}
}
} else {
+ // If the fallthrough path is off the end of the function, which would be
+ // undefined behavior, set it to be the same as the current block because
+ // we have nothing better to set it to, and leaving it alone will cause the
+ // PowerPC Branch Selection pass to crash.
+ if (It == BB->getParent()->end()) It = Dest;
BuildMI(BB, PPC::COND_BRANCH, 4).addReg(CCReg).addImm(Opc)
.addMBB(Dest).addMBB(It);
}
OpenPOWER on IntegriCloud