[llvm] [M68k] implement -mxgot (PR #119803)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 10 23:20:48 PDT 2025
================
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
+; RUN: llc -mtriple=m68k --show-mc-encoding -mattr=+xgot -relocation-model=pic -code-model=large < %s | FileCheck %s
+
+ at VBRTag = external global [2147483647 x i8]
+
+define i1 @folded_offset(i32 %conv29) {
+; CHECK-LABEL: folded_offset:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %entry
+; CHECK-NEXT: lea (0,%pc), %a0 ; encoding: [0x41,0xfa,0x00,0x00]
+; CHECK-NEXT: lea _GLOBAL_OFFSET_TABLE_, %a1 ; encoding: [0x43,0xf9,A,A,A,A]
+; CHECK-NEXT: ; fixup A - offset: 2, value: _GLOBAL_OFFSET_TABLE_, kind: FK_Data_4
+; CHECK-NEXT: suba.l %a0, %a1 ; encoding: [0x93,0xc8]
+; CHECK-NEXT: move.l #VBRTag at GOTOFF, %d0 ; encoding: [0x20,0x3c,A,A,A,A]
+; CHECK-NEXT: ; fixup A - offset: 2, value: VBRTag at GOTOFF, kind: FK_Data_4
+; CHECK-NEXT: move.b (1,%a1,%d0), %d0 ; encoding: [0x10,0x31,0x08,0x01]
----------------
mshockwave wrote:
I think there are two problems here: (1) `%a1` tries to compute the "pc-relative" offset of the GOT -- but the _PC_ was from several instructions before (pointed at `lea _GLOBAL_OFFSET_TABLE_, %a1`), rather than this instruction, so we need to add another offset to compensate the difference (2) Assuming we have the correct `%a1` value, I don't think `(1,%a1,%d0)` here is correct: what we really want is `%a1 + pc + %d0 + 1`, which should probably use Program Counter Memory Indirect Postindexed addressing mode, or the "x" addressing mode. But sadly we haven't implemented that one yet
https://github.com/llvm/llvm-project/pull/119803
More information about the llvm-commits
mailing list