|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +// RUN: %clang_cc1 -O2 -triple x86_64-linux-gnu -emit-llvm -o - %s \ |
| 3 | +// RUN: -fdebug-prefix-map=%S/= -fno-ident -fdebug-compilation-dir=%S -debug-info-kind=limited \ |
| 4 | +// RUN: -fsanitize-annotate-debug-info=signed-integer-overflow \ |
| 5 | +// RUN: -fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CHECKS |
| 6 | + |
| 7 | +// RUN: %clang_cc1 -O2 -triple x86_64-linux-gnu -emit-llvm -o - %s \ |
| 8 | +// RUN: -fdebug-prefix-map=%S/= -fno-ident -fdebug-compilation-dir=%S -debug-info-kind=limited \ |
| 9 | +// RUN: -fsanitize-annotate-debug-info=signed-integer-overflow \ |
| 10 | +// RUN: -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=CHECKU |
| 11 | + |
| 12 | +unsigned short si, sj, sk; |
| 13 | + |
| 14 | +// CHECKS-LABEL: define dso_local void @testshortmul( |
| 15 | +// CHECKS-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] !dbg [[DBG13:![0-9]+]] { |
| 16 | +// CHECKS-NEXT: [[ENTRY:.*:]] |
| 17 | +// CHECKS-NEXT: [[TMP0:%.*]] = load i16, ptr @sj, align 2, !dbg [[DBG16:![0-9]+]], !tbaa [[TBAA17:![0-9]+]] |
| 18 | +// CHECKS-NEXT: [[CONV:%.*]] = zext i16 [[TMP0]] to i32, !dbg [[DBG16]] |
| 19 | +// CHECKS-NEXT: [[TMP1:%.*]] = load i16, ptr @sk, align 2, !dbg [[DBG21:![0-9]+]], !tbaa [[TBAA17]] |
| 20 | +// CHECKS-NEXT: [[CONV1:%.*]] = zext i16 [[TMP1]] to i32, !dbg [[DBG21]] |
| 21 | +// CHECKS-NEXT: [[TMP2:%.*]] = tail call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[CONV]], i32 [[CONV1]]), !dbg [[DBG22:![0-9]+]], !nosanitize [[META23:![0-9]+]] |
| 22 | +// CHECKS-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !dbg [[DBG22]], !nosanitize [[META23]] |
| 23 | +// CHECKS-NEXT: br i1 [[TMP3]], label %[[HANDLER_MUL_OVERFLOW:.*]], label %[[CONT:.*]], !dbg [[DBG22]], !prof [[PROF24:![0-9]+]], !nosanitize [[META23]] |
| 24 | +// CHECKS: [[HANDLER_MUL_OVERFLOW]]: |
| 25 | +// CHECKS-NEXT: [[TMP4:%.*]] = zext i16 [[TMP0]] to i64, !dbg [[DBG22]] |
| 26 | +// CHECKS-NEXT: [[TMP5:%.*]] = zext i16 [[TMP1]] to i64, !dbg [[DBG22]] |
| 27 | +// CHECKS-NEXT: tail call void @__ubsan_handle_mul_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR3:[0-9]+]], !dbg [[DBG22]], !nosanitize [[META23]] |
| 28 | +// CHECKS-NEXT: unreachable, !dbg [[DBG22]], !nosanitize [[META23]] |
| 29 | +// CHECKS: [[CONT]]: |
| 30 | +// CHECKS-NEXT: [[TMP6:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !dbg [[DBG22]], !nosanitize [[META23]] |
| 31 | +// CHECKS-NEXT: [[CONV2:%.*]] = trunc i32 [[TMP6]] to i16, !dbg [[DBG16]] |
| 32 | +// CHECKS-NEXT: store i16 [[CONV2]], ptr @si, align 2, !dbg [[DBG25:![0-9]+]], !tbaa [[TBAA17]] |
| 33 | +// CHECKS-NEXT: ret void, !dbg [[DBG26:![0-9]+]] |
| 34 | +// |
| 35 | +// CHECKU-LABEL: define dso_local void @testshortmul( |
| 36 | +// CHECKU-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] !dbg [[DBG13:![0-9]+]] { |
| 37 | +// CHECKU-NEXT: [[ENTRY:.*:]] |
| 38 | +// CHECKU-NEXT: [[TMP0:%.*]] = load i16, ptr @sj, align 2, !dbg [[DBG16:![0-9]+]], !tbaa [[TBAA17:![0-9]+]] |
| 39 | +// CHECKU-NEXT: [[TMP1:%.*]] = load i16, ptr @sk, align 2, !dbg [[DBG21:![0-9]+]], !tbaa [[TBAA17]] |
| 40 | +// CHECKU-NEXT: [[MUL:%.*]] = mul i16 [[TMP1]], [[TMP0]], !dbg [[DBG22:![0-9]+]] |
| 41 | +// CHECKU-NEXT: store i16 [[MUL]], ptr @si, align 2, !dbg [[DBG23:![0-9]+]], !tbaa [[TBAA17]] |
| 42 | +// CHECKU-NEXT: ret void, !dbg [[DBG24:![0-9]+]] |
| 43 | +// |
| 44 | +void testshortmul(void) { |
| 45 | + |
| 46 | + // |
| 47 | + si = sj * sk; |
| 48 | +} |
| 49 | +//. |
| 50 | +// CHECKS: [[META0:![0-9]+]] = !DIGlobalVariableExpression(var: [[META1:![0-9]+]], expr: !DIExpression()) |
| 51 | +// CHECKS: [[META1]] = distinct !DIGlobalVariable(name: "sj", scope: [[META2:![0-9]+]], file: [[META7:![0-9]+]], line: 12, type: [[META8:![0-9]+]], isLocal: false, isDefinition: true) |
| 52 | +// CHECKS: [[META2]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META3:![0-9]+]], isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: [[META4:![0-9]+]], splitDebugInlining: false, nameTableKind: None) |
| 53 | +// CHECKS: [[META3]] = !DIFile(filename: "<stdin>", directory: {{.*}}) |
| 54 | +// CHECKS: [[META4]] = !{[[META5:![0-9]+]], [[META0]], [[META9:![0-9]+]]} |
| 55 | +// CHECKS: [[META5]] = !DIGlobalVariableExpression(var: [[META6:![0-9]+]], expr: !DIExpression()) |
| 56 | +// CHECKS: [[META6]] = distinct !DIGlobalVariable(name: "si", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 57 | +// CHECKS: [[META7]] = !DIFile(filename: "{{.*}}unsigned-promotion-debuginfo.c", directory: {{.*}}) |
| 58 | +// CHECKS: [[META8]] = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned) |
| 59 | +// CHECKS: [[META9]] = !DIGlobalVariableExpression(var: [[META10:![0-9]+]], expr: !DIExpression()) |
| 60 | +// CHECKS: [[META10]] = distinct !DIGlobalVariable(name: "sk", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 61 | +// CHECKS: [[DBG13]] = distinct !DISubprogram(name: "testshortmul", scope: [[META7]], file: [[META7]], line: 44, type: [[META14:![0-9]+]], scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META2]]) |
| 62 | +// CHECKS: [[META14]] = !DISubroutineType(types: [[META15:![0-9]+]]) |
| 63 | +// CHECKS: [[META15]] = !{null} |
| 64 | +// CHECKS: [[DBG16]] = !DILocation(line: 47, column: 8, scope: [[DBG13]]) |
| 65 | +// CHECKS: [[TBAA17]] = !{[[META18:![0-9]+]], [[META18]], i64 0} |
| 66 | +// CHECKS: [[META18]] = !{!"short", [[META19:![0-9]+]], i64 0} |
| 67 | +// CHECKS: [[META19]] = !{!"omnipotent char", [[META20:![0-9]+]], i64 0} |
| 68 | +// CHECKS: [[META20]] = !{!"Simple C/C++ TBAA"} |
| 69 | +// CHECKS: [[DBG21]] = !DILocation(line: 47, column: 13, scope: [[DBG13]]) |
| 70 | +// CHECKS: [[DBG22]] = !DILocation(line: 47, column: 11, scope: [[DBG13]]) |
| 71 | +// CHECKS: [[META23]] = !{} |
| 72 | +// CHECKS: [[PROF24]] = !{!"branch_weights", i32 1, i32 1048575} |
| 73 | +// CHECKS: [[DBG25]] = !DILocation(line: 47, column: 6, scope: [[DBG13]]) |
| 74 | +// CHECKS: [[DBG26]] = !DILocation(line: 48, column: 1, scope: [[DBG13]]) |
| 75 | +//. |
| 76 | +// CHECKU: [[META0:![0-9]+]] = !DIGlobalVariableExpression(var: [[META1:![0-9]+]], expr: !DIExpression()) |
| 77 | +// CHECKU: [[META1]] = distinct !DIGlobalVariable(name: "sj", scope: [[META2:![0-9]+]], file: [[META7:![0-9]+]], line: 12, type: [[META8:![0-9]+]], isLocal: false, isDefinition: true) |
| 78 | +// CHECKU: [[META2]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META3:![0-9]+]], isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: [[META4:![0-9]+]], splitDebugInlining: false, nameTableKind: None) |
| 79 | +// CHECKU: [[META3]] = !DIFile(filename: "<stdin>", directory: {{.*}}) |
| 80 | +// CHECKU: [[META4]] = !{[[META5:![0-9]+]], [[META0]], [[META9:![0-9]+]]} |
| 81 | +// CHECKU: [[META5]] = !DIGlobalVariableExpression(var: [[META6:![0-9]+]], expr: !DIExpression()) |
| 82 | +// CHECKU: [[META6]] = distinct !DIGlobalVariable(name: "si", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 83 | +// CHECKU: [[META7]] = !DIFile(filename: "{{.*}}unsigned-promotion-debuginfo.c", directory: {{.*}}) |
| 84 | +// CHECKU: [[META8]] = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned) |
| 85 | +// CHECKU: [[META9]] = !DIGlobalVariableExpression(var: [[META10:![0-9]+]], expr: !DIExpression()) |
| 86 | +// CHECKU: [[META10]] = distinct !DIGlobalVariable(name: "sk", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 87 | +// CHECKU: [[DBG13]] = distinct !DISubprogram(name: "testshortmul", scope: [[META7]], file: [[META7]], line: 44, type: [[META14:![0-9]+]], scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META2]]) |
| 88 | +// CHECKU: [[META14]] = !DISubroutineType(types: [[META15:![0-9]+]]) |
| 89 | +// CHECKU: [[META15]] = !{null} |
| 90 | +// CHECKU: [[DBG16]] = !DILocation(line: 47, column: 8, scope: [[DBG13]]) |
| 91 | +// CHECKU: [[TBAA17]] = !{[[META18:![0-9]+]], [[META18]], i64 0} |
| 92 | +// CHECKU: [[META18]] = !{!"short", [[META19:![0-9]+]], i64 0} |
| 93 | +// CHECKU: [[META19]] = !{!"omnipotent char", [[META20:![0-9]+]], i64 0} |
| 94 | +// CHECKU: [[META20]] = !{!"Simple C/C++ TBAA"} |
| 95 | +// CHECKU: [[DBG21]] = !DILocation(line: 47, column: 13, scope: [[DBG13]]) |
| 96 | +// CHECKU: [[DBG22]] = !DILocation(line: 47, column: 11, scope: [[DBG13]]) |
| 97 | +// CHECKU: [[DBG23]] = !DILocation(line: 47, column: 6, scope: [[DBG13]]) |
| 98 | +// CHECKU: [[DBG24]] = !DILocation(line: 48, column: 1, scope: [[DBG13]]) |
| 99 | +//. |
0 commit comments