mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
IRBuilder: Add RAII objects to reset insertion points or fast math flags.
Inspired by the object from the SLPVectorizer. This found a minor bug in the debug loc restoration in the vectorizer where the location of a following instruction was attached instead of the location from the original instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -182,4 +182,40 @@ TEST_F(IRBuilderTest, FastMathFlags) {
|
||||
|
||||
}
|
||||
|
||||
TEST_F(IRBuilderTest, RAIIHelpersTest) {
|
||||
IRBuilder<> Builder(BB);
|
||||
EXPECT_FALSE(Builder.getFastMathFlags().allowReciprocal());
|
||||
MDBuilder MDB(M->getContext());
|
||||
|
||||
MDNode *FPMathA = MDB.createFPMath(0.01);
|
||||
MDNode *FPMathB = MDB.createFPMath(0.1);
|
||||
|
||||
Builder.SetDefaultFPMathTag(FPMathA);
|
||||
|
||||
{
|
||||
IRBuilder<>::FastMathFlagGuard Guard(Builder);
|
||||
FastMathFlags FMF;
|
||||
FMF.setAllowReciprocal();
|
||||
Builder.SetFastMathFlags(FMF);
|
||||
Builder.SetDefaultFPMathTag(FPMathB);
|
||||
EXPECT_TRUE(Builder.getFastMathFlags().allowReciprocal());
|
||||
EXPECT_EQ(FPMathB, Builder.getDefaultFPMathTag());
|
||||
}
|
||||
|
||||
EXPECT_FALSE(Builder.getFastMathFlags().allowReciprocal());
|
||||
EXPECT_EQ(FPMathA, Builder.getDefaultFPMathTag());
|
||||
|
||||
Value *F = Builder.CreateLoad(GV);
|
||||
|
||||
{
|
||||
IRBuilder<>::InsertPointGuard Guard(Builder);
|
||||
Builder.SetInsertPoint(cast<Instruction>(F));
|
||||
EXPECT_EQ(F, Builder.GetInsertPoint());
|
||||
}
|
||||
|
||||
EXPECT_EQ(BB->end(), Builder.GetInsertPoint());
|
||||
EXPECT_EQ(BB, Builder.GetInsertBlock());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user