[LLVMbugs] [Bug 3148] New: unnecessary GOT lookup when calling visibility hidden or protected function
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Nov 30 20:28:15 PST 2008
http://llvm.org/bugs/show_bug.cgi?id=3148
Summary: unnecessary GOT lookup when calling visibility hidden or
protected function
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Common Code Generator Code
AssignedTo: unassignedbugs at nondot.org
ReportedBy: nicholas at mxc.ca
CC: llvmbugs at cs.uiuc.edu
GCC elides the GOT lookup when calling a hidden or protected function. Here's a
quick, silly example:
class __attribute__((visibility("hidden"))) Foo {
public:
void f(void) __attribute__((noinline)) {
for (int i = 0; i < 1000000; i += 2)
if (i < 123) f();
return;
}
};
void g(void) {
Foo foo;
foo.f();
}
Firstly, if f() is empty, GCC inlines it into g() despite the noinline tag. I
consider that naughty, and we shouldn't follow its lead there.
Secondly, GCC generates this code for g() with -O2 -fPIC:
_Z1gv:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
leal -1(%ebp), %eax
movl %eax, (%esp)
call _ZN3Foo1fEv
leave
ret
while LLVM produces this:
_Z1gv:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $12, %esp
call .Lllvm$1.$piclabel
.Lllvm$1.$piclabel:
popl %ebx
addl $_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$1.$piclabel], %ebx
leal -8(%ebp), %eax
movl %eax, (%esp)
call _ZN3Foo1fEv
addl $12, %esp
popl %ebx
popl %ebp
ret
Because it's hidden, the GOT lookup is unnecessary. Please eliminate it. Same
with protected.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list