<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Jul 26, 2013, at 6:24 PM, Nick Lewycky <<a href="mailto:nicholas@mxc.ca">nicholas@mxc.ca</a>> wrote:<br><div><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=187283&view=rev">http://llvm.org/viewvc/llvm-project?rev=187283&view=rev</a><br>Log:<br>Reimplement isPotentiallyReachable to make nocapture deduction much stronger.<br>Adds unit tests for it too.<br><br>Split BasicBlockUtils into an analysis-half and a transforms-half, and put the<br>analysis bits into a new Analysis/CFG.{h,cpp}. Promote isPotentiallyReachable<br>into llvm::isPotentiallyReachable and move it into Analysis/CFG.<br></div></blockquote><div dir="auto"><br></div>Random unit test question for you:</div><div dir="auto"><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">+TEST_F(IsPotentiallyReachableTest, SameBlockNoPath) {<br>+  ParseAssembly(<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  bitcast i8 undef to i8\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  bitcast i8 undef to i8\n"<br>+      "  bitcast i8 undef to i8\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}\n");<br>+  ExpectPath(false);<br>+}<br></div></blockquote><div dir="auto"><br></div><div dir="auto">I understand the value of unit tests for stuff like this, but dumping swaths of LLVM IR into them seems really weird to me.  Why not just express these tests in terms of the benefit, i.e., cases that make nocapture inference work better?  Then they can be written as .ll files like most of our testsuite.</div><div dir="auto"><br></div><div dir="auto">-Chris</div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">+<br>+TEST_F(IsPotentiallyReachableTest, SameBlockPath) {<br>+  ParseAssembly(<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  bitcast i8 undef to i8\n"<br>+      "  bitcast i8 undef to i8\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}\n");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, StraightNoPath) {<br>+  ParseAssembly(<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  br label %exit\n"<br>+      "exit:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(false);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, StraightPath) {<br>+  ParseAssembly(<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  br label %exit\n"<br>+      "exit:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, DestUnreachable) {<br>+  ParseAssembly(<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %midblock\n"<br>+      "midblock:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "unreachable:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  br label %midblock\n"<br>+      "}");<br>+  ExpectPath(false);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, BranchToReturn) {<br>+  ParseAssembly(<br>+      "define void @test(i1 %x) {\n"<br>+      "entry:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  br i1 %x, label %block1, label %block2\n"<br>+      "block1:\n"<br>+      "  ret void\n"<br>+      "block2:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, SimpleLoop1) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %loop\n"<br>+      "loop:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop, label %exit\n"<br>+      "exit:\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, SimpleLoop2) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  br label %loop\n"<br>+      "loop:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop, label %exit\n"<br>+      "exit:\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(false);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, SimpleLoop3) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %loop\n"<br>+      "loop:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop, label %exit\n"<br>+      "exit:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(false);<br>+}<br>+<br>+<br>+TEST_F(IsPotentiallyReachableTest, OneLoopAfterTheOther1) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %loop1\n"<br>+      "loop1:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop1, label %loop1exit\n"<br>+      "loop1exit:\n"<br>+      "  br label %loop2\n"<br>+      "loop2:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  %y = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop2, label %loop2exit\n"<br>+      "loop2exit:"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, OneLoopAfterTheOther2) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %loop1\n"<br>+      "loop1:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop1, label %loop1exit\n"<br>+      "loop1exit:\n"<br>+      "  br label %loop2\n"<br>+      "loop2:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  %y = call i1 @switch()\n"<br>+      "  br i1 %x, label %loop2, label %loop2exit\n"<br>+      "loop2exit:"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(false);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, OneLoopAfterTheOtherInsideAThirdLoop) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %outerloop3\n"<br>+      "outerloop3:\n"<br>+      "  br label %innerloop1\n"<br>+      "innerloop1:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %innerloop1, label %innerloop1exit\n"<br>+      "innerloop1exit:\n"<br>+      "  br label %innerloop2\n"<br>+      "innerloop2:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  %y = call i1 @switch()\n"<br>+      "  br i1 %x, label %innerloop2, label %innerloop2exit\n"<br>+      "innerloop2exit:"<br>+      "  ;; In outer loop3 now.\n"<br>+      "  %z = call i1 @switch()\n"<br>+      "  br i1 %z, label %outerloop3, label %exit\n"<br>+      "exit:\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br>+<br>+TEST_F(IsPotentiallyReachableTest, BranchInsideLoop) {<br>+  ParseAssembly(<br>+      "declare i1 @switch()\n"<br>+      "\n"<br>+      "define void @test() {\n"<br>+      "entry:\n"<br>+      "  br label %loop\n"<br>+      "loop:\n"<br>+      "  %x = call i1 @switch()\n"<br>+      "  br i1 %x, label %nextloopblock, label %exit\n"<br>+      "nextloopblock:\n"<br>+      "  %y = call i1 @switch()\n"<br>+      "  br i1 %y, label %left, label %right\n"<br>+      "left:\n"<br>+      "  %A = bitcast i8 undef to i8\n"<br>+      "  br label %loop\n"<br>+      "right:\n"<br>+      "  %B = bitcast i8 undef to i8\n"<br>+      "  br label %loop\n"<br>+      "exit:\n"<br>+      "  ret void\n"<br>+      "}");<br>+  ExpectPath(true);<br>+}<br><br>Modified: llvm/trunk/unittests/Analysis/CMakeLists.txt<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/CMakeLists.txt?rev=187283&r1=187282&r2=187283&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/CMakeLists.txt?rev=187283&r1=187282&r2=187283&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Analysis/CMakeLists.txt (original)<br>+++ llvm/trunk/unittests/Analysis/CMakeLists.txt Fri Jul 26 20:24:00 2013<br>@@ -1,5 +1,6 @@<br>set(LLVM_LINK_COMPONENTS<br>  Analysis<br>+  AsmParser<br>  )<br><br>add_llvm_unittest(AnalysisTests<br><br>Modified: llvm/trunk/unittests/Analysis/Makefile<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/Makefile?rev=187283&r1=187282&r2=187283&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/Makefile?rev=187283&r1=187282&r2=187283&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Analysis/Makefile (original)<br>+++ llvm/trunk/unittests/Analysis/Makefile Fri Jul 26 20:24:00 2013<br>@@ -9,7 +9,7 @@<br><br>LEVEL = ../..<br>TESTNAME = Analysis<br>-LINK_COMPONENTS := analysis<br>+LINK_COMPONENTS := analysis asmparser<br><br>include $(LEVEL)/Makefile.config<br>include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></body></html>