diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-10 14:17:42 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-10 14:17:42 +0000 |
commit | 3c29c0704b0c398429c0b9d972160964b234287d (patch) | |
tree | f583681b387a4e2820ad89d1f7aff6ddbc4e4716 /llvm/unittests/Analysis/CFGTest.cpp | |
parent | b8266d2062f203507de2154936fd25d686c303e1 (diff) | |
download | bcm5719-llvm-3c29c0704b0c398429c0b9d972160964b234287d.tar.gz bcm5719-llvm-3c29c0704b0c398429c0b9d972160964b234287d.zip |
Make succ_iterator a real random access iterator and clean up a couple of users.
llvm-svn: 201088
Diffstat (limited to 'llvm/unittests/Analysis/CFGTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/CFGTest.cpp | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/llvm/unittests/Analysis/CFGTest.cpp b/llvm/unittests/Analysis/CFGTest.cpp index 76514f4d893..ab7e0a4ac00 100644 --- a/llvm/unittests/Analysis/CFGTest.cpp +++ b/llvm/unittests/Analysis/CFGTest.cpp @@ -115,7 +115,7 @@ protected: PM.add(P); PM.run(*M); } -private: + OwningPtr<Module> M; Instruction *A, *B; }; @@ -352,27 +352,40 @@ TEST_F(IsPotentiallyReachableTest, OneLoopAfterTheOtherInsideAThirdLoop) { ExpectPath(true); } +static const char *BranchInsideLoopIR = + "declare i1 @switch()\n" + "\n" + "define void @test() {\n" + "entry:\n" + " br label %loop\n" + "loop:\n" + " %x = call i1 @switch()\n" + " br i1 %x, label %nextloopblock, label %exit\n" + "nextloopblock:\n" + " %y = call i1 @switch()\n" + " br i1 %y, label %left, label %right\n" + "left:\n" + " %A = bitcast i8 undef to i8\n" + " br label %loop\n" + "right:\n" + " %B = bitcast i8 undef to i8\n" + " br label %loop\n" + "exit:\n" + " ret void\n" + "}"; + TEST_F(IsPotentiallyReachableTest, BranchInsideLoop) { - ParseAssembly( - "declare i1 @switch()\n" - "\n" - "define void @test() {\n" - "entry:\n" - " br label %loop\n" - "loop:\n" - " %x = call i1 @switch()\n" - " br i1 %x, label %nextloopblock, label %exit\n" - "nextloopblock:\n" - " %y = call i1 @switch()\n" - " br i1 %y, label %left, label %right\n" - "left:\n" - " %A = bitcast i8 undef to i8\n" - " br label %loop\n" - "right:\n" - " %B = bitcast i8 undef to i8\n" - " br label %loop\n" - "exit:\n" - " ret void\n" - "}"); + ParseAssembly(BranchInsideLoopIR); + ExpectPath(true); +} + +TEST_F(IsPotentiallyReachableTest, ModifyTest) { + ParseAssembly(BranchInsideLoopIR); + + succ_iterator S = succ_begin(++M->getFunction("test")->begin()); + BasicBlock *OldBB = S[0]; + S[0] = S[1]; + ExpectPath(false); + S[0] = OldBB; ExpectPath(true); } |