summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-04-02 18:15:54 +0000
committerMike Stump <mrs@apple.com>2009-04-02 18:15:54 +0000
commitd3e3885f2df5ec3b7d9958b1d42ec5c9b66c3423 (patch)
treedabc001d0a9df4459ec804acf5e8baf5fae558a6 /clang/lib/CodeGen/CGExprScalar.cpp
parentcc841a3810acd2e8280ed3da4b0c2843b715cf3c (diff)
downloadbcm5719-llvm-d3e3885f2df5ec3b7d9958b1d42ec5c9b66c3423.tar.gz
bcm5719-llvm-d3e3885f2df5ec3b7d9958b1d42ec5c9b66c3423.zip
Remove -ftrapu.
llvm-svn: 68330
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp85
1 files changed, 28 insertions, 57 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 1d2da0ddf89..225b70882e2 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -262,9 +262,8 @@ public:
// Binary Operators.
Value *EmitMul(const BinOpInfo &Ops) {
- if (CGF.getContext().getLangOptions().UnsignedOverflowChecking
- || (CGF.getContext().getLangOptions().OverflowChecking
- && Ops.Ty->isSignedIntegerType()))
+ if (CGF.getContext().getLangOptions().OverflowChecking
+ && Ops.Ty->isSignedIntegerType())
return EmitOverflowCheckedBinOp(Ops);
return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
}
@@ -837,54 +836,28 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
unsigned IID;
unsigned OpID = 0;
- if (Ops.Ty->isSignedIntegerType()) {
- switch (Ops.E->getOpcode()) {
- case BinaryOperator::Add:
- case BinaryOperator::AddAssign:
- OpID = 1;
- IID = llvm::Intrinsic::sadd_with_overflow;
- break;
- case BinaryOperator::Sub:
- case BinaryOperator::SubAssign:
- OpID = 2;
- IID = llvm::Intrinsic::ssub_with_overflow;
- break;
- case BinaryOperator::Mul:
- case BinaryOperator::MulAssign:
- OpID = 3;
- IID = llvm::Intrinsic::smul_with_overflow;
- break;
- default:
- fprintf(stderr, "Opcode: %d\n", Ops.E->getOpcode());
- assert(false && "Unsupported operation for overflow detection");
- }
- OpID <<= 1;
- OpID |= 1;
- }
- else {
- assert(Ops.Ty->isUnsignedIntegerType() &&
- "Must be either a signed or unsigned integer op");
- switch (Ops.E->getOpcode()) {
- case BinaryOperator::Add:
- case BinaryOperator::AddAssign:
- OpID = 1;
- IID = llvm::Intrinsic::uadd_with_overflow;
- break;
- case BinaryOperator::Sub:
- case BinaryOperator::SubAssign:
- OpID = 2;
- IID = llvm::Intrinsic::usub_with_overflow;
- break;
- case BinaryOperator::Mul:
- case BinaryOperator::MulAssign:
- OpID = 3;
- IID = llvm::Intrinsic::umul_with_overflow;
- break;
- default:
- assert(false && "Unsupported operation for overflow detection");
- }
- OpID <<= 1;
- }
+ switch (Ops.E->getOpcode()) {
+ case BinaryOperator::Add:
+ case BinaryOperator::AddAssign:
+ OpID = 1;
+ IID = llvm::Intrinsic::sadd_with_overflow;
+ break;
+ case BinaryOperator::Sub:
+ case BinaryOperator::SubAssign:
+ OpID = 2;
+ IID = llvm::Intrinsic::ssub_with_overflow;
+ break;
+ case BinaryOperator::Mul:
+ case BinaryOperator::MulAssign:
+ OpID = 3;
+ IID = llvm::Intrinsic::smul_with_overflow;
+ break;
+ default:
+ assert(false && "Unsupported operation for overflow detection");
+ }
+ OpID <<= 1;
+ OpID |= 1;
+
const llvm::Type *opTy = CGF.CGM.getTypes().ConvertType(Ops.Ty);
llvm::Function *intrinsic = CGF.CGM.getIntrinsic(IID, &opTy, 1);
@@ -945,9 +918,8 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
if (!Ops.Ty->isPointerType()) {
- if (CGF.getContext().getLangOptions().UnsignedOverflowChecking
- || (CGF.getContext().getLangOptions().OverflowChecking
- && Ops.Ty->isSignedIntegerType()))
+ if (CGF.getContext().getLangOptions().OverflowChecking
+ && Ops.Ty->isSignedIntegerType())
return EmitOverflowCheckedBinOp(Ops);
return Builder.CreateAdd(Ops.LHS, Ops.RHS, "add");
}
@@ -998,9 +970,8 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
if (!isa<llvm::PointerType>(Ops.LHS->getType())) {
- if (CGF.getContext().getLangOptions().UnsignedOverflowChecking
- || (CGF.getContext().getLangOptions().OverflowChecking
- && Ops.Ty->isSignedIntegerType()))
+ if (CGF.getContext().getLangOptions().OverflowChecking
+ && Ops.Ty->isSignedIntegerType())
return EmitOverflowCheckedBinOp(Ops);
return Builder.CreateSub(Ops.LHS, Ops.RHS, "sub");
}
OpenPOWER on IntegriCloud