forked from OSchip/llvm-project
[llvm] Use Optional::getValueOr (NFC)
This commit is contained in:
parent
2c2d489b78
commit
8a20e2b3d3
|
@ -100,8 +100,7 @@ llvm::Optional<llvm::InlineCost> static getDefaultInlineAdvice(
|
||||||
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
|
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
|
||||||
};
|
};
|
||||||
return llvm::shouldInline(CB, GetInlineCost, ORE,
|
return llvm::shouldInline(CB, GetInlineCost, ORE,
|
||||||
Params.EnableDeferral.hasValue() &&
|
Params.EnableDeferral.getValueOr(false));
|
||||||
Params.EnableDeferral.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
|
std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static Reloc::Model getRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::Static);
|
||||||
return Reloc::Static;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ARCTargetMachine ctor - Create an ILP32 architecture model
|
/// ARCTargetMachine ctor - Create an ILP32 architecture model
|
||||||
|
|
|
@ -37,7 +37,7 @@ static StringRef getCPU(StringRef CPU) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
return RM.hasValue() ? *RM : Reloc::Static;
|
return RM.getValueOr(Reloc::Static);
|
||||||
}
|
}
|
||||||
|
|
||||||
AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,
|
AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,
|
||||||
|
|
|
@ -57,9 +57,7 @@ static std::string computeDataLayout(const Triple &TT) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::PIC_);
|
||||||
return Reloc::PIC_;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
|
BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
|
||||||
|
|
|
@ -44,7 +44,7 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT,
|
||||||
Optional<CodeModel::Model> CM,
|
Optional<CodeModel::Model> CM,
|
||||||
CodeGenOpt::Level OL, bool JIT)
|
CodeGenOpt::Level OL, bool JIT)
|
||||||
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
|
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
|
||||||
!RM.hasValue() ? Reloc::Static : *RM,
|
RM.getValueOr(Reloc::Static),
|
||||||
getEffectiveCodeModel(CM, CodeModel::Small), OL),
|
getEffectiveCodeModel(CM, CodeModel::Small), OL),
|
||||||
TLOF(std::make_unique<TargetLoweringObjectFileELF>()) {
|
TLOF(std::make_unique<TargetLoweringObjectFileELF>()) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
|
|
|
@ -187,9 +187,7 @@ namespace llvm {
|
||||||
} // end namespace llvm;
|
} // end namespace llvm;
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::Static);
|
||||||
return Reloc::Static;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() {
|
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() {
|
||||||
|
|
|
@ -48,9 +48,7 @@ static std::string computeDataLayout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::PIC_);
|
||||||
return Reloc::PIC_;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT,
|
LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT,
|
||||||
|
|
|
@ -55,9 +55,7 @@ static std::string computeDataLayout(const Triple &T, bool is64Bit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::Static);
|
||||||
return Reloc::Static;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code models. Some only make sense for 64-bit code.
|
// Code models. Some only make sense for 64-bit code.
|
||||||
|
|
|
@ -61,9 +61,7 @@ static std::string computeDataLayout(const Triple &T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::Static);
|
||||||
return Reloc::Static;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VEELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
class VEELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
||||||
|
|
|
@ -26,9 +26,7 @@
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
||||||
if (!RM.hasValue())
|
return RM.getValueOr(Reloc::Static);
|
||||||
return Reloc::Static;
|
|
||||||
return *RM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CodeModel::Model
|
static CodeModel::Model
|
||||||
|
|
|
@ -1568,8 +1568,7 @@ static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap,
|
||||||
return;
|
return;
|
||||||
auto CallSiteCount = PSI ? PSI->getProfileCount(TheCall, CallerBFI) : None;
|
auto CallSiteCount = PSI ? PSI->getProfileCount(TheCall, CallerBFI) : None;
|
||||||
int64_t CallCount =
|
int64_t CallCount =
|
||||||
std::min(CallSiteCount.hasValue() ? CallSiteCount.getValue() : 0,
|
std::min(CallSiteCount.getValueOr(0), CalleeEntryCount.getCount());
|
||||||
CalleeEntryCount.getCount());
|
|
||||||
updateProfileCallee(Callee, -CallCount, &VMap);
|
updateProfileCallee(Callee, -CallCount, &VMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,8 +310,7 @@ llvm::getOptionalElementCountLoopAttribute(Loop *TheLoop) {
|
||||||
if (Width.hasValue()) {
|
if (Width.hasValue()) {
|
||||||
Optional<int> IsScalable = getOptionalIntLoopAttribute(
|
Optional<int> IsScalable = getOptionalIntLoopAttribute(
|
||||||
TheLoop, "llvm.loop.vectorize.scalable.enable");
|
TheLoop, "llvm.loop.vectorize.scalable.enable");
|
||||||
return ElementCount::get(*Width,
|
return ElementCount::get(*Width, IsScalable.getValueOr(false));
|
||||||
IsScalable.hasValue() ? *IsScalable : false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -453,9 +453,8 @@ public:
|
||||||
MatchTableRecord(Optional<unsigned> LabelID_, StringRef EmitStr,
|
MatchTableRecord(Optional<unsigned> LabelID_, StringRef EmitStr,
|
||||||
unsigned NumElements, unsigned Flags,
|
unsigned NumElements, unsigned Flags,
|
||||||
int64_t RawValue = std::numeric_limits<int64_t>::min())
|
int64_t RawValue = std::numeric_limits<int64_t>::min())
|
||||||
: LabelID(LabelID_.hasValue() ? LabelID_.getValue() : ~0u),
|
: LabelID(LabelID_.getValueOr(~0u)), EmitStr(EmitStr),
|
||||||
EmitStr(EmitStr), NumElements(NumElements), Flags(Flags),
|
NumElements(NumElements), Flags(Flags), RawValue(RawValue) {
|
||||||
RawValue(RawValue) {
|
|
||||||
assert((!LabelID_.hasValue() || LabelID != ~0u) &&
|
assert((!LabelID_.hasValue() || LabelID != ~0u) &&
|
||||||
"This value is reserved for non-labels");
|
"This value is reserved for non-labels");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue