diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 192b5f818f3cd..59fba7a8211d0 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -815,7 +815,7 @@ class IRBuilderBase { CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, ArrayRef CallArgs, - Optional> DeoptArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); @@ -824,8 +824,8 @@ class IRBuilderBase { CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, uint32_t Flags, ArrayRef CallArgs, - Optional> TransitionArgs, - Optional> DeoptArgs, + std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); @@ -835,7 +835,7 @@ class IRBuilderBase { CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, ArrayRef CallArgs, - Optional> DeoptArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); @@ -845,7 +845,7 @@ class IRBuilderBase { CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef InvokeArgs, - Optional> DeoptArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); /// Create an invoke to the experimental.gc.statepoint intrinsic to @@ -853,8 +853,8 @@ class IRBuilderBase { InvokeInst *CreateGCStatepointInvoke( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, - ArrayRef InvokeArgs, Optional> TransitionArgs, - Optional> DeoptArgs, ArrayRef GCArgs, + ArrayRef InvokeArgs, std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); // Convenience function for the common case when CallArgs are filled in using @@ -864,7 +864,7 @@ class IRBuilderBase { CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef InvokeArgs, - Optional> DeoptArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name = ""); /// Create a call to the experimental.gc.result intrinsic to extract @@ -1195,7 +1195,7 @@ class IRBuilderBase { return I; } - Value *getConstrainedFPRounding(Optional Rounding) { + Value *getConstrainedFPRounding(std::optional Rounding) { RoundingMode UseRounding = DefaultConstrainedRounding; if (Rounding) @@ -1209,7 +1209,7 @@ class IRBuilderBase { return MetadataAsValue::get(Context, RoundingMDS); } - Value *getConstrainedFPExcept(Optional Except) { + Value *getConstrainedFPExcept(std::optional Except) { fp::ExceptionBehavior UseExcept = DefaultConstrainedExcept; if (Except) @@ -1608,8 +1608,8 @@ class IRBuilderBase { CallInst *CreateConstrainedFPBinOp( Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource = nullptr, const Twine &Name = "", MDNode *FPMathTag = nullptr, - Optional Rounding = std::nullopt, - Optional Except = std::nullopt); + std::optional Rounding = std::nullopt, + std::optional Except = std::nullopt); Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -2090,8 +2090,8 @@ class IRBuilderBase { Intrinsic::ID ID, Value *V, Type *DestTy, Instruction *FMFSource = nullptr, const Twine &Name = "", MDNode *FPMathTag = nullptr, - Optional Rounding = std::nullopt, - Optional Except = std::nullopt); + std::optional Rounding = std::nullopt, + std::optional Except = std::nullopt); // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a // compile time error, instead of converting the string to bool for the @@ -2249,10 +2249,10 @@ class IRBuilderBase { bool IsSignaling); public: - CallInst * - CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, - Value *R, const Twine &Name = "", - Optional Except = std::nullopt); + CallInst *CreateConstrainedFPCmp( + Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, + const Twine &Name = "", + std::optional Except = std::nullopt); //===--------------------------------------------------------------------===// // Instruction creation methods: Other Instructions @@ -2311,8 +2311,8 @@ class IRBuilderBase { CallInst *CreateConstrainedFPCall( Function *Callee, ArrayRef Args, const Twine &Name = "", - Optional Rounding = std::nullopt, - Optional Except = std::nullopt); + std::optional Rounding = std::nullopt, + std::optional Except = std::nullopt); Value *CreateSelect(Value *C, Value *True, Value *False, const Twine &Name = "", Instruction *MDFrom = nullptr); diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index d0bf980bef9c7..2e2f360dec509 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/Casting.h" #include #include +#include #include using namespace llvm; @@ -768,8 +769,8 @@ getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, template static std::vector -getStatepointBundles(Optional> TransitionArgs, - Optional> DeoptArgs, +getStatepointBundles(std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs) { std::vector Rval; if (DeoptArgs) { @@ -794,8 +795,9 @@ template static CallInst *CreateGCStatepointCallCommon( IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, uint32_t Flags, ArrayRef CallArgs, - Optional> TransitionArgs, Optional> DeoptArgs, - ArrayRef GCArgs, const Twine &Name) { + std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, + const Twine &Name) { Module *M = Builder->GetInsertBlock()->getParent()->getParent(); // Fill in the one generic type'd argument (the function is also vararg) Function *FnStatepoint = @@ -816,7 +818,7 @@ static CallInst *CreateGCStatepointCallCommon( CallInst *IRBuilderBase::CreateGCStatepointCall( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, - ArrayRef CallArgs, Optional> DeoptArgs, + ArrayRef CallArgs, std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name) { return CreateGCStatepointCallCommon( this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None), @@ -826,8 +828,9 @@ CallInst *IRBuilderBase::CreateGCStatepointCall( CallInst *IRBuilderBase::CreateGCStatepointCall( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, uint32_t Flags, ArrayRef CallArgs, - Optional> TransitionArgs, Optional> DeoptArgs, - ArrayRef GCArgs, const Twine &Name) { + std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, + const Twine &Name) { return CreateGCStatepointCallCommon( this, ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs, DeoptArgs, GCArgs, Name); @@ -835,7 +838,7 @@ CallInst *IRBuilderBase::CreateGCStatepointCall( CallInst *IRBuilderBase::CreateGCStatepointCall( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, - ArrayRef CallArgs, Optional> DeoptArgs, + ArrayRef CallArgs, std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name) { return CreateGCStatepointCallCommon( this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None), @@ -847,8 +850,9 @@ static InvokeInst *CreateGCStatepointInvokeCommon( IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef InvokeArgs, - Optional> TransitionArgs, Optional> DeoptArgs, - ArrayRef GCArgs, const Twine &Name) { + std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, + const Twine &Name) { Module *M = Builder->GetInsertBlock()->getParent()->getParent(); // Fill in the one generic type'd argument (the function is also vararg) Function *FnStatepoint = @@ -871,7 +875,7 @@ static InvokeInst *CreateGCStatepointInvokeCommon( InvokeInst *IRBuilderBase::CreateGCStatepointInvoke( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, - ArrayRef InvokeArgs, Optional> DeoptArgs, + ArrayRef InvokeArgs, std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name) { return CreateGCStatepointInvokeCommon( this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, @@ -882,8 +886,8 @@ InvokeInst *IRBuilderBase::CreateGCStatepointInvoke( InvokeInst *IRBuilderBase::CreateGCStatepointInvoke( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, - ArrayRef InvokeArgs, Optional> TransitionArgs, - Optional> DeoptArgs, ArrayRef GCArgs, + ArrayRef InvokeArgs, std::optional> TransitionArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name) { return CreateGCStatepointInvokeCommon( this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags, @@ -893,7 +897,7 @@ InvokeInst *IRBuilderBase::CreateGCStatepointInvoke( InvokeInst *IRBuilderBase::CreateGCStatepointInvoke( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef InvokeArgs, - Optional> DeoptArgs, ArrayRef GCArgs, + std::optional> DeoptArgs, ArrayRef GCArgs, const Twine &Name) { return CreateGCStatepointInvokeCommon( this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, @@ -999,8 +1003,8 @@ CallInst *IRBuilderBase::CreateIntrinsic(Type *RetTy, Intrinsic::ID ID, CallInst *IRBuilderBase::CreateConstrainedFPBinOp( Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource, const Twine &Name, MDNode *FPMathTag, - Optional Rounding, - Optional Except) { + std::optional Rounding, + std::optional Except) { Value *RoundingV = getConstrainedFPRounding(Rounding); Value *ExceptV = getConstrainedFPExcept(Except); @@ -1033,8 +1037,8 @@ Value *IRBuilderBase::CreateNAryOp(unsigned Opc, ArrayRef Ops, CallInst *IRBuilderBase::CreateConstrainedFPCast( Intrinsic::ID ID, Value *V, Type *DestTy, Instruction *FMFSource, const Twine &Name, MDNode *FPMathTag, - Optional Rounding, - Optional Except) { + std::optional Rounding, + std::optional Except) { Value *ExceptV = getConstrainedFPExcept(Except); FastMathFlags UseFMF = FMF; @@ -1084,7 +1088,7 @@ Value *IRBuilderBase::CreateFCmpHelper( CallInst *IRBuilderBase::CreateConstrainedFPCmp( Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, - const Twine &Name, Optional Except) { + const Twine &Name, std::optional Except) { Value *PredicateV = getConstrainedFPPredicate(P); Value *ExceptV = getConstrainedFPExcept(Except); @@ -1096,8 +1100,8 @@ CallInst *IRBuilderBase::CreateConstrainedFPCmp( CallInst *IRBuilderBase::CreateConstrainedFPCall( Function *Callee, ArrayRef Args, const Twine &Name, - Optional Rounding, - Optional Except) { + std::optional Rounding, + std::optional Except) { llvm::SmallVector UseArgs; append_range(UseArgs, Args); diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 1ce0b95e43c10..1e35b24c17714 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -1626,10 +1627,10 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */ uint32_t Flags = uint32_t(StatepointFlags::None); SmallVector CallArgs(Call->args()); - Optional> DeoptArgs; + std::optional> DeoptArgs; if (auto Bundle = Call->getOperandBundle(LLVMContext::OB_deopt)) DeoptArgs = Bundle->Inputs; - Optional> TransitionArgs; + std::optional> TransitionArgs; if (auto Bundle = Call->getOperandBundle(LLVMContext::OB_gc_transition)) { TransitionArgs = Bundle->Inputs; // TODO: This flag no longer serves a purpose and can be removed later