[llvm-bugs] [Bug 52181] New: Incorrect code generation when using regcall with -fPIC
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Oct 14 10:45:32 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52181
Bug ID: 52181
Summary: Incorrect code generation when using regcall with
-fPIC
Product: clang
Version: 12.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: jakedelmastro at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
So I have a simple example here for x86 (-m32) where a regular cdecl function
is trying to call a function using the regcall convention.
__attribute__((regcall)) void bar();
void foo()
{
bar();
}
When this is compiled with -fPIC, the required loading of ebx table offsets by
the caller is incorrectly omitted.
foo(): # @foo()
push ebp
mov ebp, esp
sub esp, 8
call __regcall3__bar()@PLT
add esp, 8
pop ebp
ret
arguments are -m32 -fPIC -target i386-linux-elf, this happens in both C & C++
when the same code is compiled in GCC 13 we get correct code:
foo():
push ebp
mov ebp, esp
push ebx
sub esp, 4
call __x86.get_pc_thunk.ax
add eax, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_
mov ebx, eax
call bar()@PLT
nop
mov ebx, DWORD PTR -4[ebp]
leave
ret
__x86.get_pc_thunk.ax:
mov eax, DWORD PTR [esp]
ret
note the loading of ebx with the offset of the GOT
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211014/ac67a3ce/attachment.html>
More information about the llvm-bugs
mailing list