forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca55ee8
commit 96a99a5
Showing
1 changed file
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 | ||
// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -remove-traps-random-rate=1 %s -o - | FileCheck %s --implicit-check-not="call void @llvm.ubsantrap" --check-prefixes=REMOVE | ||
|
||
// CHECK-LABEL: define dso_local noundef i32 @test( | ||
// CHECK-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]] | ||
// CHECK-NEXT: br i1 [[TMP1]], label [[TRAP:%.*]], label [[CONT:%.*]], !nosanitize [[META2]] | ||
// CHECK: trap: | ||
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR3:[0-9]+]], !nosanitize [[META2]] | ||
// CHECK-NEXT: unreachable, !nosanitize [[META2]] | ||
// CHECK: cont: | ||
// CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]] | ||
// CHECK-NEXT: ret i32 [[TMP2]] | ||
// | ||
// REMOVE-LABEL: define dso_local noundef i32 @test( | ||
// REMOVE-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// REMOVE-NEXT: entry: | ||
// REMOVE-NEXT: [[TMP0:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]] | ||
// REMOVE-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]] | ||
// REMOVE-NEXT: [[TMP2:%.*]] = xor i1 [[TMP1]], true | ||
// REMOVE-NEXT: tail call void @llvm.assume(i1 [[TMP2]]) | ||
// REMOVE-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]] | ||
// REMOVE-NEXT: ret i32 [[TMP3]] | ||
// | ||
int test(int x) { | ||
return x + 123; | ||
} | ||
|
||
// CHECK-LABEL: define {{.*}}i32 @test( | ||
// CHECK: call { i32, i1 } @llvm.sadd.with.overflow.i32( | ||
// CHECK: trap: | ||
// CHECK-NEXT: call void @llvm.ubsantrap(i8 0) | ||
// CHECK-NEXT: unreachable | ||
|
||
// REMOVE-LABEL: define {{.*}}i32 @test( | ||
// REMOVE: call { i32, i1 } @llvm.sadd.with.overflow.i32( | ||
//. | ||
// CHECK: [[META2]] = !{} | ||
//. | ||
// REMOVE: [[META2]] = !{} | ||
//. |