diff options
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r-- | llvm/lib/IR/Module.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 49fadc9ed7e6..73354a8f36d2 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -262,7 +262,7 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { if (!NMD) { NMD = new NamedMDNode(Name); NMD->setParent(this); - NamedMDList.push_back(NMD); + insertNamedMDNode(NMD); } return NMD; } @@ -271,7 +271,7 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { /// delete it. void Module::eraseNamedMetadata(NamedMDNode *NMD) { NamedMDSymTab.erase(NMD->getName()); - NamedMDList.erase(NMD->getIterator()); + eraseNamedMDNode(NMD); } bool Module::isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB) { @@ -672,6 +672,18 @@ void Module::setRtLibUseGOT() { addModuleFlag(ModFlagBehavior::Max, "RtLibUseGOT", 1); } +bool Module::getDirectAccessExternalData() const { + auto *Val = cast_or_null<ConstantAsMetadata>( + getModuleFlag("direct-access-external-data")); + if (Val) + return cast<ConstantInt>(Val->getValue())->getZExtValue() > 0; + return getPICLevel() == PICLevel::NotPIC; +} + +void Module::setDirectAccessExternalData(bool Value) { + addModuleFlag(ModFlagBehavior::Max, "direct-access-external-data", Value); +} + UWTableKind Module::getUwtable() const { if (auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("uwtable"))) return UWTableKind(cast<ConstantInt>(Val->getValue())->getZExtValue()); @@ -746,6 +758,13 @@ unsigned Module::getOverrideStackAlignment() const { return 0; } +unsigned Module::getMaxTLSAlignment() const { + Metadata *MD = getModuleFlag("MaxTLSAlign"); + if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD)) + return CI->getZExtValue(); + return 0; +} + void Module::setOverrideStackAlignment(unsigned Align) { addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align); } |