xref: /llvm-project/llvm/test/DebugInfo/X86/fake-use.ll (revision 822f74a91106b7ca10e85508eb642e62ef945afa)
1; REQUIRES: object-emission
2
3; Make sure the fake use of 'b' at the end of 'foo' causes location information for 'b'
4; to extend all the way to the end of the function.
5
6; RUN: %llc_dwarf -O2 -filetype=obj -mtriple=x86_64-unknown-linux -dwarf-linkage-names=Abstract < %s | llvm-dwarfdump --debug-info --debug-line -v - -o %t
7; RUN: %python %p/../Inputs/check-fake-use.py %t
8; RUN: sed -e 's,call void (...) @llvm.fake.use,;,' %s | %llc_dwarf - -O2 -filetype=obj -mtriple=x86_64-unknown-linux -dwarf-linkage-names=Abstract | llvm-dwarfdump --debug-info --debug-line -v - -o %t
9; RUN: not %python %p/../Inputs/check-fake-use.py %t
10
11; Generated with:
12; clang -O2 -g -S -emit-llvm -fextend-variable-liveness=this fake-use.c
13;
14; int glob[10];
15; extern void bar();
16;
17; int foo(int b, int i)
18; {
19;    int loc = glob[i] * 2;
20;    if (b) {
21;      glob[2] = loc;
22;      bar();
23;    }
24;    return loc;
25; }
26;
27; ModuleID = 't2.c'
28source_filename = "t2.c"
29
30@glob = common local_unnamed_addr global [10 x i32] zeroinitializer, align 16, !dbg !0
31
32; Function Attrs: nounwind sspstrong uwtable
33define i32 @foo(i32 %b, i32 %i) local_unnamed_addr optdebug !dbg !13 {
34entry:
35    #dbg_value(i32 %b, !17, !20, !21)
36  %c = add i32 %b, 42
37  %tobool = icmp sgt i32 %c, 2, !dbg !27
38  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"()
39  tail call void (...) @bar() #2, !dbg !32
40  %idxprom = sext i32 %i to i64, !dbg !22
41  %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* @glob, i64 0, i64 %idxprom, !dbg !22
42  %0 = load i32, i32* %arrayidx, align 4, !dbg !22, !tbaa !23
43  %mul = shl nsw i32 %0, 1, !dbg !22
44  br i1 %tobool, label %if.end, label %if.then, !dbg !29
45
46if.then:                                          ; preds = %entry
47  store i32 %mul, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @glob, i64 0, i64 2), align 8, !dbg !30, !tbaa !23
48  tail call void (...) @bar() #2, !dbg !32
49  br label %if.end, !dbg !33
50
51if.end:                                           ; preds = %entry, %if.then
52  call void (...) @llvm.fake.use(i32 %b), !dbg !34
53  ret i32 %mul, !dbg !35
54}
55
56declare void @bar(...) local_unnamed_addr
57
58!llvm.dbg.cu = !{!1}
59!llvm.module.flags = !{!9, !10, !11}
60!llvm.ident = !{!12}
61
62!0 = distinct !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "glob", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true), expr: !DIExpression())
63!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 4.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)
64!2 = !DIFile(filename: "t2.c", directory: "/")
65!3 = !{}
66!4 = !{!0}
67!5 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 320, align: 32, elements: !7)
68!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
69!7 = !{!8}
70!8 = !DISubrange(count: 10)
71!9 = !{i32 2, !"Dwarf Version", i32 4}
72!10 = !{i32 2, !"Debug Info Version", i32 3}
73!11 = !{i32 1, !"PIC Level", i32 2}
74!12 = !{!"clang version 4.0.0"}
75!13 = distinct !DISubprogram(name: "foo", scope: !2, file: !2, line: 4, type: !14, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !1, retainedNodes: !16)
76!14 = !DISubroutineType(types: !15)
77!15 = !{!6, !6, !6}
78!16 = !{!17, !19}
79!17 = !DILocalVariable(name: "b", arg: 1, scope: !13, file: !2, line: 4, type: !6)
80!19 = !DILocalVariable(name: "loc", scope: !13, file: !2, line: 6, type: !6)
81!20 = !DIExpression()
82!21 = !DILocation(line: 4, scope: !13)
83!22 = !DILocation(line: 6, scope: !13)
84!23 = !{!24, !24, i64 0}
85!24 = !{!"int", !25, i64 0}
86!25 = !{!"omnipotent char", !26, i64 0}
87!26 = !{!"Simple C/C++ TBAA"}
88!27 = !DILocation(line: 7, scope: !28)
89!28 = distinct !DILexicalBlock(scope: !13, file: !2, line: 7)
90!29 = !DILocation(line: 7, scope: !13)
91!30 = !DILocation(line: 8, scope: !31)
92!31 = distinct !DILexicalBlock(scope: !28, file: !2, line: 7)
93!32 = !DILocation(line: 9, scope: !31)
94!33 = !DILocation(line: 10, scope: !31)
95!34 = !DILocation(line: 12, scope: !13)
96!35 = !DILocation(line: 11, scope: !13)
97