[PATCH] D62461: [llvm-objdump] Print source when subsequent lines in the translation unit come from the same line in two different headers.
Mike Pozulp via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 23:47:25 PDT 2019
mmpozulp created this revision.
mmpozulp added reviewers: grimar, rupprecht, jhenderson.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If you have these files
header1.h
int add1(int a) { return a + 1; }
header2.h
int return4() { return 4; }
test.c
#include "header1.h"
#include "header2.h"
and compile them with `clang -g -c test.c -o test.o` and run `llvm-objdump --source test.o`, the source from `header2.h` is missing
0000000000000000 add1:
; int add1(int a) { return a + 1; }
0: 55 pushq %rbp
1: 48 89 e5 movq %rsp, %rbp
4: 89 7d fc movl %edi, -4(%rbp)
7: 8b 45 fc movl -4(%rbp), %eax
a: 83 c0 01 addl $1, %eax
d: 5d popq %rbp
e: c3 retq
f: 90 nop
0000000000000010 return4:
10: 55 pushq %rbp
11: 48 89 e5 movq %rsp, %rbp
14: b8 04 00 00 00 movl $4, %eax
19: 5d popq %rbp
1a: c3 retq
This patch fixes this problem, interleaving the source from `header2.h`
0000000000000000 add1:
; int add1(int a) { return a + 1; }
0: 55 pushq %rbp
1: 48 89 e5 movq %rsp, %rbp
4: 89 7d fc movl %edi, -4(%rbp)
7: 8b 45 fc movl -4(%rbp), %eax
a: 83 c0 01 addl $1, %eax
d: 5d popq %rbp
e: c3 retq
f: 90 nop
0000000000000010 return4:
; int return4() { return 4; }
10: 55 pushq %rbp
11: 48 89 e5 movq %rsp, %rbp
14: b8 04 00 00 00 movl $4, %eax
19: 5d popq %rbp
1a: c3 retq
FYI I noticed this bug while working on a different patch requested by @jhenderson (https://bugs.llvm.org/show_bug.cgi?id=41905).
Repository:
rL LLVM
https://reviews.llvm.org/D62461
Files:
llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-header1.h
llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-header2.h
llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-same-line-different-file.c
llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-same-line-different-file.ll
llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
llvm/test/tools/llvm-objdump/X86/source-interleave-same-line-different-file.test
llvm/tools/llvm-objdump/llvm-objdump.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62461.201436.patch
Type: text/x-patch
Size: 6676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190526/8c08be6f/attachment.bin>
More information about the llvm-commits
mailing list