summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-02-09 15:45:06 +0000
committerGabor Greif <ggreif@gmail.com>2009-02-09 15:45:06 +0000
commitccd27fb84b0ac13ad1d30b17cbeb87a0ea934154 (patch)
treeddb8cf871cdd2e5ff04974a0cbccbfb43578e81e /lib/VMCore
parentfb3e5ca53b412a41d26bb4316f10e68aa72f65f6 (diff)
downloadllvm-ccd27fb84b0ac13ad1d30b17cbeb87a0ea934154.tar.gz
llvm-ccd27fb84b0ac13ad1d30b17cbeb87a0ea934154.tar.bz2
llvm-ccd27fb84b0ac13ad1d30b17cbeb87a0ea934154.tar.xz
make sure that BranchInst::getSuccessor() does not assert in cast<>
even if the underlying operand is NULL. This may happen in debugging context within opt with partial loop unrolling (see test/Transforms/LoopUnroll/partial.ll). After this fix I can resubmit the (backed out) r63459: * lib/VMCore/AsmWriter.cpp: use precise accessors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 6a17516be2..0322d669d3 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1505,13 +1505,14 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
const Value *Operand = I.getNumOperands() ? I.getOperand(0) : 0;
// Special case conditional branches to swizzle the condition out to the front
- if (isa<BranchInst>(I) && I.getNumOperands() > 1) {
+ if (isa<BranchInst>(I) && cast<BranchInst>(I).isConditional()) {
+ BranchInst &BI(cast<BranchInst>(I));
Out << ' ';
- writeOperand(I.getOperand(2), true);
+ writeOperand(BI.getCondition(), true);
Out << ", ";
- writeOperand(Operand, true);
+ writeOperand(BI.getSuccessor(0), true);
Out << ", ";
- writeOperand(I.getOperand(1), true);
+ writeOperand(BI.getSuccessor(1), true);
} else if (isa<SwitchInst>(I)) {
// Special case switch statement to get formatting nice and correct...