Skip to content

Commit

Permalink
add FMF for CreateCall variant
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rotateright committed Dec 31, 2015
1 parent 6edca69 commit 3f79d59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/llvm/IR/IRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1529,8 +1529,11 @@ class IRBuilder : public IRBuilderBase, public Inserter {

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,
Expand Down
10 changes: 10 additions & 0 deletions unittests/IR/IRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down

0 comments on commit 3f79d59

Please sign in to comment.