aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2023-05-10 13:13:58 -0700
committerArthur Eubanks <aeubanks@google.com>2023-09-14 15:09:25 -0700
commit1feb00a28c9fdab162da08a15fcc9d088a36c352 (patch)
treeeed42abf6312a0198a76d4e5df95c25f481aa496 /llvm/lib/Target/TargetMachine.cpp
parent5093413a5007b017a530edbeed42d32bfd18b126 (diff)
downloadllvm-1feb00a28c9fdab162da08a15fcc9d088a36c352.zip
llvm-1feb00a28c9fdab162da08a15fcc9d088a36c352.tar.gz
llvm-1feb00a28c9fdab162da08a15fcc9d088a36c352.tar.bz2
[X86] Introduce a large data threshold for the medium code model
Currently clang's medium code model treats all data as large, putting them in a large data section and using more expensive instruction sequences to access them. Following gcc's -mlarge-data-threshold, which allows putting data under a certain size in a normal data section as opposed to a large data section. This allows using cheaper code sequences to access some portion of data in the binary (which will be implemented in LLVM in a future patch). And under the medium codel mode, only put data above the large data threshold into large data sections, not all data. Reviewed By: MaskRay, rnk Differential Revision: https://reviews.llvm.org/D149288
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/TargetMachine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 0b4a251..2119167 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -39,14 +39,16 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
TargetMachine::~TargetMachine() = default;
-bool TargetMachine::isLargeData() const {
+bool TargetMachine::isLargeData(const GlobalVariable *GV) const {
if (getTargetTriple().getArch() != Triple::x86_64)
return false;
// Large data under the large code model still needs to be thought about, so
// restrict this to medium.
if (getCodeModel() != CodeModel::Medium)
return false;
- return true;
+ const DataLayout &DL = GV->getParent()->getDataLayout();
+ uint64_t Size = DL.getTypeSizeInBits(GV->getValueType()) / 8;
+ return Size == 0 || Size > LargeDataThreshold;
}
bool TargetMachine::isPositionIndependent() const {