[PATCH] D150297: [X86] Use RIP-relative addressing for data under large data threshold for medium code model

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 10:21:57 PDT 2023


jyknight added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:20828
   // since they must be within 2GiB. This is also possible in non-PIC mode, and
   // shorter than the 64-bit absolute immediate that would otherwise be emitted.
+  // For PIC global variables, MO_NO_FLAG also means it can be referenced
----------------
This function is getting kinda complex. And given we already have classifyLocalReference/classifyGlobalReference and friends, why does this function even need to look at GV and the CodeModel at all? That kinda feels wrong...Shouldn't it be entirely based on the OpFlags?

That is, I'm kinda wondering why this function isn't, in its entirety just

```
  if (Subtarget.isPICStyleRIPRel() && OpFlags == X86II::MO_NO_FLAG)
    return X86ISD::WrapperRIP;

  if (OpFlags == X86II::MO_GOTPCREL || OpFlags == X86II::MO_GOTPCREL_NORELAX)
    return X86ISD::WrapperRIP;

  return X86ISD::Wrapper;
```

Or do we actually emit references that are neither GOT nor pc-relative in PIC mode in some circumstances? (Which would, then, imply text relocations...which seems wrong...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150297/new/

https://reviews.llvm.org/D150297



More information about the llvm-commits mailing list