diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-27 03:15:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-27 03:15:45 +0000 |
commit | f2361c5e5c2917e6f19a55927b221d8671753a40 (patch) | |
tree | 096c093f33f851d65205de8e053ac2849d70a721 /lib/Transforms | |
parent | 35504209a0ddbc70d97a7ef16c504acc863bfeec (diff) | |
download | external_llvm-f2361c5e5c2917e6f19a55927b221d8671753a40.tar.gz external_llvm-f2361c5e5c2917e6f19a55927b221d8671753a40.tar.bz2 external_llvm-f2361c5e5c2917e6f19a55927b221d8671753a40.zip |
Changes because the Terminator::getSuccessor function now FAILS if successor
IDX is out of range instead of returning null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/MutateStructTypes.cpp | 13 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index fcad5fa050..b5dd937f7e 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -369,10 +369,15 @@ void MutateStructTypes::transformMethod(Function *m) { break; case Instruction::Br: { const BranchInst *BI = cast<BranchInst>(I); - NewI = new BranchInst( - cast<BasicBlock>(ConvertValue(BI->getSuccessor(0))), - cast_or_null<BasicBlock>(ConvertValue(BI->getSuccessor(1))), - ConvertValue(BI->getCondition())); + if (BI->isConditional()) { + NewI = + new BranchInst(cast<BasicBlock>(ConvertValue(BI->getSuccessor(0))), + cast<BasicBlock>(ConvertValue(BI->getSuccessor(1))), + ConvertValue(BI->getCondition())); + } else { + NewI = + new BranchInst(cast<BasicBlock>(ConvertValue(BI->getSuccessor(0)))); + } break; } case Instruction::Switch: diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index fd3daa5bef..51a827d14b 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -397,8 +397,8 @@ void SCCP::visitBranchInst(BranchInst *BI) { void SCCP::visitSwitchInst(SwitchInst *SI) { InstVal &SCValue = getValueState(SI->getCondition()); if (SCValue.isOverdefined()) { // Overdefined condition? All dests are exe - for(unsigned i = 0; BasicBlock *Succ = SI->getSuccessor(i); ++i) - markExecutable(Succ); + for(unsigned i = 0, E = SI->getNumSuccessors(); i != E; ++i) + markExecutable(SI->getSuccessor(i)); } else if (SCValue.isConstant()) { Constant *CPV = SCValue.getConstant(); // Make sure to skip the "default value" which isn't a value |