1 ;; Verify that llvm-objdump -l also prints the function name in disassembly
2 ;; output, getting it from the debug info.
4 ; RUN: llc < %s -o %t.o -filetype=obj -mtriple=x86_64-unknown-linux-gnu
5 ; RUN: llvm-objdump --no-print-imm-hex -dl %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-NO-DEMANGLE
7 ; RUN: llc < %s -o %t.o -filetype=obj -mtriple=x86_64-unknown-linux-gnu
8 ; RUN: llvm-objdump --no-print-imm-hex -dlC %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DEMANGLE
10 ; CHECK: 0000000000000000 <foo>:
11 ; CHECK-NEXT: ; foo():
12 ; CHECK-NEXT: ; /tmp{{/|\\}}src.cc:1
13 ; CHECK-NEXT: 0: b8 05 00 00 00 movl $5, %eax
14 ; CHECK-NEXT: 5: c3 retq
16 ; CHECK-NO-DEMANGLE: 0000000000000010 <_ZN3xyz3barEv>:
17 ; CHECK-NO-DEMANGLE-NEXT: ; _ZN3xyz3barEv():
18 ; CHECK-DEMANGLE: 0000000000000010 <xyz::bar()>:
19 ; CHECK-DEMANGLE-NEXT: ; xyz::bar():
21 ; CHECK-NEXT: ; /tmp{{/|\\}}src.cc:3
22 ; CHECK-NEXT: 10: b8 0a 00 00 00 movl $10, %eax
23 ; CHECK-NEXT: 15: c3 retq
25 ; CHECK-NO-DEMANGLE: 0000000000000020 <_ZN3xyz3bazEv>:
26 ; CHECK-NO-DEMANGLE-NEXT: ; _ZN3xyz3bazEv():
27 ; CHECK-DEMANGLE: 0000000000000020 <xyz::baz()>:
28 ; CHECK-DEMANGLE-NEXT: ; xyz::baz():
30 ; CHECK-NEXT: ; /tmp{{/|\\}}src.cc:3
31 ; CHECK-NEXT: 20: b8 14 00 00 00 movl $20, %eax
32 ; CHECK-NEXT: 25: c3 retq
34 ;; When symbol information is missing, we can get function names from debug
35 ;; info. The IR is intentionally doctored to have different names in debug info
36 ;; for the test case here.
37 ; RUN: llvm-strip %t.o -N foo -N _ZN3xyz3barEv -N _ZN3xyz3bazEv -o %t-stripped.o
38 ; RUN: llvm-objdump --no-print-imm-hex -dlC %t-stripped.o | FileCheck %s --check-prefix=STRIPPED
40 ; STRIPPED: 0000000000000000 <.text>:
41 ; STRIPPED-NEXT: ; Function1():
42 ; STRIPPED-NEXT: ; /tmp{{/|\\}}src.cc:1
43 ; STRIPPED-NEXT: 0: b8 05 00 00 00 movl $5, %eax
44 ; STRIPPED-NEXT: 5: c3 retq
46 ; STRIPPED: ; xyz::bar():
47 ; STRIPPED-NEXT: ; /tmp{{/|\\}}src.cc:3
48 ; STRIPPED-NEXT: 10: b8 0a 00 00 00 movl $10, %eax
49 ; STRIPPED-NEXT: 15: c3 retq
51 ; STRIPPED: ; xyz::baz():
52 ; STRIPPED-NEXT: ; /tmp{{/|\\}}src.cc:3
53 ; STRIPPED-NEXT: 20: b8 14 00 00 00 movl $20, %eax
54 ; STRIPPED-NEXT: 25: c3 retq
58 ;; extern "C" int foo() { return 5; };
60 ;; int bar() { return 10; } int baz() { return 20; }
62 ;; $ clang++ -O -g -c /tmp/src.cc -S -emit-llvm
63 ;; Note: bar() and baz() intentionally written on the same line.
65 ; ModuleID = '/tmp/src.cc'
66 source_filename = "/tmp/src.cc"
67 target triple = "x86_64-unknown-linux-gnu"
69 define dso_local i32 @foo() #0 !dbg !7 {
74 define dso_local i32 @_ZN3xyz3barEv() #0 !dbg !13 {
79 define dso_local i32 @_ZN3xyz3bazEv() #0 !dbg !16 {
84 attributes #0 = { "frame-pointer"="none" }
87 !llvm.module.flags = !{!3, !4, !5}
90 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
91 ; Note: <invalid> triggers a bad DILineInfo. We still print "Function1()".
92 !1 = !DIFile(filename: "<invalid>", directory: "")
94 !3 = !{i32 7, !"Dwarf Version", i32 4}
95 !4 = !{i32 2, !"Debug Info Version", i32 3}
96 !5 = !{i32 1, !"wchar_size", i32 4}
97 !6 = !{!"clang trunk)"}
98 !7 = distinct !DISubprogram(name: "Function1", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
99 !8 = !DIFile(filename: "/tmp/src.cc", directory: "")
100 !9 = !DISubroutineType(types: !10)
102 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
103 !12 = !DILocation(line: 1, column: 24, scope: !7)
104 !13 = distinct !DISubprogram(name: "bar", linkageName: "_ZN3xyz3barEv", scope: !14, file: !8, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
105 !14 = !DINamespace(name: "xyz", scope: null)
106 !15 = !DILocation(line: 3, column: 13, scope: !13)
107 !16 = distinct !DISubprogram(name: "baz", linkageName: "_ZN3xyz3bazEv", scope: !14, file: !8, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
108 !17 = !DILocation(line: 3, column: 38, scope: !16)