[PATCH] D23940: Delete dead code
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 13:03:31 PDT 2016
> On Aug 26, 2016, at 12:51 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>
> On 26 August 2016 at 15:37, Mehdi AMINI <mehdi.amini at apple.com> wrote:
>> mehdi_amini added a comment.
>>
>> We should be able to skip the GOT/PLT for such symbols in the codegen right now, wouldn't we?
>
> They are skipped right now by a combination of visibility and codegen model.
Let me take an example of what I mean:
$ cat foo.cint foo =42;
int bar();int bar2();
int main() {
return bar() + bar2();
}
$ cat bar.c
extern int foo;
int locally_defined = 0;
int bar(){
return foo;
}
int bar2() {
return locally_defined;
}
clang foo.c -c
clang bar.c -c -flto
clang foo.o bar.o
You can see the difference in the codegen for bar and bar2 when I disassemble the binary:
_bar:
100000fa0: 55 pushq %rbp
100000fa1: 48 89 e5 movq %rsp, %rbp
100000fa4: 48 8d 05 55 00 00 00 leaq 85(%rip), %rax
100000fab: 8b 00 movl (%rax), %eax
100000fad: 5d popq %rbp
100000fae: c3 retq
100000faf: 90 nop
_bar2:
100000fb0: 55 pushq %rbp
100000fb1: 48 89 e5 movq %rsp, %rbp
100000fb4: 31 c0 xorl %eax, %eax
100000fb6: 5d popq %rbp
100000fb7: c3 retq
—
Mehdi
More information about the llvm-commits
mailing list