diff options
author | Arthur Eubanks <aeubanks@google.com> | 2023-09-19 16:36:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 16:36:30 -0700 |
commit | 64573da4bf0bc7883e6d4d3debc60daf665d78b8 (patch) | |
tree | c3d636a43e088d4507e60aa24a9dff52f7d7c3d0 /llvm/lib/IR/Module.cpp | |
parent | 96ea48ff5dcba46af350f5300eafd7f7394ba606 (diff) | |
download | llvm-64573da4bf0bc7883e6d4d3debc60daf665d78b8.zip llvm-64573da4bf0bc7883e6d4d3debc60daf665d78b8.tar.gz llvm-64573da4bf0bc7883e6d4d3debc60daf665d78b8.tar.bz2 |
[IR] Add "Large Data Threshold" module metadata (#66797)
This allows us to not have to pass -mllvm flags to set the large data
threshold for (in-LLD/not-distributed) ThinLTO.
Follows https://reviews.llvm.org/D52322, which did the same for the code
model.
Since the large data threshold is tied to the code model and we disallow
mixing different code models, do the same for the large data threshold.
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r-- | llvm/lib/IR/Module.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 5861bbd..dba660b 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -631,6 +631,23 @@ void Module::setCodeModel(CodeModel::Model CL) { addModuleFlag(ModFlagBehavior::Error, "Code Model", CL); } +std::optional<uint64_t> Module::getLargeDataThreshold() const { + auto *Val = + cast_or_null<ConstantAsMetadata>(getModuleFlag("Large Data Threshold")); + + if (!Val) + return std::nullopt; + + return cast<ConstantInt>(Val->getValue())->getZExtValue(); +} + +void Module::setLargeDataThreshold(uint64_t Threshold) { + // Since the large data threshold goes along with the code model, the merge + // behavior is the same. + addModuleFlag(ModFlagBehavior::Error, "Large Data Threshold", + ConstantInt::get(Type::getInt64Ty(Context), Threshold)); +} + void Module::setProfileSummary(Metadata *M, ProfileSummary::Kind Kind) { if (Kind == ProfileSummary::PSK_CSInstr) setModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M); |