[llvm-branch-commits] [llvm-branch] r89486 - in /llvm/branches/Apple/Zoidberg: include/llvm/Analysis/LoopInfo.h lib/Transforms/Scalar/SCCP.cpp lib/Transforms/Utils/LoopSimplify.cpp test/Transforms/IPConstantProp/dangling-block-address.ll test/Transforms/LoopRotate/indirectbr.ll test/Transforms/LoopSimplify/indirectbr.ll

Dan Gohman gohman at apple.com
Fri Nov 20 12:58:50 PST 2009


Author: djg
Date: Fri Nov 20 14:58:50 2009
New Revision: 89486

URL: http://llvm.org/viewvc/llvm-project?rev=89486&view=rev
Log:
$ svn merge -c 89483 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89483 into '.':
A    test/Transforms/IPConstantProp/dangling-block-address.ll
U    lib/Transforms/Scalar/SCCP.cpp
$ svn merge -c 89484 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89484 into '.':
U    test/Transforms/LoopSimplify/indirectbr.ll
A    test/Transforms/LoopRotate/indirectbr.ll
U    include/llvm/Analysis/LoopInfo.h
U    lib/Transforms/Utils/LoopSimplify.cpp

Added:
    llvm/branches/Apple/Zoidberg/test/Transforms/IPConstantProp/dangling-block-address.ll
      - copied unchanged from r89483, llvm/trunk/test/Transforms/IPConstantProp/dangling-block-address.ll
    llvm/branches/Apple/Zoidberg/test/Transforms/LoopRotate/indirectbr.ll
      - copied unchanged from r89484, llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll
Modified:
    llvm/branches/Apple/Zoidberg/include/llvm/Analysis/LoopInfo.h
    llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/SCCP.cpp
    llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/branches/Apple/Zoidberg/test/Transforms/LoopSimplify/indirectbr.ll

Modified: llvm/branches/Apple/Zoidberg/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Analysis/LoopInfo.h?rev=89486&r1=89485&r2=89486&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Analysis/LoopInfo.h Fri Nov 20 14:58:50 2009
@@ -269,8 +269,6 @@
 
   /// getLoopLatch - If there is a single latch block for this loop, return it.
   /// A latch block is a block that contains a branch back to the header.
-  /// A loop header in normal form has two edges into it: one from a preheader
-  /// and one from a latch block.
   BlockT *getLoopLatch() const {
     BlockT *Header = getHeader();
     typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits;
@@ -278,20 +276,12 @@
                                             InvBlockTraits::child_begin(Header);
     typename InvBlockTraits::ChildIteratorType PE =
                                               InvBlockTraits::child_end(Header);
-    if (PI == PE) return 0;  // no preds?
-
     BlockT *Latch = 0;
-    if (contains(*PI))
-      Latch = *PI;
-    ++PI;
-    if (PI == PE) return 0;  // only one pred?
-
-    if (contains(*PI)) {
-      if (Latch) return 0;  // multiple backedges
-      Latch = *PI;
-    }
-    ++PI;
-    if (PI != PE) return 0;  // more than two preds
+    for (; PI != PE; ++PI)
+      if (contains(*PI)) {
+        if (Latch) return 0;
+        Latch = *PI;
+      }
 
     return Latch;
   }

Modified: llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/SCCP.cpp?rev=89486&r1=89485&r2=89486&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/SCCP.cpp Fri Nov 20 14:58:50 2009
@@ -1869,8 +1869,12 @@
     for (unsigned i = 0, e = BlocksToErase.size(); i != e; ++i) {
       // If there are any PHI nodes in this successor, drop entries for BB now.
       BasicBlock *DeadBB = BlocksToErase[i];
-      while (!DeadBB->use_empty()) {
-        Instruction *I = cast<Instruction>(DeadBB->use_back());
+      for (Value::use_iterator UI = DeadBB->use_begin(), UE = DeadBB->use_end();
+           UI != UE; ) {
+        // Ignore blockaddress users; BasicBlock's dtor will handle them.
+        Instruction *I = dyn_cast<Instruction>(*UI++);
+        if (!I) continue;
+
         bool Folded = ConstantFoldTerminator(I->getParent());
         if (!Folded) {
           // The constant folder may not have been able to fold the terminator

Modified: llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp?rev=89486&r1=89485&r2=89486&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp Fri Nov 20 14:58:50 2009
@@ -477,8 +477,13 @@
   SmallVector<BasicBlock*, 8> OuterLoopPreds;
   for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
     if (PN->getIncomingValue(i) != PN ||
-        !L->contains(PN->getIncomingBlock(i)))
+        !L->contains(PN->getIncomingBlock(i))) {
+      // We can't split indirectbr edges.
+      if (isa<IndirectBrInst>(PN->getIncomingBlock(i)->getTerminator()))
+        return 0;
+
       OuterLoopPreds.push_back(PN->getIncomingBlock(i));
+    }
 
   BasicBlock *Header = L->getHeader();
   BasicBlock *NewBB = SplitBlockPredecessors(Header, &OuterLoopPreds[0],

Modified: llvm/branches/Apple/Zoidberg/test/Transforms/LoopSimplify/indirectbr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/Transforms/LoopSimplify/indirectbr.ll?rev=89486&r1=89485&r2=89486&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/Transforms/LoopSimplify/indirectbr.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/Transforms/LoopSimplify/indirectbr.ll Fri Nov 20 14:58:50 2009
@@ -81,3 +81,20 @@
   %y = phi i64 [ %z, %L0 ], [ 1, %entry ]
   ret i64 %y
 }
+
+define void @pr5502() nounwind {
+entry:
+  br label %while.cond
+
+while.cond:
+  br i1 undef, label %while.body, label %while.end
+
+while.body:
+  indirectbr i8* undef, [label %end_opcode, label %end_opcode]
+
+end_opcode:
+  br i1 false, label %end_opcode, label %while.cond
+
+while.end:
+  ret void
+}





More information about the llvm-branch-commits mailing list