1 ; $ clang++ -S -emit-llvm -o - -gdwarf-5 -o - -O1 tail2.cc
3 ; void __attribute__((noinline)) bat() { sink++; }
4 ; void __attribute__((noinline)) bar() { sink++; }
5 ; void __attribute__((noinline)) foo() {
9 ; int __attribute__((disable_tail_calls)) main() { foo(); }
11 ; On Windows, we don't handle the relocations needed for AT_return_pc properly
12 ; and fail with "failed to compute relocation: IMAGE_REL_AMD64_ADDR32".
13 ; UNSUPPORTED: cygwin,windows-gnu,windows-msvc
15 ; REQUIRES: object-emission
16 ; RUN: %llc_dwarf -mtriple=x86_64-- < %s -o - | FileCheck %s -check-prefix=ASM
17 ; RUN: %llc_dwarf -mtriple=x86_64-- < %s -filetype=obj -o %t.o
18 ; RUN: llvm-dwarfdump %t.o -o - | FileCheck %s -check-prefix=OBJ -implicit-check-not=DW_TAG_call_site
19 ; RUN: llvm-dwarfdump -verify %t.o 2>&1 | FileCheck %s -check-prefix=VERIFY
20 ; RUN: llvm-dwarfdump -statistics %t.o | FileCheck %s -check-prefix=STATS
21 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis -o /dev/null
24 ; STATS: "call site entries":5
26 @sink = global i32 0, align 4, !dbg !0
28 ; ASM: DW_TAG_subprogram
29 ; ASM: DW_AT_call_all_calls
30 ; OBJ: [[bat_sp:.*]]: DW_TAG_subprogram
31 ; OBJ: DW_AT_call_all_calls (true)
32 ; OBJ: DW_AT_name ("bat")
33 define void @_Z3batv() !dbg !13 {
35 %0 = load volatile i32, i32* @sink, align 4, !dbg !16, !tbaa !17
36 %inc = add nsw i32 %0, 1, !dbg !16
37 store volatile i32 %inc, i32* @sink, align 4, !dbg !16, !tbaa !17
41 ; ASM: DW_TAG_subprogram
42 ; ASM: DW_AT_call_all_calls
43 ; OBJ: [[bar_sp:.*]]: DW_TAG_subprogram
44 ; OBJ: DW_AT_call_all_calls (true)
45 ; OBJ: DW_AT_name ("bar")
46 define void @_Z3barv() !dbg !22 {
48 %0 = load volatile i32, i32* @sink, align 4, !dbg !23, !tbaa !17
49 %inc = add nsw i32 %0, 1, !dbg !23
50 store volatile i32 %inc, i32* @sink, align 4, !dbg !23, !tbaa !17
54 ; ASM: DW_TAG_subprogram
55 ; ASM: DW_AT_call_all_calls
56 ; OBJ: [[foo_sp:.*]]: DW_TAG_subprogram
57 ; OBJ: DW_AT_call_all_calls (true)
58 ; OBJ: DW_AT_name ("foo")
59 ; OBJ: DW_TAG_call_site
60 ; OBJ: DW_AT_call_origin ([[bar_sp]])
61 ; OBJ: DW_AT_call_return_pc
62 ; OBJ: DW_TAG_call_site
63 ; OBJ: DW_AT_call_origin ([[bat_sp]])
64 ; OBJ: DW_AT_call_return_pc
65 ; OBJ: DW_TAG_call_site
66 ; OBJ: DW_AT_call_origin ([[bar_sp]])
67 ; OBJ: DW_AT_call_return_pc
68 ; OBJ: DW_TAG_call_site
69 ; OBJ: DW_AT_call_origin ([[bat_sp]])
70 ; OBJ: DW_AT_call_tail_call
71 define void @_Z3foov() !dbg !25 {
73 tail call void @_Z3barv(), !dbg !26
74 tail call void @_Z3batv(), !dbg !27
75 tail call void @_Z3barv(), !dbg !26
76 tail call void @_Z3batv(), !dbg !27
80 ; ASM: DW_TAG_subprogram
81 ; ASM: DW_AT_call_all_calls
82 ; OBJ: DW_TAG_subprogram
83 ; OBJ: DW_AT_call_all_calls (true)
84 ; OBJ: DW_AT_name ("main")
85 ; OBJ: DW_TAG_call_site
86 ; OBJ: DW_AT_call_origin ([[foo_sp]])
87 ; OBJ: DW_AT_call_return_pc
88 define i32 @main() !dbg !29 {
90 call void @_Z3foov(), !dbg !32
92 %indirect_target = load void ()*, void ()** undef
93 call void %indirect_target()
95 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
101 !llvm.module.flags = !{!8, !9, !10, !11}
104 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
105 !1 = distinct !DIGlobalVariable(name: "sink", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
106 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
107 !3 = !DIFile(filename: "/Users/vsk/src/llvm.org-tailcall/tail2.cc", directory: "/Users/vsk/src/builds/llvm-project-tailcall-RA", checksumkind: CSK_MD5, checksum: "3b61952c21b7f657ddb7c0ad44cf5529")
110 !6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)
111 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
112 !8 = !{i32 2, !"Dwarf Version", i32 5}
113 !9 = !{i32 2, !"Debug Info Version", i32 3}
114 !10 = !{i32 1, !"wchar_size", i32 4}
115 !11 = !{i32 7, !"PIC Level", i32 2}
116 !12 = !{!"clang version 7.0.0 "}
117 !13 = distinct !DISubprogram(name: "bat", linkageName: "_Z3batv", scope: !3, file: !3, line: 2, type: !14, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, isOptimized: true, unit: !2, retainedNodes: !4)
118 !14 = !DISubroutineType(types: !15)
120 !16 = !DILocation(line: 2, column: 44, scope: !13)
121 !17 = !{!18, !18, i64 0}
122 !18 = !{!"int", !19, i64 0}
123 !19 = !{!"omnipotent char", !20, i64 0}
124 !20 = !{!"Simple C++ TBAA"}
125 !21 = !DILocation(line: 2, column: 48, scope: !13)
126 !22 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !3, file: !3, line: 3, type: !14, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, isOptimized: true, unit: !2, retainedNodes: !4)
127 !23 = !DILocation(line: 3, column: 44, scope: !22)
128 !24 = !DILocation(line: 3, column: 48, scope: !22)
129 !25 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !3, file: !3, line: 4, type: !14, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, isOptimized: true, unit: !2, retainedNodes: !4)
130 !26 = !DILocation(line: 5, column: 3, scope: !25)
131 !27 = !DILocation(line: 6, column: 3, scope: !25)
132 !28 = !DILocation(line: 7, column: 1, scope: !25)
133 !29 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 8, type: !30, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, isOptimized: true, unit: !2, retainedNodes: !4)
134 !30 = !DISubroutineType(types: !31)
136 !32 = !DILocation(line: 8, column: 50, scope: !29)
137 !33 = !DILocation(line: 8, column: 57, scope: !29)