|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 5 |
| 2 | +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fsanitize=signed-integer-overflow -O3 %s -o - -fsanitize-recover=signed-integer-overflow | FileCheck %s --check-prefixes=RECOVER |
| 3 | +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fsanitize=signed-integer-overflow -O3 %s -o - | FileCheck %s --check-prefixes=ABORT |
| 4 | + |
| 5 | +// RECOVER: Function Attrs: mustprogress nounwind |
| 6 | +// RECOVER-LABEL: define dso_local noundef range(i32 -32768, 32768) i32 @_Z4testRiRs( |
| 7 | +// RECOVER-SAME: ptr noundef nonnull align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noundef nonnull readonly align 2 captures(none) dereferenceable(2) [[C:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 8 | +// RECOVER-NEXT: [[ENTRY:.*]]: |
| 9 | +// RECOVER-NEXT: [[TMP0:%.*]] = load i16, ptr [[C]], align 2, !tbaa [[TBAA2:![0-9]+]] |
| 10 | +// RECOVER-NEXT: [[CONV:%.*]] = sext i16 [[TMP0]] to i32 |
| 11 | +// RECOVER-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 4, !tbaa [[TBAA6:![0-9]+]] |
| 12 | +// RECOVER-NEXT: [[TMP2:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP1]], i32 [[CONV]]), !nosanitize [[META8:![0-9]+]] |
| 13 | +// RECOVER-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !nosanitize [[META8]] |
| 14 | +// RECOVER-NEXT: br i1 [[TMP3]], label %[[HANDLER_ADD_OVERFLOW:.*]], label %[[CONT:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] |
| 15 | +// RECOVER: [[HANDLER_ADD_OVERFLOW]]: |
| 16 | +// RECOVER-NEXT: [[TMP4:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize [[META8]] |
| 17 | +// RECOVER-NEXT: [[TMP5:%.*]] = zext i32 [[CONV]] to i64, !nosanitize [[META8]] |
| 18 | +// RECOVER-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB1]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR3:[0-9]+]], !nosanitize [[META8]] |
| 19 | +// RECOVER-NEXT: [[DOTPRE:%.*]] = load i16, ptr [[C]], align 2, !tbaa [[TBAA2]] |
| 20 | +// RECOVER-NEXT: [[DOTPRE3:%.*]] = sext i16 [[DOTPRE]] to i32 |
| 21 | +// RECOVER-NEXT: br label %[[CONT]], !nosanitize [[META8]] |
| 22 | +// RECOVER: [[CONT]]: |
| 23 | +// RECOVER-NEXT: [[CONV1_PRE_PHI:%.*]] = phi i32 [ [[DOTPRE3]], %[[HANDLER_ADD_OVERFLOW]] ], [ [[CONV]], %[[ENTRY]] ] |
| 24 | +// RECOVER-NEXT: [[TMP6:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !nosanitize [[META8]] |
| 25 | +// RECOVER-NEXT: store i32 [[TMP6]], ptr [[A]], align 4, !tbaa [[TBAA6]] |
| 26 | +// RECOVER-NEXT: ret i32 [[CONV1_PRE_PHI]] |
| 27 | +// |
| 28 | +// ABORT: Function Attrs: mustprogress nounwind |
| 29 | +// ABORT-LABEL: define dso_local noundef range(i32 -32768, 32768) i32 @_Z4testRiRs( |
| 30 | +// ABORT-SAME: ptr noundef nonnull align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noundef nonnull readonly align 2 captures(none) dereferenceable(2) [[C:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 31 | +// ABORT-NEXT: [[ENTRY:.*:]] |
| 32 | +// ABORT-NEXT: [[TMP0:%.*]] = load i16, ptr [[C]], align 2, !tbaa [[TBAA2:![0-9]+]] |
| 33 | +// ABORT-NEXT: [[CONV:%.*]] = sext i16 [[TMP0]] to i32 |
| 34 | +// ABORT-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 4, !tbaa [[TBAA6:![0-9]+]] |
| 35 | +// ABORT-NEXT: [[TMP2:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP1]], i32 [[CONV]]), !nosanitize [[META8:![0-9]+]] |
| 36 | +// ABORT-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !nosanitize [[META8]] |
| 37 | +// ABORT-NEXT: br i1 [[TMP3]], label %[[HANDLER_ADD_OVERFLOW:.*]], label %[[CONT:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] |
| 38 | +// ABORT: [[HANDLER_ADD_OVERFLOW]]: |
| 39 | +// ABORT-NEXT: [[TMP4:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize [[META8]] |
| 40 | +// ABORT-NEXT: [[TMP5:%.*]] = zext i32 [[CONV]] to i64, !nosanitize [[META8]] |
| 41 | +// ABORT-NEXT: tail call void @__ubsan_handle_add_overflow_abort(ptr nonnull @[[GLOB1]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR3:[0-9]+]], !nosanitize [[META8]] |
| 42 | +// ABORT-NEXT: unreachable, !nosanitize [[META8]] |
| 43 | +// ABORT: [[CONT]]: |
| 44 | +// ABORT-NEXT: [[TMP6:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !nosanitize [[META8]] |
| 45 | +// ABORT-NEXT: store i32 [[TMP6]], ptr [[A]], align 4, !tbaa [[TBAA6]] |
| 46 | +// ABORT-NEXT: ret i32 [[CONV]] |
| 47 | +// |
| 48 | +int test(int &a, short &c) { |
| 49 | + a += c; |
| 50 | + return c; |
| 51 | +} |
| 52 | +//. |
| 53 | +// RECOVER: attributes #[[ATTR0]] = { mustprogress nounwind "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 54 | +// RECOVER: attributes #[[ATTR1:[0-9]+]] = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 55 | +// RECOVER: attributes #[[ATTR2:[0-9]+]] = { uwtable } |
| 56 | +// RECOVER: attributes #[[ATTR3]] = { nomerge nounwind } |
| 57 | +//. |
| 58 | +// ABORT: attributes #[[ATTR0]] = { mustprogress nounwind "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 59 | +// ABORT: attributes #[[ATTR1:[0-9]+]] = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 60 | +// ABORT: attributes #[[ATTR2:[0-9]+]] = { noreturn nounwind uwtable } |
| 61 | +// ABORT: attributes #[[ATTR3]] = { nomerge noreturn nounwind } |
| 62 | +//. |
| 63 | +// RECOVER: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} |
| 64 | +// RECOVER: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} |
| 65 | +// RECOVER: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} |
| 66 | +// RECOVER: [[META3]] = !{!"short", [[META4:![0-9]+]], i64 0} |
| 67 | +// RECOVER: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0} |
| 68 | +// RECOVER: [[META5]] = !{!"Simple C++ TBAA"} |
| 69 | +// RECOVER: [[TBAA6]] = !{[[META7:![0-9]+]], [[META7]], i64 0} |
| 70 | +// RECOVER: [[META7]] = !{!"int", [[META4]], i64 0} |
| 71 | +// RECOVER: [[META8]] = !{} |
| 72 | +// RECOVER: [[PROF9]] = !{!"branch_weights", i32 1, i32 1048575} |
| 73 | +//. |
| 74 | +// ABORT: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} |
| 75 | +// ABORT: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} |
| 76 | +// ABORT: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} |
| 77 | +// ABORT: [[META3]] = !{!"short", [[META4:![0-9]+]], i64 0} |
| 78 | +// ABORT: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0} |
| 79 | +// ABORT: [[META5]] = !{!"Simple C++ TBAA"} |
| 80 | +// ABORT: [[TBAA6]] = !{[[META7:![0-9]+]], [[META7]], i64 0} |
| 81 | +// ABORT: [[META7]] = !{!"int", [[META4]], i64 0} |
| 82 | +// ABORT: [[META8]] = !{} |
| 83 | +// ABORT: [[PROF9]] = !{!"branch_weights", i32 1, i32 1048575} |
| 84 | +//. |
0 commit comments