[PATCH] D149288: [X86] Introduce a large data threshold for the medium code model

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

jyknight added a comment.

`large-data-threshold` is ABI, and needs to have a default value which is the same as GCC, 65535. (And users should be discouraged from changing it.)

In many common cases you can get away with using different values in different object files, because cross-object references are going via PLT/GOT when the compiler doesn't know the definition is in-DSO. But that's definitely not a 100% solution -- e.g. `__attribute__((visibility("hidden")))` or ODR-data defined in a -fPIE object is known to be defined in-DSO, so will use a pc-relative reference.

Comment at: llvm/lib/Target/TargetMachine.cpp:50
+    const DataLayout &DL = GV->getParent()->getDataLayout();
+    return DL.getTypeSizeInBits(GV->getValueType()) / 8 >= LargeDataThreshold;
+  }
W also must handle unknown-sized objects as large here.

E.g. `clang -mcmodel=medium -fPIC` on
__attribute__((visibility("hidden"))) extern int x[];
int bar(void) { return x[0]; }
must refer to x via GOTOFF not pc-relative, because it _could_ be defined as large.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list