[llvm-commits] [llvm] r134071 - in /llvm/trunk: include/llvm/BasicBlock.h lib/Transforms/Utils/Local.cpp lib/Transforms/Utils/SimplifyCFG.cpp lib/VMCore/BasicBlock.cpp test/Transforms/SimplifyCFG/lifetime.ll

Chad Rosier mcrosier at apple.com
Wed Jun 29 09:22:11 PDT 2011


Author: mcrosier
Date: Wed Jun 29 11:22:11 2011
New Revision: 134071

URL: http://llvm.org/viewvc/llvm-project?rev=134071&view=rev
Log:
Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and 
lifetime intrinsics" due to buildbot failures.

Removed:
    llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
Modified:
    llvm/trunk/include/llvm/BasicBlock.h
    llvm/trunk/lib/Transforms/Utils/Local.cpp
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/lib/VMCore/BasicBlock.cpp

Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=134071&r1=134070&r2=134071&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Wed Jun 29 11:22:11 2011
@@ -138,12 +138,6 @@
     return const_cast<BasicBlock*>(this)->getFirstNonPHIOrDbg();
   }
 
-  // Same as above, but also skip lifetime intrinsics.
-  Instruction* getFirstNonPHIOrDbgOrLifetime();
-  const Instruction* getFirstNonPHIOrDbgOrLifetime() const {
-    return const_cast<BasicBlock*>(this)->getFirstNonPHIOrDbgOrLifetime();
-  }
-
   /// removeFromParent - This method unlinks 'this' from the containing
   /// function, but does not delete it.
   ///

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=134071&r1=134070&r2=134071&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Jun 29 11:22:11 2011
@@ -536,9 +536,9 @@
 
 /// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
 /// unconditional branch, and contains no instructions other than PHI nodes,
-/// potential side-effect free intrinsics and the branch.  If possible,
-/// eliminate BB by rewriting all the predecessors to branch to the successor
-/// block and return true.  If we can't transform, return false.
+/// potential debug intrinsics and the branch.  If possible, eliminate BB by
+/// rewriting all the predecessors to branch to the successor block and return
+/// true.  If we can't transform, return false.
 bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB) {
   assert(BB != &BB->getParent()->getEntryBlock() &&
          "TryToSimplifyUncondBranchFromEmptyBlock called on entry block!");
@@ -613,15 +613,13 @@
     }
   }
   
-  if (Succ->getSinglePredecessor()) {
-    // BB is the only predecessor of Succ, so Succ will end up with exactly
-    // the same predecessors BB had.
-
-    // Copy over any phi, debug or lifetime instruction.
-    BB->getTerminator()->eraseFromParent();
-    Succ->getInstList().splice(Succ->begin(), BB->getInstList());
-  } else {
-    while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
+  while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
+    if (Succ->getSinglePredecessor()) {
+      // BB is the only predecessor of Succ, so Succ will end up with exactly
+      // the same predecessors BB had.
+      Succ->getInstList().splice(Succ->begin(),
+                                 BB->getInstList(), BB->begin());
+    } else {
       // We explicitly check for such uses in CanPropagatePredecessorsForPHIs.
       assert(PN->use_empty() && "There shouldn't be any uses here!");
       PN->eraseFromParent();

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=134071&r1=134070&r2=134071&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jun 29 11:22:11 2011
@@ -2604,7 +2604,7 @@
   BasicBlock *BB = BI->getParent();
   
   // If the Terminator is the only non-phi instruction, simplify the block.
-  BasicBlock::iterator I = BB->getFirstNonPHIOrDbgOrLifetime();
+  BasicBlock::iterator I = BB->getFirstNonPHIOrDbg();
   if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
       TryToSimplifyUncondBranchFromEmptyBlock(BB))
     return true;

Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=134071&r1=134070&r2=134071&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/trunk/lib/VMCore/BasicBlock.cpp Wed Jun 29 11:22:11 2011
@@ -147,26 +147,6 @@
   return &*i;
 }
 
-Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
-  // All valid basic blocks should have a terminator,
-  // which is not a PHINode. If we have an invalid basic
-  // block we'll get an assertion failure when dereferencing
-  // a past-the-end iterator.
-  BasicBlock::iterator i = begin();
-  for (;; ++i) {
-    if (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i))
-      continue;
-
-    const IntrinsicInst *II = dyn_cast<IntrinsicInst>(i);
-    if (!II)
-      break;
-    if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
-        II->getIntrinsicID() != Intrinsic::lifetime_end)
-      break;
-  }
-  return &*i;
-}
-
 void BasicBlock::dropAllReferences() {
   for(iterator I = begin(), E = end(); I != E; ++I)
     I->dropAllReferences();

Removed: llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll?rev=134070&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll (removed)
@@ -1,29 +0,0 @@
-; RUN: opt < %s -simplifycfg -S | FileCheck %s
-
-; Test that a lifetime intrinsic doesn't prevent us from simplifying this.
-
-; CHECK: foo
-; CHECK: entry:
-; CHECK-NOT: bb0:
-; CHECK-NOT: bb1:
-; CHECK: ret
-define void @foo(i1 %x) {
-entry:
-  %a = alloca i8
-  call void @llvm.lifetime.start(i64 -1, i8* %a) nounwind
-  br i1 %x, label %bb0, label %bb1
-
-bb0:
-  call void @llvm.lifetime.end(i64 -1, i8* %a) nounwind
-  br label %bb1
-
-bb1:
-  call void @f()
-  ret void
-}
-
-declare void @f()
-
-declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
-
-declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind





More information about the llvm-commits mailing list