From: Sanjay Patel Date: Thu, 31 Dec 2015 15:39:34 +0000 (+0000) Subject: add FMF for CreateCall variant X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3f79d5915246b9946e543dbbf78728cc1194cfae;p=oota-llvm.git add FMF for CreateCall variant The version with OpBundles was missed in: http://reviews.llvm.org/rL255555 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 7fe04f2a091..e133e6d8093 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -1529,8 +1529,11 @@ public: CallInst *CreateCall(Value *Callee, ArrayRef Args = None, ArrayRef OpBundles = None, - const Twine &Name = "") { - return Insert(CallInst::Create(Callee, Args, OpBundles), Name); + const Twine &Name = "", MDNode *FPMathTag = nullptr) { + CallInst *CI = CallInst::Create(Callee, Args, OpBundles); + if (isa(CI)) + CI = cast(AddFPMathAttributes(CI, FPMathTag, FMF)); + return Insert(CI, Name); } CallInst *CreateCall(Value *Callee, ArrayRef Args, diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index e0da018d7bf..82565ccaebc 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -217,6 +217,11 @@ TEST_F(IRBuilderTest, FastMathFlags) { FCall = Builder.CreateCall(Callee, None); EXPECT_FALSE(FCall->hasNoNaNs()); + Value *V = + Function::Create(CalleeTy, Function::ExternalLinkage, "", M.get()); + FCall = Builder.CreateCall(V, None); + EXPECT_FALSE(FCall->hasNoNaNs()); + FMF.clear(); FMF.setNoNaNs(); Builder.SetFastMathFlags(FMF); @@ -226,6 +231,11 @@ TEST_F(IRBuilderTest, FastMathFlags) { EXPECT_TRUE(Builder.getFastMathFlags().NoNaNs); EXPECT_TRUE(FCall->hasNoNaNs()); + FCall = Builder.CreateCall(V, None); + EXPECT_TRUE(Builder.getFastMathFlags().any()); + EXPECT_TRUE(Builder.getFastMathFlags().NoNaNs); + EXPECT_TRUE(FCall->hasNoNaNs()); + Builder.clearFastMathFlags(); // To test a copy, make sure that a '0' and a '1' change state.