Bjorn Pettersson | 80cb2ce | 2019-10-28 17:34:52 +0100 | [diff] [blame^] | 1 | ; RUN: opt < %s -S -inline | FileCheck %s |
| 2 | ; RUN: opt < %s -S -strip-debug -inline | FileCheck %s |
| 3 | |
| 4 | ; https://bugs.llvm.org/show_bug.cgi?id=43291 |
| 5 | ; The purpose of this test is to check if there is use_empty in the inner loop when scanning |
| 6 | ; blocks of allocas, if the alloca is use_empty, skip it when allocas inlining. |
| 7 | |
| 8 | define void @foo(i16 %k) !dbg !6 { |
| 9 | call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15 |
| 10 | %alloca_a = alloca i32 |
| 11 | call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15 |
| 12 | %alloca_b = alloca [3 x i32] |
| 13 | call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15 |
| 14 | %alloca_c = alloca i32 |
| 15 | call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15 |
| 16 | %alloca_a..1 = bitcast i32* %alloca_a to i8**, !dbg !16 |
| 17 | %alloca_c..1 = bitcast i32* %alloca_c to i8**, !dbg !16 |
| 18 | %_tmp23 = icmp ne i16 %k, 0 |
| 19 | br i1 %_tmp23, label %bb1, label %bb2 |
| 20 | |
| 21 | bb1: ; preds = %0 |
| 22 | %_tmp28 = getelementptr [3 x i32], [3 x i32]* %alloca_b, i16 0, i64 0 |
| 23 | store i32 0, i32* %_tmp28 |
| 24 | br label %bb2 |
| 25 | |
| 26 | bb2: ; preds = %bb1, %0 |
| 27 | ret void |
| 28 | } |
| 29 | |
| 30 | define i16 @bar() !dbg !17 { |
| 31 | ; CHECK-LABEL: bar |
| 32 | ; CHECK: %alloca_a.i = alloca i32 |
| 33 | ; CHECK-NOT: %alloca_b.i = alloca [3 x i32] |
| 34 | ; CHECK: %alloca_c.i = alloca i32 |
| 35 | call void @foo(i16 0), !dbg !20 |
| 36 | br label %bb1 |
| 37 | |
| 38 | bb1: ; preds = %0 |
| 39 | ret i16 0 |
| 40 | } |
| 41 | |
| 42 | ; Function Attrs: nounwind readnone speculatable willreturn |
| 43 | declare void @llvm.dbg.value(metadata, metadata, metadata) #0 |
| 44 | |
| 45 | attributes #0 = { nounwind readnone speculatable willreturn } |
| 46 | |
| 47 | !llvm.dbg.cu = !{!0} |
| 48 | !llvm.module.flags = !{!3, !4} |
| 49 | !llvm.ident = !{!5} |
| 50 | |
| 51 | !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "Foo", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2) |
| 52 | !1 = !DIFile(filename: "foo2.c", directory: "/tmp") |
| 53 | !2 = !{} |
| 54 | !3 = !{i32 2, !"Dwarf Version", i32 4} |
| 55 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
| 56 | !5 = !{!"Foo"} |
| 57 | !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 17, type: !7, scopeLine: 17, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 58 | !7 = !DISubroutineType(types: !8) |
| 59 | !8 = !{!9, !13} |
| 60 | !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", file: !10, line: 76, baseType: !11) |
| 61 | !10 = !DIFile(filename: "stdint.h", directory: "/tmp") |
| 62 | !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "__i64_t", file: !1, baseType: !12) |
| 63 | !12 = !DIBasicType(name: "signed long long", size: 64, encoding: DW_ATE_signed) |
| 64 | !13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) |
| 65 | !14 = !DILocalVariable(name: "k", arg: 1, scope: !6, file: !1, line: 17, type: !13) |
| 66 | !15 = !DILocation(line: 0, scope: !6) |
| 67 | !16 = !DILocation(line: 19, column: 3, scope: !6) |
| 68 | !17 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 8, type: !18, scopeLine: 8, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 69 | !18 = !DISubroutineType(types: !19) |
| 70 | !19 = !{!13} |
| 71 | !20 = !DILocation(line: 8, column: 7, scope: !17) |