|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +// RUN: %clang_cc1 -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 -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: ) #[[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]+]] |
| 18 | +// CHECKS-NEXT: [[CONV:%.*]] = zext i16 [[TMP0]] to i32, !dbg [[DBG16]] |
| 19 | +// CHECKS-NEXT: [[TMP1:%.*]] = load i16, ptr @sk, align 2, !dbg [[DBG17:![0-9]+]] |
| 20 | +// CHECKS-NEXT: [[CONV1:%.*]] = zext i16 [[TMP1]] to i32, !dbg [[DBG17]] |
| 21 | +// CHECKS-NEXT: [[TMP2:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[CONV]], i32 [[CONV1]]), !dbg [[DBG18:![0-9]+]], !nosanitize [[META19:![0-9]+]] |
| 22 | +// CHECKS-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !dbg [[DBG18]], !nosanitize [[META19]] |
| 23 | +// CHECKS-NEXT: [[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !dbg [[DBG18]], !nosanitize [[META19]] |
| 24 | +// CHECKS-NEXT: [[TMP5:%.*]] = xor i1 [[TMP4]], true, !dbg [[DBG18]], !nosanitize [[META19]] |
| 25 | +// CHECKS-NEXT: br i1 [[TMP5]], label %[[CONT:.*]], label %[[HANDLER_MUL_OVERFLOW:.*]], !dbg [[DBG18]], !prof [[PROF20:![0-9]+]], !nosanitize [[META19]] |
| 26 | +// CHECKS: [[HANDLER_MUL_OVERFLOW]]: |
| 27 | +// CHECKS-NEXT: [[TMP6:%.*]] = zext i32 [[CONV]] to i64, !dbg [[DBG18]], !nosanitize [[META19]] |
| 28 | +// CHECKS-NEXT: [[TMP7:%.*]] = zext i32 [[CONV1]] to i64, !dbg [[DBG18]], !nosanitize [[META19]] |
| 29 | +// CHECKS-NEXT: call void @__ubsan_handle_mul_overflow_abort(ptr @[[GLOB1:[0-9]+]], i64 [[TMP6]], i64 [[TMP7]]) #[[ATTR3:[0-9]+]], !dbg [[DBG18]], !nosanitize [[META19]] |
| 30 | +// CHECKS-NEXT: unreachable, !dbg [[DBG18]], !nosanitize [[META19]] |
| 31 | +// CHECKS: [[CONT]]: |
| 32 | +// CHECKS-NEXT: [[CONV2:%.*]] = trunc i32 [[TMP3]] to i16, !dbg [[DBG16]] |
| 33 | +// CHECKS-NEXT: store i16 [[CONV2]], ptr @si, align 2, !dbg [[DBG21:![0-9]+]] |
| 34 | +// CHECKS-NEXT: ret void, !dbg [[DBG22:![0-9]+]] |
| 35 | +// |
| 36 | +// CHECKU-LABEL: define dso_local void @testshortmul( |
| 37 | +// CHECKU-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG13:![0-9]+]] { |
| 38 | +// CHECKU-NEXT: [[ENTRY:.*:]] |
| 39 | +// CHECKU-NEXT: [[TMP0:%.*]] = load i16, ptr @sj, align 2, !dbg [[DBG16:![0-9]+]] |
| 40 | +// CHECKU-NEXT: [[CONV:%.*]] = zext i16 [[TMP0]] to i32, !dbg [[DBG16]] |
| 41 | +// CHECKU-NEXT: [[TMP1:%.*]] = load i16, ptr @sk, align 2, !dbg [[DBG17:![0-9]+]] |
| 42 | +// CHECKU-NEXT: [[CONV1:%.*]] = zext i16 [[TMP1]] to i32, !dbg [[DBG17]] |
| 43 | +// CHECKU-NEXT: [[MUL:%.*]] = mul nsw i32 [[CONV]], [[CONV1]], !dbg [[DBG18:![0-9]+]] |
| 44 | +// CHECKU-NEXT: [[CONV2:%.*]] = trunc i32 [[MUL]] to i16, !dbg [[DBG16]] |
| 45 | +// CHECKU-NEXT: store i16 [[CONV2]], ptr @si, align 2, !dbg [[DBG19:![0-9]+]] |
| 46 | +// CHECKU-NEXT: ret void, !dbg [[DBG20:![0-9]+]] |
| 47 | +// |
| 48 | +void testshortmul(void) { |
| 49 | + |
| 50 | + // |
| 51 | + si = sj * sk; |
| 52 | +} |
| 53 | +//. |
| 54 | +// CHECKS: [[META0:![0-9]+]] = !DIGlobalVariableExpression(var: [[META1:![0-9]+]], expr: !DIExpression()) |
| 55 | +// CHECKS: [[META1]] = distinct !DIGlobalVariable(name: "sj", scope: [[META2:![0-9]+]], file: [[META7:![0-9]+]], line: 12, type: [[META8:![0-9]+]], isLocal: false, isDefinition: true) |
| 56 | +// CHECKS: [[META2]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META3:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: [[META4:![0-9]+]], splitDebugInlining: false, nameTableKind: None) |
| 57 | +// CHECKS: [[META3]] = !DIFile(filename: "<stdin>", directory: {{.*}}) |
| 58 | +// CHECKS: [[META4]] = !{[[META5:![0-9]+]], [[META0]], [[META9:![0-9]+]]} |
| 59 | +// CHECKS: [[META5]] = !DIGlobalVariableExpression(var: [[META6:![0-9]+]], expr: !DIExpression()) |
| 60 | +// CHECKS: [[META6]] = distinct !DIGlobalVariable(name: "si", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 61 | +// CHECKS: [[META7]] = !DIFile(filename: "{{.*}}unsigned-promotion-debuginfo.c", directory: {{.*}}) |
| 62 | +// CHECKS: [[META8]] = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned) |
| 63 | +// CHECKS: [[META9]] = !DIGlobalVariableExpression(var: [[META10:![0-9]+]], expr: !DIExpression()) |
| 64 | +// CHECKS: [[META10]] = distinct !DIGlobalVariable(name: "sk", scope: [[META2]], file: [[META7]], line: 12, type: [[META8]], isLocal: false, isDefinition: true) |
| 65 | +// CHECKS: [[DBG13]] = distinct !DISubprogram(name: "testshortmul", scope: [[META7]], file: [[META7]], line: 48, type: [[META14:![0-9]+]], scopeLine: 48, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: [[META2]]) |
| 66 | +// CHECKS: [[META14]] = !DISubroutineType(types: [[META15:![0-9]+]]) |
| 67 | +// CHECKS: [[META15]] = !{null} |
| 68 | +// CHECKS: [[DBG16]] = !DILocation(line: 51, column: 8, scope: [[DBG13]]) |
| 69 | +// CHECKS: [[DBG17]] = !DILocation(line: 51, column: 13, scope: [[DBG13]]) |
| 70 | +// CHECKS: [[DBG18]] = !DILocation(line: 51, column: 11, scope: [[DBG13]]) |
| 71 | +// CHECKS: [[META19]] = !{} |
| 72 | +// CHECKS: [[PROF20]] = !{!"branch_weights", i32 1048575, i32 1} |
| 73 | +// CHECKS: [[DBG21]] = !DILocation(line: 51, column: 6, scope: [[DBG13]]) |
| 74 | +// CHECKS: [[DBG22]] = !DILocation(line: 52, 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: false, 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: 48, type: [[META14:![0-9]+]], scopeLine: 48, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: [[META2]]) |
| 88 | +// CHECKU: [[META14]] = !DISubroutineType(types: [[META15:![0-9]+]]) |
| 89 | +// CHECKU: [[META15]] = !{null} |
| 90 | +// CHECKU: [[DBG16]] = !DILocation(line: 51, column: 8, scope: [[DBG13]]) |
| 91 | +// CHECKU: [[DBG17]] = !DILocation(line: 51, column: 13, scope: [[DBG13]]) |
| 92 | +// CHECKU: [[DBG18]] = !DILocation(line: 51, column: 11, scope: [[DBG13]]) |
| 93 | +// CHECKU: [[DBG19]] = !DILocation(line: 51, column: 6, scope: [[DBG13]]) |
| 94 | +// CHECKU: [[DBG20]] = !DILocation(line: 52, column: 1, scope: [[DBG13]]) |
| 95 | +//. |
0 commit comments