From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/lib/IR/Module.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'llvm/lib/IR/Module.cpp') diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index b51ea45f651a..49fadc9ed7e6 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -12,7 +12,6 @@ #include "llvm/IR/Module.h" #include "SymbolTableListTraitsImpl.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" @@ -49,6 +48,7 @@ #include #include #include +#include #include #include @@ -596,7 +596,9 @@ PICLevel::Level Module::getPICLevel() const { } void Module::setPICLevel(PICLevel::Level PL) { - addModuleFlag(ModFlagBehavior::Max, "PIC Level", PL); + // The merge result of a non-PIC object and a PIC object can only be reliably + // used as a non-PIC object, so use the Min merge behavior. + addModuleFlag(ModFlagBehavior::Min, "PIC Level", PL); } PIELevel::Level Module::getPIELevel() const { @@ -613,11 +615,11 @@ void Module::setPIELevel(PIELevel::Level PL) { addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL); } -Optional Module::getCodeModel() const { +std::optional Module::getCodeModel() const { auto *Val = cast_or_null(getModuleFlag("Code Model")); if (!Val) - return None; + return std::nullopt; return static_cast( cast(Val->getValue())->getZExtValue()); @@ -773,9 +775,9 @@ static VersionTuple getSDKVersionMD(Metadata *MD) { auto *Arr = dyn_cast_or_null(CM->getValue()); if (!Arr) return {}; - auto getVersionComponent = [&](unsigned Index) -> Optional { + auto getVersionComponent = [&](unsigned Index) -> std::optional { if (Index >= Arr->getNumElements()) - return None; + return std::nullopt; return (unsigned)Arr->getElementAsInteger(Index); }; auto Major = getVersionComponent(0); -- cgit v1.2.3