================ @@ -0,0 +1,66 @@ +// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv +// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECK + +// Check that -fsanitize=signed-integer-overflow doesn't instrument with -fwrapv +// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CHECKSIO + +extern volatile int a, b, c; + +// CHECK-LABEL: define void @test_add_overflow +void test_add_overflow(void) { + // CHECK: [[ADD0:%.*]] = load {{.*}} i32 + // CHECK-NEXT: [[ADD1:%.*]] = load {{.*}} i32 + // CHECK-NEXT: {{%.*}} = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[ADD0]], i32 [[ADD1]]) + // CHECK: call void @__ubsan_handle_add_overflow + + // CHECKSIO-NOT: call void @__ubsan_handle_add_overflow + a = b + c; +} + +// CHECK-LABEL: define void @test_inc_overflow +void test_inc_overflow(void) { + // This decays and gets handled by __ubsan_handle_add_overflow... + // CHECK: [[INC0:%.*]] = load {{.*}} i32 + // CHECK-NEXT: call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[INC0]], i32 1) + // CHECK: br {{.*}} %handler.add_overflow + + // CHECKSIO-NOT: br {{.*}} %handler.add_overflow ---------------- tschuett wrote:
In some tests the branch on the overflow bit is not visible. It gives you more confidence, if there is always a branch on the overflow bit. https://github.com/llvm/llvm-project/pull/80089 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits