1 ; RUN: opt < %s -S -passes=inline | FileCheck %s
2 ; RUN: opt < %s -S -strip-debug -passes=inline | FileCheck %s
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.
8 declare void @use(ptr )
10 define void @foo(i16 %k) !dbg !6 {
11 call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15
12 %alloca_a = alloca i32
13 call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15
14 %alloca_b = alloca [3 x i32]
15 call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15
16 %alloca_c = alloca i32
17 call void @llvm.dbg.value(metadata i16 %k, metadata !14, metadata !DIExpression()), !dbg !15
18 call void @use(ptr %alloca_a), !dbg !16
19 call void @use(ptr %alloca_c), !dbg !16
20 %_tmp23 = icmp ne i16 %k, 0
21 br i1 %_tmp23, label %bb1, label %bb2
24 store i32 0, ptr %alloca_b
27 bb2: ; preds = %bb1, %0
31 define i16 @bar() !dbg !17 {
33 ; CHECK: %alloca_a.i = alloca i32
34 ; CHECK-NOT: %alloca_b.i = alloca [3 x i32]
35 ; CHECK: %alloca_c.i = alloca i32
36 call void @foo(i16 0), !dbg !20
43 ; Function Attrs: nounwind readnone speculatable willreturn
44 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
46 attributes #0 = { nounwind readnone speculatable willreturn }
49 !llvm.module.flags = !{!3, !4}
52 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "Foo", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2)
53 !1 = !DIFile(filename: "foo2.c", directory: "/tmp")
55 !3 = !{i32 2, !"Dwarf Version", i32 4}
56 !4 = !{i32 2, !"Debug Info Version", i32 3}
58 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 17, type: !7, scopeLine: 17, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
59 !7 = !DISubroutineType(types: !8)
61 !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", file: !10, line: 76, baseType: !11)
62 !10 = !DIFile(filename: "stdint.h", directory: "/tmp")
63 !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "__i64_t", file: !1, baseType: !12)
64 !12 = !DIBasicType(name: "signed long long", size: 64, encoding: DW_ATE_signed)
65 !13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
66 !14 = !DILocalVariable(name: "k", arg: 1, scope: !6, file: !1, line: 17, type: !13)
67 !15 = !DILocation(line: 0, scope: !6)
68 !16 = !DILocation(line: 19, column: 3, scope: !6)
69 !17 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 8, type: !18, scopeLine: 8, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
70 !18 = !DISubroutineType(types: !19)
72 !20 = !DILocation(line: 8, column: 7, scope: !17)