diff options
author | Igor Laevsky <igmyrj@gmail.com> | 2017-12-13 11:45:53 +0000 |
---|---|---|
committer | Igor Laevsky <igmyrj@gmail.com> | 2017-12-13 11:45:53 +0000 |
commit | 033683a63fc1e74deace77962a3d79fc8040e5dc (patch) | |
tree | 35d21a34a0ebcc640dea28950968e49c8f005c56 /unittests | |
parent | 6dc08a09269df810075faf71bfb36d996fc09fac (diff) |
[FuzzMutate] Correctly split landingpad blocks
Differential Revision: https://reviews.llvm.org/D41112
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/FuzzMutate/OperationsTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/unittests/FuzzMutate/OperationsTest.cpp b/unittests/FuzzMutate/OperationsTest.cpp index d18291e3df5..be1789e9475 100644 --- a/unittests/FuzzMutate/OperationsTest.cpp +++ b/unittests/FuzzMutate/OperationsTest.cpp @@ -211,6 +211,35 @@ TEST(OperationsTest, SplitBlock) { EXPECT_FALSE(verifyModule(M, &errs())); } +TEST(OperationsTest, SplitEHBlock) { + // Check that we will not try to branch back to the landingpad block using + // regular branch instruction + + LLVMContext Ctx; + const char *SourceCode = + "declare i32* @f()" + "declare i32 @personality_function()" + "define i32* @test() personality i32 ()* @personality_function {\n" + "entry:\n" + " %val = invoke i32* @f()\n" + " to label %normal unwind label %exceptional\n" + "normal:\n" + " ret i32* %val\n" + "exceptional:\n" + " %landing_pad4 = landingpad token cleanup\n" + " ret i32* undef\n" + "}"; + auto M = parseAssembly(SourceCode, Ctx); + + // Get the landingpad block + BasicBlock &BB = *std::next(M->getFunction("test")->begin(), 2); + + fuzzerop::OpDescriptor Descr = fuzzerop::splitBlockDescriptor(1); + + Descr.BuilderFunc({ConstantInt::getTrue(Ctx)},&*BB.getFirstInsertionPt()); + ASSERT_TRUE(!verifyModule(*M, &errs())); +} + TEST(OperationsTest, SplitBlockWithPhis) { LLVMContext Ctx; |