mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 00:36:06 +00:00
[FPEnv] IRBuilder fails to add strictfp attribute
The strictfp attribute is required on all function calls in a function that is itself marked with the strictfp attribute. The IRBuilder knows this and has a method for adding the attribute to function call instructions. If a function being called has the strictfp attribute itself then the IRBuilder will refuse to add the attribute to the calling instruction despite being asked to add it. Eliminate this error. Differential Revision: https://reviews.llvm.org/D84878
This commit is contained in:
parent
317e00dc54
commit
d535a91d13
@ -294,8 +294,7 @@ public:
|
||||
}
|
||||
|
||||
void setConstrainedFPCallAttr(CallInst *I) {
|
||||
if (!I->hasFnAttr(Attribute::StrictFP))
|
||||
I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
|
||||
I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
|
||||
}
|
||||
|
||||
void setDefaultOperandBundles(ArrayRef<OperandBundleDef> OpBundles) {
|
||||
|
@ -332,6 +332,33 @@ TEST_F(IRBuilderTest, ConstrainedFPIntrinsics) {
|
||||
EXPECT_EQ(fp::ebStrict, CII->getExceptionBehavior());
|
||||
}
|
||||
|
||||
TEST_F(IRBuilderTest, ConstrainedFPFunctionCall) {
|
||||
IRBuilder<> Builder(BB);
|
||||
|
||||
// Create an empty constrained FP function.
|
||||
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
|
||||
/*isVarArg=*/false);
|
||||
Function *Callee =
|
||||
Function::Create(FTy, Function::ExternalLinkage, "", M.get());
|
||||
BasicBlock *CalleeBB = BasicBlock::Create(Ctx, "", Callee);
|
||||
IRBuilder<> CalleeBuilder(CalleeBB);
|
||||
CalleeBuilder.setIsFPConstrained(true);
|
||||
CalleeBuilder.setConstrainedFPFunctionAttr();
|
||||
CalleeBuilder.CreateRetVoid();
|
||||
|
||||
// Now call the empty constrained FP function.
|
||||
Builder.setIsFPConstrained(true);
|
||||
Builder.setConstrainedFPFunctionAttr();
|
||||
CallInst *FCall = Builder.CreateCall(Callee, None);
|
||||
|
||||
// Check the attributes to verify the strictfp attribute is on the call.
|
||||
EXPECT_TRUE(FCall->getAttributes().getFnAttributes().hasAttribute(
|
||||
Attribute::StrictFP));
|
||||
|
||||
Builder.CreateRetVoid();
|
||||
EXPECT_FALSE(verifyModule(*M));
|
||||
}
|
||||
|
||||
TEST_F(IRBuilderTest, Lifetime) {
|
||||
IRBuilder<> Builder(BB);
|
||||
AllocaInst *Var1 = Builder.CreateAlloca(Builder.getInt8Ty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user