diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
commit | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (patch) | |
tree | 6a77b463f700e090df586672c26b9fe765fd115b /llvm/lib/IR/IRBuilder.cpp | |
parent | ec6892d1c979ce0b84c86918d5cdbb03037b409a (diff) | |
parent | 6d16b1c5c468a79ecf867293023c89ac518ecdda (diff) | |
download | llvm-users/chapuni/cov/single/nextcount-base.zip llvm-users/chapuni/cov/single/nextcount-base.tar.gz llvm-users/chapuni/cov/single/nextcount-base.tar.bz2 |
Merge branch 'users/chapuni/cov/single/pair' into users/chapuni/cov/single/nextcount-baseusers/chapuni/cov/single/nextcount-base
Diffstat (limited to 'llvm/lib/IR/IRBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index f340f7a..27b499e 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -78,11 +78,11 @@ void IRBuilderBase::SetInstDebugLocation(Instruction *I) const { CallInst * IRBuilderBase::createCallHelper(Function *Callee, ArrayRef<Value *> Ops, - const Twine &Name, Instruction *FMFSource, + const Twine &Name, FMFSource FMFSource, ArrayRef<OperandBundleDef> OpBundles) { CallInst *CI = CreateCall(Callee, Ops, OpBundles, Name); - if (FMFSource) - CI->copyFastMathFlags(FMFSource); + if (isa<FPMathOperator>(CI)) + CI->setFastMathFlags(FMFSource.get(FMF)); return CI; } @@ -869,7 +869,7 @@ CallInst *IRBuilderBase::CreateGCGetPointerOffset(Value *DerivedPtr, } CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, - Instruction *FMFSource, + FMFSource FMFSource, const Twine &Name) { Module *M = BB->getModule(); Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, {V->getType()}); @@ -877,12 +877,12 @@ CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, } Value *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, - Value *RHS, Instruction *FMFSource, + Value *RHS, FMFSource FMFSource, const Twine &Name) { Module *M = BB->getModule(); Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, {LHS->getType()}); if (Value *V = Folder.FoldBinaryIntrinsic(ID, LHS, RHS, Fn->getReturnType(), - FMFSource)) + /*FMFSource=*/nullptr)) return V; return createCallHelper(Fn, {LHS, RHS}, Name, FMFSource); } @@ -890,7 +890,7 @@ Value *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, ArrayRef<Type *> Types, ArrayRef<Value *> Args, - Instruction *FMFSource, + FMFSource FMFSource, const Twine &Name) { Module *M = BB->getModule(); Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, Types); @@ -899,7 +899,7 @@ CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, CallInst *IRBuilderBase::CreateIntrinsic(Type *RetTy, Intrinsic::ID ID, ArrayRef<Value *> Args, - Instruction *FMFSource, + FMFSource FMFSource, const Twine &Name) { Module *M = BB->getModule(); @@ -925,16 +925,13 @@ 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, - std::optional<RoundingMode> Rounding, + Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource, + const Twine &Name, MDNode *FPMathTag, std::optional<RoundingMode> Rounding, std::optional<fp::ExceptionBehavior> Except) { Value *RoundingV = getConstrainedFPRounding(Rounding); Value *ExceptV = getConstrainedFPExcept(Except); - FastMathFlags UseFMF = FMF; - if (FMFSource) - UseFMF = FMFSource->getFastMathFlags(); + FastMathFlags UseFMF = FMFSource.get(FMF); CallInst *C = CreateIntrinsic(ID, {L->getType()}, {L, R, RoundingV, ExceptV}, nullptr, Name); @@ -944,14 +941,12 @@ CallInst *IRBuilderBase::CreateConstrainedFPBinOp( } CallInst *IRBuilderBase::CreateConstrainedFPUnroundedBinOp( - Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource, + Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag, std::optional<fp::ExceptionBehavior> Except) { Value *ExceptV = getConstrainedFPExcept(Except); - FastMathFlags UseFMF = FMF; - if (FMFSource) - UseFMF = FMFSource->getFastMathFlags(); + FastMathFlags UseFMF = FMFSource.get(FMF); CallInst *C = CreateIntrinsic(ID, {L->getType()}, {L, R, ExceptV}, nullptr, Name); @@ -976,15 +971,12 @@ Value *IRBuilderBase::CreateNAryOp(unsigned Opc, ArrayRef<Value *> Ops, } CallInst *IRBuilderBase::CreateConstrainedFPCast( - Intrinsic::ID ID, Value *V, Type *DestTy, - Instruction *FMFSource, const Twine &Name, MDNode *FPMathTag, - std::optional<RoundingMode> Rounding, + Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource, + const Twine &Name, MDNode *FPMathTag, std::optional<RoundingMode> Rounding, std::optional<fp::ExceptionBehavior> Except) { Value *ExceptV = getConstrainedFPExcept(Except); - FastMathFlags UseFMF = FMF; - if (FMFSource) - UseFMF = FMFSource->getFastMathFlags(); + FastMathFlags UseFMF = FMFSource.get(FMF); CallInst *C; if (Intrinsic::hasConstrainedFPRoundingModeOperand(ID)) { @@ -1002,9 +994,10 @@ CallInst *IRBuilderBase::CreateConstrainedFPCast( return C; } -Value *IRBuilderBase::CreateFCmpHelper( - CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name, - MDNode *FPMathTag, bool IsSignaling) { +Value *IRBuilderBase::CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, + Value *RHS, const Twine &Name, + MDNode *FPMathTag, FMFSource FMFSource, + bool IsSignaling) { if (IsFPConstrained) { auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps : Intrinsic::experimental_constrained_fcmp; @@ -1013,7 +1006,9 @@ Value *IRBuilderBase::CreateFCmpHelper( if (auto *V = Folder.FoldCmp(P, LHS, RHS)) return V; - return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name); + return Insert( + setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMFSource.get(FMF)), + Name); } CallInst *IRBuilderBase::CreateConstrainedFPCmp( @@ -1047,6 +1042,12 @@ CallInst *IRBuilderBase::CreateConstrainedFPCall( Value *IRBuilderBase::CreateSelect(Value *C, Value *True, Value *False, const Twine &Name, Instruction *MDFrom) { + return CreateSelectFMF(C, True, False, {}, Name, MDFrom); +} + +Value *IRBuilderBase::CreateSelectFMF(Value *C, Value *True, Value *False, + FMFSource FMFSource, const Twine &Name, + Instruction *MDFrom) { if (auto *V = Folder.FoldSelect(C, True, False)) return V; @@ -1057,7 +1058,7 @@ Value *IRBuilderBase::CreateSelect(Value *C, Value *True, Value *False, Sel = addBranchMetadata(Sel, Prof, Unpred); } if (isa<FPMathOperator>(Sel)) - setFPAttrs(Sel, nullptr /* MDNode* */, FMF); + setFPAttrs(Sel, /*MDNode=*/nullptr, FMFSource.get(FMF)); return Insert(Sel, Name); } |