#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"
///
/// 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) {
/// 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; }
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);
/// \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) {
}
// 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.
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:
/// @{
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include <optional>
using namespace llvm;
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);
}
#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <optional>
#include <vector>
using namespace llvm;
// AllocaInst Class
//===----------------------------------------------------------------------===//
-Optional<TypeSize>
+std::optional<TypeSize>
AllocaInst::getAllocationSizeInBits(const DataLayout &DL) const {
TypeSize Size = DL.getTypeAllocSizeInBits(getAllocatedType());
if (isArrayAllocation()) {
setArgOperand(*EVLPos, NewEVL);
}
-Optional<unsigned> VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
+std::optional<unsigned>
+VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
return std::nullopt;
}
}
-Optional<unsigned>
+std::optional<unsigned>
VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
/// \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());
}
return nullptr;
}
-Optional<unsigned> VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
+std::optional<unsigned>
+VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
switch (VPID) {
default:
break;
return getArgOperand(DataParamOpt.value());
}
-Optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
+std::optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
switch (VPID) {
default:
break;
}
// Equivalent non-predicated opcode
-Optional<unsigned> VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
+std::optional<unsigned>
+VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
switch (ID) {
default:
break;
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;
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;
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();
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())
#include <map>
#include <memory>
#include <numeric>
+#include <optional>
#include <set>
#include <string>
#include <unordered_map>
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));
#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <optional>
using namespace llvm;
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;
} // end anonymous namespace
static ArrayRef<Use> GetDeoptBundleOperands(const CallBase *Call) {
- Optional<OperandBundleUse> DeoptBundle =
+ std::optional<OperandBundleUse> DeoptBundle =
Call->getOperandBundle(LLVMContext::OB_deopt);
if (!DeoptBundle) {
#include <cstdint>
#include <iterator>
#include <limits>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
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());
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;
"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);
}
}
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};
#include "llvm/IR/Verifier.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
+#include <optional>
#include <sstream>
using namespace llvm;
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();
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();
if (VPID == Intrinsic::not_intrinsic)
continue;
- Optional<unsigned> RoundTripOC =
+ std::optional<unsigned> RoundTripOC =
VPIntrinsic::getFunctionalOpcodeForVP(VPID);
// No equivalent Opcode available.
if (!RoundTripOC)
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)