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,
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);
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.