aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp9
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp7
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp3
-rw-r--r--lib/Transforms/Scalar/GVN.cpp9
-rw-r--r--lib/Transforms/Scalar/GVNPRE.cpp13
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp70
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp4
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp2
-rw-r--r--lib/Transforms/Utils/BreakCriticalEdges.cpp5
-rw-r--r--lib/Transforms/Utils/ValueMapper.cpp3
10 files changed, 66 insertions, 59 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 366005bb13..57a8d281e0 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -28,6 +28,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/ADT/DenseMap.h"
@@ -882,7 +883,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
Value *LV = new LoadInst(InitBool, InitBool->getName()+".val", CI);
InitBoolUsed = true;
switch (CI->getPredicate()) {
- default: assert(0 && "Unknown ICmp Predicate!");
+ default: LLVM_UNREACHABLE("Unknown ICmp Predicate!");
case ICmpInst::ICMP_ULT:
case ICmpInst::ICMP_SLT:
LV = Context->getConstantIntFalse(); // X < null -> always false
@@ -1163,7 +1164,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
PN->getName()+".f"+utostr(FieldNo), PN);
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
} else {
- assert(0 && "Unknown usable value");
+ LLVM_UNREACHABLE("Unknown usable value");
Result = 0;
}
@@ -2056,7 +2057,7 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val,
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
Elts.push_back(Context->getUndef(STy->getElementType(i)));
} else {
- assert(0 && "This code is out of sync with "
+ LLVM_UNREACHABLE("This code is out of sync with "
" ConstantFoldLoadThroughGEPConstantExpr");
}
@@ -2084,7 +2085,7 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val,
Constant *Elt = Context->getUndef(ATy->getElementType());
Elts.assign(ATy->getNumElements(), Elt);
} else {
- assert(0 && "This code is out of sync with "
+ LLVM_UNREACHABLE("This code is out of sync with "
" ConstantFoldLoadThroughGEPConstantExpr");
}
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 9d87403bdc..31e36d8994 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -53,6 +53,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include <map>
#include <vector>
using namespace llvm;
@@ -128,7 +129,7 @@ static bool isEquivalentType(const Type *Ty1, const Type *Ty2) {
return false;
default:
- assert(0 && "Unknown type!");
+ LLVM_UNREACHABLE("Unknown type!");
return false;
case Type::PointerTyID: {
@@ -469,7 +470,7 @@ static LinkageCategory categorize(const Function *F) {
return ExternalStrong;
}
- assert(0 && "Unknown LinkageType.");
+ LLVM_UNREACHABLE("Unknown LinkageType.");
return ExternalWeak;
}
@@ -575,7 +576,7 @@ static bool fold(std::vector<Function *> &FnVec, unsigned i, unsigned j) {
case Internal:
switch (catG) {
case ExternalStrong:
- assert(0);
+ llvm_unreachable();
// fall-through
case ExternalWeak:
if (F->hasAddressTaken())
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index c1f29fec55..51a0bae67d 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -44,6 +44,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Instrumentation.h"
#include "RSProfiling.h"
#include <set>
@@ -407,7 +408,7 @@ Value* ProfilerRS::Translate(Value* v) {
TransCache[v] = v;
return v;
}
- assert(0 && "Value not handled");
+ LLVM_UNREACHABLE("Value not handled");
return 0;
}
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index b2fdd24c2c..f0d131c677 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -37,6 +37,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include <cstdio>
@@ -201,7 +202,7 @@ template <> struct DenseMapInfo<Expression> {
Expression::ExpressionOpcode ValueTable::getOpcode(BinaryOperator* BO) {
switch(BO->getOpcode()) {
default: // THIS SHOULD NEVER HAPPEN
- assert(0 && "Binary operator with unknown opcode?");
+ LLVM_UNREACHABLE("Binary operator with unknown opcode?");
case Instruction::Add: return Expression::ADD;
case Instruction::FAdd: return Expression::FADD;
case Instruction::Sub: return Expression::SUB;
@@ -227,7 +228,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) {
if (isa<ICmpInst>(C)) {
switch (C->getPredicate()) {
default: // THIS SHOULD NEVER HAPPEN
- assert(0 && "Comparison with unknown predicate?");
+ LLVM_UNREACHABLE("Comparison with unknown predicate?");
case ICmpInst::ICMP_EQ: return Expression::ICMPEQ;
case ICmpInst::ICMP_NE: return Expression::ICMPNE;
case ICmpInst::ICMP_UGT: return Expression::ICMPUGT;
@@ -242,7 +243,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) {
} else {
switch (C->getPredicate()) {
default: // THIS SHOULD NEVER HAPPEN
- assert(0 && "Comparison with unknown predicate?");
+ LLVM_UNREACHABLE("Comparison with unknown predicate?");
case FCmpInst::FCMP_OEQ: return Expression::FCMPOEQ;
case FCmpInst::FCMP_OGT: return Expression::FCMPOGT;
case FCmpInst::FCMP_OGE: return Expression::FCMPOGE;
@@ -264,7 +265,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) {
Expression::ExpressionOpcode ValueTable::getOpcode(CastInst* C) {
switch(C->getOpcode()) {
default: // THIS SHOULD NEVER HAPPEN
- assert(0 && "Cast operator with unknown opcode?");
+ LLVM_UNREACHABLE("Cast operator with unknown opcode?");
case Instruction::Trunc: return Expression::TRUNC;
case Instruction::ZExt: return Expression::ZEXT;
case Instruction::SExt: return Expression::SEXT;
diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp
index af7e039eb9..d5098f2953 100644
--- a/lib/Transforms/Scalar/GVNPRE.cpp
+++ b/lib/Transforms/Scalar/GVNPRE.cpp
@@ -39,6 +39,7 @@
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <deque>
#include <map>
@@ -240,7 +241,7 @@ Expression::ExpressionOpcode
// THIS SHOULD NEVER HAPPEN
default:
- assert(0 && "Binary operator with unknown opcode?");
+ LLVM_UNREACHABLE("Binary operator with unknown opcode?");
return Expression::ADD;
}
}
@@ -271,7 +272,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) {
// THIS SHOULD NEVER HAPPEN
default:
- assert(0 && "Comparison with unknown predicate?");
+ LLVM_UNREACHABLE("Comparison with unknown predicate?");
return Expression::ICMPEQ;
}
} else {
@@ -307,7 +308,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) {
// THIS SHOULD NEVER HAPPEN
default:
- assert(0 && "Comparison with unknown predicate?");
+ LLVM_UNREACHABLE("Comparison with unknown predicate?");
return Expression::FCMPOEQ;
}
}
@@ -343,7 +344,7 @@ Expression::ExpressionOpcode
// THIS SHOULD NEVER HAPPEN
default:
- assert(0 && "Cast operator with unknown opcode?");
+ LLVM_UNREACHABLE("Cast operator with unknown opcode?");
return Expression::BITCAST;
}
}
@@ -577,7 +578,7 @@ uint32_t ValueTable::lookup(Value* V) const {
if (VI != valueNumbering.end())
return VI->second;
else
- assert(0 && "Value not numbered?");
+ LLVM_UNREACHABLE("Value not numbered?");
return 0;
}
@@ -767,7 +768,7 @@ Value* GVNPRE::find_leader(ValueNumberedSet& vals, uint32_t v) {
if (v == VN.lookup(*I))
return *I;
- assert(0 && "No leader found, but present bit is set?");
+ LLVM_UNREACHABLE("No leader found, but present bit is set?");
return 0;
}
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 89881f739f..6aa6530126 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1679,7 +1679,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
UndefElts = UndefElts2;
if (VWidth > InVWidth) {
- assert(0 && "Unimp");
+ LLVM_UNREACHABLE("Unimp");
// If there are more elements in the result than there are in the source,
// then an output element is undef if the corresponding input element is
// undef.
@@ -1687,7 +1687,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
if (UndefElts2[OutIdx/Ratio])
UndefElts.set(OutIdx);
} else if (VWidth < InVWidth) {
- assert(0 && "Unimp");
+ LLVM_UNREACHABLE("Unimp");
// If there are more elements in the source than there are in the result,
// then a result element is undef if all of the corresponding input
// elements are undef.
@@ -1757,7 +1757,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
RHS = InsertNewInstBefore(new ExtractElementInst(RHS, 0U,"tmp"), *II);
switch (II->getIntrinsicID()) {
- default: assert(0 && "Case stmts out of sync!");
+ default: LLVM_UNREACHABLE("Case stmts out of sync!");
case Intrinsic::x86_sse_sub_ss:
case Intrinsic::x86_sse2_sub_sd:
TmpV = InsertNewInstBefore(BinaryOperator::CreateFSub(LHS, RHS,
@@ -2019,7 +2019,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
PN->getIncomingValue(i), C, "phitmp",
NonConstBB->getTerminator());
else
- assert(0 && "Unknown binop!");
+ LLVM_UNREACHABLE("Unknown binop!");
AddToWorkList(cast<Instruction>(InV));
}
@@ -3355,7 +3355,7 @@ static unsigned getICmpCode(const ICmpInst *ICI) {
case ICmpInst::ICMP_SLE: return 6; // 110
// True -> 7
default:
- assert(0 && "Invalid ICmp predicate!");
+ LLVM_UNREACHABLE("Invalid ICmp predicate!");
return 0;
}
}
@@ -3383,7 +3383,7 @@ static unsigned getFCmpCode(FCmpInst::Predicate CC, bool &isOrdered) {
// True -> 7
default:
// Not expecting FCMP_FALSE and FCMP_TRUE;
- assert(0 && "Unexpected FCmp predicate!");
+ LLVM_UNREACHABLE("Unexpected FCmp predicate!");
return 0;
}
}
@@ -3395,7 +3395,7 @@ static unsigned getFCmpCode(FCmpInst::Predicate CC, bool &isOrdered) {
static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS,
LLVMContext *Context) {
switch (code) {
- default: assert(0 && "Illegal ICmp code!");
+ default: LLVM_UNREACHABLE("Illegal ICmp code!");
case 0: return Context->getConstantIntFalse();
case 1:
if (sign)
@@ -3429,7 +3429,7 @@ static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS,
static Value *getFCmpValue(bool isordered, unsigned code,
Value *LHS, Value *RHS, LLVMContext *Context) {
switch (code) {
- default: assert(0 && "Illegal FCmp code!");
+ default: LLVM_UNREACHABLE("Illegal FCmp code!");
case 0:
if (isordered)
return new FCmpInst(*Context, FCmpInst::FCMP_ORD, LHS, RHS);
@@ -3508,7 +3508,7 @@ struct FoldICmpLogical {
case Instruction::And: Code = LHSCode & RHSCode; break;
case Instruction::Or: Code = LHSCode | RHSCode; break;
case Instruction::Xor: Code = LHSCode ^ RHSCode; break;
- default: assert(0 && "Illegal logical opcode!"); return 0;
+ default: LLVM_UNREACHABLE("Illegal logical opcode!"); return 0;
}
bool isSigned = ICmpInst::isSignedPredicate(RHSICI->getPredicate()) ||
@@ -3843,10 +3843,10 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
assert(LHSCst != RHSCst && "Compares not folded above?");
switch (LHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X == 13 & X == 15) -> false
case ICmpInst::ICMP_UGT: // (X == 13 & X > 15) -> false
case ICmpInst::ICMP_SGT: // (X == 13 & X > 15) -> false
@@ -3858,7 +3858,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
}
case ICmpInst::ICMP_NE:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_ULT:
if (LHSCst == SubOne(RHSCst, Context)) // (X != 13 & X u< 14) -> X < 13
return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Val, LHSCst);
@@ -3885,7 +3885,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_ULT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X u< 13 & X == 15) -> false
case ICmpInst::ICMP_UGT: // (X u< 13 & X u> 15) -> false
return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
@@ -3900,7 +3900,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_SLT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X s< 13 & X == 15) -> false
case ICmpInst::ICMP_SGT: // (X s< 13 & X s> 15) -> false
return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
@@ -3915,7 +3915,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_UGT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X u> 13 & X == 15) -> X == 15
case ICmpInst::ICMP_UGT: // (X u> 13 & X u> 15) -> X u> 15
return ReplaceInstUsesWith(I, RHS);
@@ -3934,7 +3934,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_SGT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X s> 13 & X == 15) -> X == 15
case ICmpInst::ICMP_SGT: // (X s> 13 & X s> 15) -> X s> 15
return ReplaceInstUsesWith(I, RHS);
@@ -4532,10 +4532,10 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
assert(LHSCst != RHSCst && "Compares not folded above?");
switch (LHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ:
if (LHSCst == SubOne(RHSCst, Context)) {
// (X == 13 | X == 14) -> X-13 <u 2
@@ -4558,7 +4558,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_NE:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X != 13 | X == 15) -> X != 13
case ICmpInst::ICMP_UGT: // (X != 13 | X u> 15) -> X != 13
case ICmpInst::ICMP_SGT: // (X != 13 | X s> 15) -> X != 13
@@ -4571,7 +4571,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_ULT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X u< 13 | X == 14) -> no change
break;
case ICmpInst::ICMP_UGT: // (X u< 13 | X u> 15) -> (X-13) u> 2
@@ -4592,7 +4592,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_SLT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X s< 13 | X == 14) -> no change
break;
case ICmpInst::ICMP_SGT: // (X s< 13 | X s> 15) -> (X-13) s> 2
@@ -4613,7 +4613,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_UGT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X u> 13 | X == 15) -> X u> 13
case ICmpInst::ICMP_UGT: // (X u> 13 | X u> 15) -> X u> 13
return ReplaceInstUsesWith(I, LHS);
@@ -4628,7 +4628,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
break;
case ICmpInst::ICMP_SGT:
switch (RHSCC) {
- default: assert(0 && "Unknown integer condition code!");
+ default: LLVM_UNREACHABLE("Unknown integer condition code!");
case ICmpInst::ICMP_EQ: // (X s> 13 | X == 15) -> X > 13
case ICmpInst::ICMP_SGT: // (X s> 13 | X s> 15) -> X > 13
return ReplaceInstUsesWith(I, LHS);
@@ -5704,7 +5704,7 @@ Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I,
ICmpInst::Predicate Pred;
switch (I.getPredicate()) {
- default: assert(0 && "Unexpected predicate!");
+ default: LLVM_UNREACHABLE("Unexpected predicate!");
case FCmpInst::FCMP_UEQ:
case FCmpInst::FCMP_OEQ:
Pred = ICmpInst::ICMP_EQ;
@@ -5798,7 +5798,7 @@ Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I,
// the compare predicate and sometimes the value. RHSC is rounded towards
// zero at this point.
switch (Pred) {
- default: assert(0 && "Unexpected integer comparison!");
+ default: LLVM_UNREACHABLE("Unexpected integer comparison!");
case ICmpInst::ICMP_NE: // (float)int != 4.4 --> true
return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
case ICmpInst::ICMP_EQ: // (float)int == 4.4 --> false
@@ -5875,7 +5875,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
// Simplify 'fcmp pred X, X'
if (Op0 == Op1) {
switch (I.getPredicate()) {
- default: assert(0 && "Unknown predicate!");
+ default: LLVM_UNREACHABLE("Unknown predicate!");
case FCmpInst::FCMP_UEQ: // True if unordered or equal
case FCmpInst::FCMP_UGE: // True if unordered, greater than, or equal
case FCmpInst::FCMP_ULE: // True if unordered, less than, or equal
@@ -5994,7 +5994,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// icmp's with boolean values can always be turned into bitwise operations
if (Ty == Type::Int1Ty) {
switch (I.getPredicate()) {
- default: assert(0 && "Invalid icmp instruction!");
+ default: LLVM_UNREACHABLE("Invalid icmp instruction!");
case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
Instruction *Xor = BinaryOperator::CreateXor(Op0, Op1, I.getName()+"tmp");
InsertNewInstBefore(Xor, I);
@@ -6136,7 +6136,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// Based on the range information we know about the LHS, see if we can
// simplify this comparison. For example, (x&4) < 8 is always true.
switch (I.getPredicate()) {
- default: assert(0 && "Unknown icmp opcode!");
+ default: LLVM_UNREACHABLE("Unknown icmp opcode!");
case ICmpInst::ICMP_EQ:
if (Op0Max.ult(Op1Min) || Op0Min.ugt(Op1Max))
return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
@@ -6645,7 +6645,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
Value *X = DivI->getOperand(0);
switch (Pred) {
- default: assert(0 && "Unhandled icmp opcode!");
+ default: LLVM_UNREACHABLE("Unhandled icmp opcode!");
case ICmpInst::ICMP_EQ:
if (LoOverflow && HiOverflow)
return ReplaceInstUsesWith(ICI, Context->getConstantIntFalse());
@@ -8081,7 +8081,7 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty,
}
default:
// TODO: Can handle more cases here.
- assert(0 && "Unreachable!");
+ LLVM_UNREACHABLE("Unreachable!");
break;
}
@@ -8296,7 +8296,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
default:
// All the others use floating point so we shouldn't actually
// get here because of the check above.
- assert(0 && "Unknown cast type");
+ LLVM_UNREACHABLE("Unknown cast type");
case Instruction::Trunc:
DoXForm = true;
break;
@@ -8352,7 +8352,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
assert(Res->getType() == DestTy);
switch (CI.getOpcode()) {
- default: assert(0 && "Unknown cast type!");
+ default: LLVM_UNREACHABLE("Unknown cast type!");
case Instruction::Trunc:
case Instruction::BitCast:
// Just replace this cast with the result.
@@ -9196,7 +9196,7 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
else
return BinaryOperator::Create(BO->getOpcode(), NewSI, MatchOp);
}
- assert(0 && "Shouldn't get here");
+ LLVM_UNREACHABLE("Shouldn't get here");
return 0;
}
@@ -9238,7 +9238,7 @@ Instruction *InstCombiner::FoldSelectIntoOp(SelectInst &SI, Value *TrueVal,
NewSel->takeName(TVI);
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TVI))
return BinaryOperator::Create(BO->getOpcode(), FalseVal, NewSel);
- assert(0 && "Unknown instruction!!");
+ LLVM_UNREACHABLE("Unknown instruction!!");
}
}
}
@@ -9267,7 +9267,7 @@ Instruction *InstCombiner::FoldSelectIntoOp(SelectInst &SI, Value *TrueVal,
NewSel->takeName(FVI);
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(FVI))
return BinaryOperator::Create(BO->getOpcode(), TrueVal, NewSel);
- assert(0 && "Unknown instruction!!");
+ LLVM_UNREACHABLE("Unknown instruction!!");
}
}
}
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 2de64c15ab..e521be2db2 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -456,7 +456,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
} else if (SCValue.isConstant())
Succs[SI->findCaseValue(cast<ConstantInt>(SCValue.getConstant()))] = true;
} else {
- assert(0 && "SCCP: Don't know how to handle this terminator!");
+ LLVM_UNREACHABLE("SCCP: Don't know how to handle this terminator!");
}
}
@@ -1806,7 +1806,7 @@ bool IPSCCP::runOnModule(Module &M) {
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(I)) {
assert(isa<UndefValue>(SI->getCondition()) && "Switch should fold");
} else {
- assert(0 && "Didn't fold away reference to block!");
+ LLVM_UNREACHABLE("Didn't fold away reference to block!");
}
#endif
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index da2c375be9..2c97e5796f 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -267,7 +267,7 @@ bool SROA::performScalarRepl(Function &F) {
// Check that all of the users of the allocation are capable of being
// transformed.
switch (isSafeAllocaToScalarRepl(AI)) {
- default: assert(0 && "Unexpected value!");
+ default: LLVM_UNREACHABLE("Unexpected value!");
case 0: // Not safe to scalar replace.
break;
case 1: // Safe, but requires cleanup/canonicalizations first
diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp
index c4fd1eae43..f45f24ccfc 100644
--- a/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -26,6 +26,7 @@
#include "llvm/Type.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
@@ -222,8 +223,8 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
// If NewBBDominatesDestBB hasn't been computed yet, do so with DF.
if (!OtherPreds.empty()) {
// FIXME: IMPLEMENT THIS!
- assert(0 && "Requiring domfrontiers but not idom/domtree/domset."
- " not implemented yet!");
+ LLVM_UNREACHABLE("Requiring domfrontiers but not idom/domtree/domset."
+ " not implemented yet!");
}
// Since the new block is dominated by its only predecessor TIBB,
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp
index 21b3a220c3..951d24f121 100644
--- a/lib/Transforms/Utils/ValueMapper.cpp
+++ b/lib/Transforms/Utils/ValueMapper.cpp
@@ -20,6 +20,7 @@
#include "llvm/LLVMContext.h"
#include "llvm/MDNode.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext *Context) {
@@ -126,7 +127,7 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext *Context) {
return VM[V] = C;
} else {
- assert(0 && "Unknown type of constant!");
+ LLVM_UNREACHABLE("Unknown type of constant!");
}
}