[all-commits] [llvm/llvm-project] ebbc5d: [M68k] Correctly emit non-pic relocations (#89863)
Peter Lafreniere via All-commits
all-commits at lists.llvm.org
Fri May 3 08:15:17 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ebbc5de7db45b2fc81564a6c870a57f4b95d0477
https://github.com/llvm/llvm-project/commit/ebbc5de7db45b2fc81564a6c870a57f4b95d0477
Author: Peter Lafreniere <peter at n8pjl.ca>
Date: 2024-05-03 (Fri, 03 May 2024)
Changed paths:
M llvm/lib/Target/M68k/M68kSubtarget.cpp
M llvm/test/CodeGen/M68k/Arith/divide-by-constant.ll
M llvm/test/CodeGen/M68k/Arith/imul.ll
M llvm/test/CodeGen/M68k/Arith/mul64.ll
M llvm/test/CodeGen/M68k/Arith/sdiv-exact.ll
M llvm/test/CodeGen/M68k/Arith/smul-with-overflow.ll
M llvm/test/CodeGen/M68k/Arith/sub-with-overflow.ll
M llvm/test/CodeGen/M68k/Atomics/cmpxchg.ll
M llvm/test/CodeGen/M68k/Atomics/load-store.ll
M llvm/test/CodeGen/M68k/Atomics/rmw.ll
M llvm/test/CodeGen/M68k/CodeModel/medium-static.ll
M llvm/test/CodeGen/M68k/CodeModel/small-static.ll
M llvm/test/CodeGen/M68k/TLS/tlsie.ll
M llvm/test/CodeGen/M68k/TLS/tlsle.ll
M llvm/test/CodeGen/M68k/gcc_except_table.ll
Log Message:
-----------
[M68k] Correctly emit non-pic relocations (#89863)
The m68k backend will always emit external calls (including libcalls)
with
PC-relative PLT relocations, even when in non-pic mode or -fno-plt is
used.
This is unexpected, as other function calls are emitted with absolute
addressing, and a static code modes suggests that there is no PLT. It
also
leads to a miscompilation where the call instruction emitted expects an
immediate address, while the relocation emitted for that instruction is
PC-relative.
This miscompilation can even be seen in the default C function in
godbolt:
https://godbolt.org/z/zEoazovzo
Fix the issue by classifying external function references based upon the
pic
mode. This triggers a change in the static code model, making it more in
line
with the expected behaviour and allowing use of this backend in more
bare-metal
situations where a PLT does not exist.
The change avoids the issue where we emit a PLT32 relocation for an
absolute
call, and makes libcalls and other external calls use absolute
addressing modes
when a static code model is desired.
Further work should be done in instruction lowering and validation to
ensure
that miscompilations of the same type don't occur.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list