add FMF for CreateCall variant

The version with OpBundles was missed in:
http://reviews.llvm.org/rL255555

llvm-svn: 256674
This commit is contained in:
Sanjay Patel 2015-12-31 15:39:34 +00:00
parent 0dc468880d
commit 947cccb862
2 changed files with 15 additions and 2 deletions

View File

@ -1529,8 +1529,11 @@ public:
CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args = None,
ArrayRef<OperandBundleDef> 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<FPMathOperator>(CI))
CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
return Insert(CI, Name);
}
CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,

View File

@ -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.