[cfe-commits] r167258 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/trapv.c
Richard Smith
richard-llvm at metafoo.co.uk
Thu Nov 1 15:13:39 PDT 2012
Author: rsmith
Date: Thu Nov 1 17:13:39 2012
New Revision: 167258
URL: http://llvm.org/viewvc/llvm-project?rev=167258&view=rev
Log:
Remove divison-by-zero checks from -ftrapv. These checks were incompatible with
g++'s -ftrapv, failed to call the -ftrapv overflow handler, and are still
available under -fcatch-undefined-behavior.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/trapv.c
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=167258&r1=167257&r2=167258&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Nov 1 17:13:39 2012
@@ -418,10 +418,6 @@
return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");
return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
}
- bool isTrapvOverflowBehavior() {
- return CGF.getContext().getLangOpts().getSignedOverflowBehavior()
- == LangOptions::SOB_Trapping || CGF.CatchUndefined;
- }
/// Create a binary op that checks for overflow.
/// Currently only supports +, - and *.
Value *EmitOverflowCheckedBinOp(const BinOpInfo &Ops);
@@ -1946,7 +1942,7 @@
}
Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {
- if (isTrapvOverflowBehavior()) {
+ if (CGF.CatchUndefined) {
llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
if (Ops.Ty->isIntegerType())
@@ -1974,7 +1970,7 @@
Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
// Rem in C can't be a floating point type: C99 6.5.5p2.
- if (isTrapvOverflowBehavior()) {
+ if (CGF.CatchUndefined) {
llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
if (Ops.Ty->isIntegerType())
Modified: cfe/trunk/test/CodeGen/trapv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/trapv.c?rev=167258&r1=167257&r2=167258&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/trapv.c (original)
+++ cfe/trunk/test/CodeGen/trapv.c Thu Nov 1 17:13:39 2012
@@ -50,3 +50,12 @@
// CHECK-NEXT: br i1 [[T5]]
// CHECK: call void @llvm.trap()
}
+
+// CHECK: define void @test3(
+void test3(int a, int b, float c, float d) {
+ // CHECK-NOT: @llvm.trap
+ (void)(a / b);
+ (void)(a % b);
+ (void)(c / d);
+ // CHECK: }
+}
More information about the cfe-commits
mailing list