Instructions: convert Optional to std::optional
This commit is contained in:
parent
e33243c950
commit
f3b6dbfda8
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
|
@ -2031,7 +2030,7 @@ public:
|
|||
///
|
||||
/// It is an error to call this for operand bundle types that may have
|
||||
/// multiple instances of them on the same instruction.
|
||||
Optional<OperandBundleUse> getOperandBundle(uint32_t ID) const {
|
||||
std::optional<OperandBundleUse> getOperandBundle(uint32_t ID) const {
|
||||
assert(countOperandBundlesOfType(ID) < 2 && "Precondition violated!");
|
||||
|
||||
for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
|
||||
/// Get allocation size in bits. Returns None if size can't be determined,
|
||||
/// e.g. in case of a VLA.
|
||||
Optional<TypeSize> getAllocationSizeInBits(const DataLayout &DL) const;
|
||||
std::optional<TypeSize> getAllocationSizeInBits(const DataLayout &DL) const;
|
||||
|
||||
/// Return the type that is being allocated by the instruction.
|
||||
Type *getAllocatedType() const { return AllocatedType; }
|
||||
|
|
|
@ -482,8 +482,9 @@ public:
|
|||
Type *ReturnType,
|
||||
ArrayRef<Value *> Params);
|
||||
|
||||
static Optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
|
||||
static Optional<unsigned> getVectorLengthParamPos(Intrinsic::ID IntrinsicID);
|
||||
static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
|
||||
static std::optional<unsigned> getVectorLengthParamPos(
|
||||
Intrinsic::ID IntrinsicID);
|
||||
|
||||
/// The llvm.vp.* intrinsics for this instruction Opcode
|
||||
static Intrinsic::ID getForOpcode(unsigned OC);
|
||||
|
@ -513,11 +514,11 @@ public:
|
|||
|
||||
/// \return The pointer operand of this load,store, gather or scatter.
|
||||
Value *getMemoryPointerParam() const;
|
||||
static Optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
|
||||
static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
|
||||
|
||||
/// \return The data (payload) operand of this store or scatter.
|
||||
Value *getMemoryDataParam() const;
|
||||
static Optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
|
||||
static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static bool classof(const IntrinsicInst *I) {
|
||||
|
@ -528,12 +529,12 @@ public:
|
|||
}
|
||||
|
||||
// Equivalent non-predicated opcode
|
||||
Optional<unsigned> getFunctionalOpcode() const {
|
||||
std::optional<unsigned> getFunctionalOpcode() const {
|
||||
return getFunctionalOpcodeForVP(getIntrinsicID());
|
||||
}
|
||||
|
||||
// Equivalent non-predicated opcode
|
||||
static Optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
|
||||
static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
|
||||
};
|
||||
|
||||
/// This represents vector predication reduction intrinsics.
|
||||
|
@ -544,8 +545,8 @@ public:
|
|||
unsigned getStartParamPos() const;
|
||||
unsigned getVectorParamPos() const;
|
||||
|
||||
static Optional<unsigned> getStartParamPos(Intrinsic::ID ID);
|
||||
static Optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
|
||||
static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
|
||||
static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
/// @{
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include <optional>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -122,7 +123,7 @@ static bool maySpeculateLanes(VPIntrinsic &VPI) {
|
|||
if (isa<VPReductionIntrinsic>(VPI))
|
||||
return false;
|
||||
// Fallback to whether the intrinsic is speculatable.
|
||||
Optional<unsigned> OpcOpt = VPI.getFunctionalOpcode();
|
||||
std::optional<unsigned> OpcOpt = VPI.getFunctionalOpcode();
|
||||
unsigned FunctionalOpc = OpcOpt.value_or((unsigned)Instruction::Call);
|
||||
return isSafeToSpeculativelyExecuteWithOpcode(FunctionalOpc, &VPI);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -55,7 +56,7 @@ static cl::opt<bool> DisableI2pP2iOpt(
|
|||
// AllocaInst Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Optional<TypeSize>
|
||||
std::optional<TypeSize>
|
||||
AllocaInst::getAllocationSizeInBits(const DataLayout &DL) const {
|
||||
TypeSize Size = DL.getTypeAllocSizeInBits(getAllocatedType());
|
||||
if (isArrayAllocation()) {
|
||||
|
|
|
@ -412,7 +412,8 @@ void VPIntrinsic::setVectorLengthParam(Value *NewEVL) {
|
|||
setArgOperand(*EVLPos, NewEVL);
|
||||
}
|
||||
|
||||
Optional<unsigned> VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
|
||||
std::optional<unsigned>
|
||||
VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
|
||||
switch (IntrinsicID) {
|
||||
default:
|
||||
return std::nullopt;
|
||||
|
@ -424,7 +425,7 @@ Optional<unsigned> VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
|
|||
}
|
||||
}
|
||||
|
||||
Optional<unsigned>
|
||||
std::optional<unsigned>
|
||||
VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
|
||||
switch (IntrinsicID) {
|
||||
default:
|
||||
|
@ -440,7 +441,8 @@ VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
|
|||
/// \return the alignment of the pointer used by this load/store/gather or
|
||||
/// scatter.
|
||||
MaybeAlign VPIntrinsic::getPointerAlignment() const {
|
||||
Optional<unsigned> PtrParamOpt = getMemoryPointerParamPos(getIntrinsicID());
|
||||
std::optional<unsigned> PtrParamOpt =
|
||||
getMemoryPointerParamPos(getIntrinsicID());
|
||||
assert(PtrParamOpt && "no pointer argument!");
|
||||
return getParamAlign(PtrParamOpt.value());
|
||||
}
|
||||
|
@ -452,7 +454,8 @@ Value *VPIntrinsic::getMemoryPointerParam() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Optional<unsigned> VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
|
||||
std::optional<unsigned>
|
||||
VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
|
||||
switch (VPID) {
|
||||
default:
|
||||
break;
|
||||
|
@ -472,7 +475,7 @@ Value *VPIntrinsic::getMemoryDataParam() const {
|
|||
return getArgOperand(DataParamOpt.value());
|
||||
}
|
||||
|
||||
Optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
|
||||
std::optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
|
||||
switch (VPID) {
|
||||
default:
|
||||
break;
|
||||
|
@ -497,7 +500,8 @@ bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) {
|
|||
}
|
||||
|
||||
// Equivalent non-predicated opcode
|
||||
Optional<unsigned> VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
|
||||
std::optional<unsigned>
|
||||
VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
|
||||
switch (ID) {
|
||||
default:
|
||||
break;
|
||||
|
@ -708,7 +712,8 @@ unsigned VPReductionIntrinsic::getStartParamPos() const {
|
|||
return *VPReductionIntrinsic::getStartParamPos(getIntrinsicID());
|
||||
}
|
||||
|
||||
Optional<unsigned> VPReductionIntrinsic::getVectorParamPos(Intrinsic::ID ID) {
|
||||
std::optional<unsigned>
|
||||
VPReductionIntrinsic::getVectorParamPos(Intrinsic::ID ID) {
|
||||
switch (ID) {
|
||||
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
|
||||
#define VP_PROPERTY_REDUCTION(STARTPOS, VECTORPOS) return VECTORPOS;
|
||||
|
@ -720,7 +725,8 @@ Optional<unsigned> VPReductionIntrinsic::getVectorParamPos(Intrinsic::ID ID) {
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
Optional<unsigned> VPReductionIntrinsic::getStartParamPos(Intrinsic::ID ID) {
|
||||
std::optional<unsigned>
|
||||
VPReductionIntrinsic::getStartParamPos(Intrinsic::ID ID) {
|
||||
switch (ID) {
|
||||
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
|
||||
#define VP_PROPERTY_REDUCTION(STARTPOS, VECTORPOS) return STARTPOS;
|
||||
|
|
|
@ -655,7 +655,7 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
|
|||
StackLifetimeAnalyzer.getLiveRange(AI2));
|
||||
};
|
||||
auto GetAllocaSize = [&](const AllocaInfo &A) {
|
||||
Optional<TypeSize> RetSize = A.Alloca->getAllocationSizeInBits(DL);
|
||||
std::optional<TypeSize> RetSize = A.Alloca->getAllocationSizeInBits(DL);
|
||||
assert(RetSize && "Variable Length Arrays (VLA) are not supported.\n");
|
||||
assert(!RetSize->isScalable() && "Scalable vectors are not yet supported");
|
||||
return RetSize->getFixedSize();
|
||||
|
|
|
@ -3313,7 +3313,7 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
|
|||
LiveGcValues.insert(BasePtr);
|
||||
LiveGcValues.insert(DerivedPtr);
|
||||
}
|
||||
Optional<OperandBundleUse> Bundle =
|
||||
std::optional<OperandBundleUse> Bundle =
|
||||
GCSP.getOperandBundle(LLVMContext::OB_gc_live);
|
||||
unsigned NumOfGCLives = LiveGcValues.size();
|
||||
if (!Bundle || NumOfGCLives == Bundle->Inputs.size())
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
@ -826,7 +827,7 @@ populateEHOperandBundle(VPCandidateInfo &Cand,
|
|||
if (!isa<IntrinsicInst>(OrigCall)) {
|
||||
// The instrumentation call should belong to the same funclet as a
|
||||
// non-intrinsic call, so just copy the operand bundle, if any exists.
|
||||
Optional<OperandBundleUse> ParentFunclet =
|
||||
std::optional<OperandBundleUse> ParentFunclet =
|
||||
OrigCall->getOperandBundle(LLVMContext::OB_funclet);
|
||||
if (ParentFunclet)
|
||||
OpBundles.emplace_back(OperandBundleDef(*ParentFunclet));
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -1348,7 +1349,7 @@ static bool hasUndefContents(MemorySSA *MSSA, AliasAnalysis *AA, Value *V,
|
|||
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(V))) {
|
||||
if (getUnderlyingObject(II->getArgOperand(1)) == Alloca) {
|
||||
const DataLayout &DL = Alloca->getModule()->getDataLayout();
|
||||
if (Optional<TypeSize> AllocaSize =
|
||||
if (std::optional<TypeSize> AllocaSize =
|
||||
Alloca->getAllocationSizeInBits(DL))
|
||||
if (*AllocaSize == LTSize->getValue() * 8)
|
||||
return true;
|
||||
|
|
|
@ -296,7 +296,7 @@ using RematCandTy = MapVector<Value *, RematerizlizationCandidateRecord>;
|
|||
} // end anonymous namespace
|
||||
|
||||
static ArrayRef<Use> GetDeoptBundleOperands(const CallBase *Call) {
|
||||
Optional<OperandBundleUse> DeoptBundle =
|
||||
std::optional<OperandBundleUse> DeoptBundle =
|
||||
Call->getOperandBundle(LLVMContext::OB_deopt);
|
||||
|
||||
if (!DeoptBundle) {
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -2138,7 +2139,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
|
|||
if (CallerPersonality) {
|
||||
EHPersonality Personality = classifyEHPersonality(CallerPersonality);
|
||||
if (isScopedEHPersonality(Personality)) {
|
||||
Optional<OperandBundleUse> ParentFunclet =
|
||||
std::optional<OperandBundleUse> ParentFunclet =
|
||||
CB.getOperandBundle(LLVMContext::OB_funclet);
|
||||
if (ParentFunclet)
|
||||
CallSiteEHPad = cast<FuncletPadInst>(ParentFunclet->Inputs.front());
|
||||
|
@ -2283,7 +2284,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
|
|||
HandleByValArgumentInit(Init.Ty, Init.Dst, Init.Src, Caller->getParent(),
|
||||
&*FirstNewBlock, IFI);
|
||||
|
||||
Optional<OperandBundleUse> ParentDeopt =
|
||||
std::optional<OperandBundleUse> ParentDeopt =
|
||||
CB.getOperandBundle(LLVMContext::OB_deopt);
|
||||
if (ParentDeopt) {
|
||||
SmallVector<OperandBundleDef, 2> OpDefs;
|
||||
|
|
|
@ -1487,7 +1487,8 @@ static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
|
|||
"address of variable must have exactly 1 location operand.");
|
||||
if (auto *AI =
|
||||
dyn_cast_or_null<AllocaInst>(DII->getVariableLocationOp(0))) {
|
||||
if (Optional<TypeSize> FragmentSize = AI->getAllocationSizeInBits(DL)) {
|
||||
if (std::optional<TypeSize> FragmentSize =
|
||||
AI->getAllocationSizeInBits(DL)) {
|
||||
return TypeSize::isKnownGE(ValueSize, *FragmentSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ void MemoryOpRemark::visitVariable(const Value *V,
|
|||
return;
|
||||
|
||||
// If not, get it from the alloca.
|
||||
Optional<TypeSize> TySize = AI->getAllocationSizeInBits(DL);
|
||||
std::optional<TypeSize> TySize = AI->getAllocationSizeInBits(DL);
|
||||
std::optional<uint64_t> Size =
|
||||
TySize ? getSizeInBytes(TySize->getFixedSize()) : std::nullopt;
|
||||
VariableInfo Var{nameOrNone(AI), Size};
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -259,7 +260,7 @@ TEST_F(VPIntrinsicTest, GetParamPos) {
|
|||
|
||||
for (Function &F : *M) {
|
||||
ASSERT_TRUE(F.isIntrinsic());
|
||||
Optional<unsigned> MaskParamPos =
|
||||
std::optional<unsigned> MaskParamPos =
|
||||
VPIntrinsic::getMaskParamPos(F.getIntrinsicID());
|
||||
if (MaskParamPos) {
|
||||
Type *MaskParamType = F.getArg(MaskParamPos.value())->getType();
|
||||
|
@ -268,7 +269,7 @@ TEST_F(VPIntrinsicTest, GetParamPos) {
|
|||
cast<VectorType>(MaskParamType)->getElementType()->isIntegerTy(1));
|
||||
}
|
||||
|
||||
Optional<unsigned> VecLenParamPos =
|
||||
std::optional<unsigned> VecLenParamPos =
|
||||
VPIntrinsic::getVectorLengthParamPos(F.getIntrinsicID());
|
||||
if (VecLenParamPos) {
|
||||
Type *VecLenParamType = F.getArg(VecLenParamPos.value())->getType();
|
||||
|
@ -295,7 +296,7 @@ TEST_F(VPIntrinsicTest, OpcodeRoundTrip) {
|
|||
if (VPID == Intrinsic::not_intrinsic)
|
||||
continue;
|
||||
|
||||
Optional<unsigned> RoundTripOC =
|
||||
std::optional<unsigned> RoundTripOC =
|
||||
VPIntrinsic::getFunctionalOpcodeForVP(VPID);
|
||||
// No equivalent Opcode available.
|
||||
if (!RoundTripOC)
|
||||
|
@ -316,7 +317,7 @@ TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) {
|
|||
unsigned FullTripCounts = 0;
|
||||
for (const auto &VPDecl : *M) {
|
||||
auto VPID = VPDecl.getIntrinsicID();
|
||||
Optional<unsigned> OC = VPIntrinsic::getFunctionalOpcodeForVP(VPID);
|
||||
std::optional<unsigned> OC = VPIntrinsic::getFunctionalOpcodeForVP(VPID);
|
||||
|
||||
// no equivalent Opcode available
|
||||
if (!OC)
|
||||
|
|
Loading…
Reference in New Issue