[llvm] [X86] Disallow immediate address calls when position independent (PR #202370)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 01:11:14 PDT 2026


================
@@ -241,7 +241,7 @@ bool X86Subtarget::isLegalToCallImmediateAddr() const {
   // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
   // but WinCOFFObjectWriter::RecordRelocation cannot emit them.  Once it does,
   // the following check for Win32 should be removed.
-  if (Is64Bit || isTargetWin32())
+  if (Is64Bit || isTargetWin32() || isPositionIndependent())
----------------
phoebewang wrote:

No, I think they are basically the same thing.

I did some archeology, it looks like 61da1864 equals what you want to change here. But later, 96098337 excludes for ELF explicitly. I don't see any detailed reasoning, but guess maybe compatibility with GNU tool chain. It's there for about 20 years. I'm worried the change will break existing users.

I was thinking if we can use a different represent to distinguish absolute address against relative address. Then we can do a different lower in `LowerCall` for them.

https://github.com/llvm/llvm-project/pull/202370


More information about the llvm-commits mailing list