Changeset View
Standalone View
llvm/test/tools/llvm-objdump/X86/source-interleave-function-from-debug.test
- This file was added.
;; Verify that llvm-objdump -l also prints the function name in disassembly | |||||
;; output, getting it from the debug info. | |||||
; RUN: llc < %s -o %t.o -filetype=obj -mtriple=x86_64-pc-linux | |||||
; RUN: llvm-objdump -d -l -C %t.o | FileCheck %s | |||||
dblaikie: Clearly there's prior art here, but testing objdump with llc seems a bit heavyweight/circular… | |||||
Not entirely circular: it's only the llc tests that depend on llvm-objdump and llvm-objdump tests that depend on llc. The tools themselves don't have a circular dep.
The reason I went w/ IR is for the relatively straightforward debug annotations, e.g. run "clang++ -S -emit-llvm" on a toy cc file and manipulate it as needed. That doesn't seem to be feasible w/ raw assembly: the dwarf information gets encoded as raw bytes. I think this is a lot more readable, unless there's some other way to represent debug info in assembly? rupprecht: > Clearly there's prior art here, but testing objdump with llc seems a bit heavyweight/circular… | |||||
I prefer an IR test for this case. The result is known to be stable and cannot affect people who work on CodeGen (test/CodeGen). "frame-pointer"="none" can make the emitted instructions even simpler. MaskRay: I prefer an IR test for this case. The result is known to be stable and cannot affect people… | |||||
; RUN: llvm-strip %t.o -N foo -N _ZN3xyz3barEv -o %t-stripped.o | |||||
; RUN: llvm-objdump -d -l -C %t-stripped.o | FileCheck %s --check-prefix=STRIPPED | |||||
; CHECK: 0000000000000000 foo: | |||||
; CHECK-NEXT: ; foo(): | |||||
; CHECK-NEXT: 0: b8 05 00 00 00 movl $5, %eax | |||||
; CHECK: 0000000000000010 xyz::bar(): | |||||
; CHECK-NEXT: ; _ZN3xyz3barEv(): | |||||
; CHECK-NEXT: ; /tmp/foo.c:2 | |||||
; CHECK-NEXT: 10: b8 0a 00 00 00 movl $10, %eax | |||||
; STRIPPED: 0000000000000000 .text: | |||||
; STRIPPED-NEXT: ; Function1(): | |||||
; STRIPPED-NEXT: 0: b8 05 00 00 00 movl $5, %eax | |||||
; STRIPPED: ; _ZN3xyz3barEv(): | |||||
; STRIPPED-NEXT: ; /tmp/foo.c:2 | |||||
Not Done ReplyInline ActionsWith "frame-pointer"="none", there will be even more NOPs. Consider CHECK-COUNT-10: nop or just omit NOPs. MaskRay: With `"frame-pointer"="none"`, there will be even more NOPs. Consider `CHECK-COUNT-10: nop` or… | |||||
; STRIPPED-NEXT: 10: b8 0a 00 00 00 movl $10, %eax | |||||
;; IR adapted from: | |||||
;; extern "C" int foo() { return 5; }; | |||||
;; namespace xyz { | |||||
;; int bar() { return 10; } | |||||
;; } // namespace xyz | |||||
; ModuleID = '/tmp/foo.c' | |||||
source_filename = "/tmp/foo.c" | |||||
target triple = "x86_64-unknown-linux-gnu" | |||||
define dso_local i32 @foo() !dbg !7 { | |||||
ret i32 5, !dbg !12 | |||||
} | |||||
define dso_local i32 @_ZN3xyz3barEv() !dbg !13 { | |||||
ret i32 10, !dbg !14 | |||||
} | |||||
!llvm.dbg.cu = !{!0} | |||||
!llvm.module.flags = !{!3, !4} | |||||
!llvm.ident = !{!6} | |||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) | |||||
; Note: <invalid> triggers a bad DILineInfo. We still print "Function1()". | |||||
!1 = !DIFile(filename: "<invalid>", directory: "") | |||||
!2 = !{} | |||||
!3 = !{i32 7, !"Dwarf Version", i32 4} | |||||
!4 = !{i32 2, !"Debug Info Version", i32 3} | |||||
!6 = !{!"clang trunk"} | |||||
!7 = distinct !DISubprogram(name: "Function1", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) | |||||
!8 = !DIFile(filename: "foo.c", directory: "/tmp") | |||||
!9 = !DISubroutineType(types: !10) | |||||
!10 = !{!11} | |||||
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | |||||
!12 = !DILocation(line: 1, column: 13, scope: !7) | |||||
!13 = distinct !DISubprogram(name: "_ZN3xyz3barEv", scope: !8, file: !8, line: 2, type: !9, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) | |||||
!14 = !DILocation(line: 2, column: 13, scope: !13) | |||||
Not Done ReplyInline ActionsAdd -O on the clang command line. "frame-pointer"="none" is the default behavior of -O* on Linux x86-64. (Yeah, the frame pointer decision is OS/Arch dependent...A mess) MaskRay: Add `-O` on the clang command line.
`"frame-pointer"="none"` is the default behavior of `-O*`… |
Clearly there's prior art here, but testing objdump with llc seems a bit heavyweight/circular (no doubt some llc tests use llvm-objdump to verify their result) - I'd expect this to use raw assembly + llvm-mc at most.
not a requirement for change, just a thought