[llvm-branch-commits] [llvm-branch] r195606 - Merging r195493:

Bill Wendling isanbard at gmail.com
Sun Nov 24 21:23:10 PST 2013


Author: void
Date: Sun Nov 24 23:23:10 2013
New Revision: 195606

URL: http://llvm.org/viewvc/llvm-project?rev=195606&view=rev
Log:
Merging r195493:
------------------------------------------------------------------------
r195493 | arsenm | 2013-11-22 11:24:39 -0800 (Fri, 22 Nov 2013) | 6 lines

StructurizeCFG: Fix verification failure with some loops.

If the beginning of the loop was also the entry block
of the function, branches were inserted to the entry block
which isn't allowed. If this occurs, create a new dummy
function entry block that branches to the start of the loop.
------------------------------------------------------------------------

Added:
    llvm/branches/release_34/test/Transforms/StructurizeCFG/no-branch-to-entry.ll
      - copied unchanged from r195493, llvm/trunk/test/Transforms/StructurizeCFG/no-branch-to-entry.ll
Modified:
    llvm/branches/release_34/   (props changed)
    llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp

Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 24 23:23:10 2013
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355,195397-195399,195421,195423,195432,195439,195476-195477,195491-195492,195567,195599
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355,195397-195399,195421,195423,195432,195439,195476-195477,195491-195493,195567,195599

Modified: llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp?rev=195606&r1=195605&r2=195606&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp (original)
+++ llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp Sun Nov 24 23:23:10 2013
@@ -779,6 +779,20 @@ void StructurizeCFG::handleLoops(bool Ex
     handleLoops(false, LoopEnd);
   }
 
+  // If the start of the loop is the entry block, we can't branch to it so
+  // insert a new dummy entry block.
+  Function *LoopFunc = LoopStart->getParent();
+  if (LoopStart == &LoopFunc->getEntryBlock()) {
+    LoopStart->setName("entry.orig");
+
+    BasicBlock *NewEntry =
+      BasicBlock::Create(LoopStart->getContext(),
+                         "entry",
+                         LoopFunc,
+                         LoopStart);
+    BranchInst::Create(LoopStart, NewEntry);
+  }
+
   // Create an extra loop end node
   LoopEnd = needPrefix(false);
   BasicBlock *Next = needPostfix(LoopEnd, ExitUseAllowed);





More information about the llvm-branch-commits mailing list