[llvm-commits] [llvm] r63912 - in /llvm/branches/Apple/Dib: lib/Transforms/Scalar/CondPropagate.cpp lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/CondProp/basictest-dbg.ll test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll test/Transforms/SimplifyCFG/branch_fold_dbg.ll test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll test/Transforms/SimplifyCFG/switch_formation.dbg.ll test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll

Bill Wendling isanbard at gmail.com
Thu Feb 5 18:14:16 PST 2009


Author: void
Date: Thu Feb  5 20:14:15 2009
New Revision: 63912

URL: http://llvm.org/viewvc/llvm-project?rev=63912&view=rev
Log:
Pull revs 63671, 63687, 63700, 63781, 63802, and 63898 into Dib.

Added:
    llvm/branches/Apple/Dib/test/Transforms/CondProp/basictest-dbg.ll
    llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll
    llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/branch_fold_dbg.ll
    llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll
    llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/switch_formation.dbg.ll
    llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll
Modified:
    llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp
    llvm/branches/Apple/Dib/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp?rev=63912&r1=63911&r2=63912&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp Thu Feb  5 20:14:15 2009
@@ -17,6 +17,7 @@
 #include "llvm/Constants.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Pass.h"
 #include "llvm/Type.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -123,8 +124,8 @@
 // jump directly to the destination instead of going through this block.
 void CondProp::SimplifyPredecessors(BranchInst *BI) {
   // TODO: We currently only handle the most trival case, where the PHI node has
-  // one use (the branch), and is the only instruction besides the branch in the
-  // block.
+  // one use (the branch), and is the only instruction besides the branch and dbg
+  // intrinsics in the block.
   PHINode *PN = cast<PHINode>(BI->getCondition());
 
   if (PN->getNumIncomingValues() == 1) {
@@ -137,7 +138,12 @@
   if (!PN->hasOneUse()) return;
 
   BasicBlock *BB = BI->getParent();
-  if (&*BB->begin() != PN || &*next(BB->begin()) != BI)
+  if (&*BB->begin() != PN)
+    return;
+  BasicBlock::iterator BBI = BB->begin();
+  BasicBlock::iterator BBE = BB->end();
+  while (BBI != BBE && isa<DbgInfoIntrinsic>(++BBI));
+  if (&*BBI != BI)
     return;
 
   // Ok, we have this really simple case, walk the PHI operands, looking for
@@ -165,13 +171,18 @@
 // the destination instead of going through this block.
 void CondProp::SimplifyPredecessors(SwitchInst *SI) {
   // TODO: We currently only handle the most trival case, where the PHI node has
-  // one use (the branch), and is the only instruction besides the branch in the
-  // block.
+  // one use (the branch), and is the only instruction besides the branch and 
+  // dbg intrinsics in the block.
   PHINode *PN = cast<PHINode>(SI->getCondition());
   if (!PN->hasOneUse()) return;
 
   BasicBlock *BB = SI->getParent();
-  if (&*BB->begin() != PN || &*next(BB->begin()) != SI)
+  if (&*BB->begin() != PN)
+    return;
+  BasicBlock::iterator BBI = BB->begin();
+  BasicBlock::iterator BBE = BB->end();
+  while (BBI != BBE && isa<DbgInfoIntrinsic>(++BBI));
+  if (&*BBI != SI)
     return;
 
   bool RemovedPreds = false;

Modified: llvm/branches/Apple/Dib/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/Utils/SimplifyCFG.cpp?rev=63912&r1=63911&r2=63912&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/Utils/SimplifyCFG.cpp Thu Feb  5 20:14:15 2009
@@ -15,6 +15,7 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Type.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/CFG.h"
@@ -852,7 +853,14 @@
   BasicBlock *BB1 = BI->getSuccessor(0);  // The true destination.
   BasicBlock *BB2 = BI->getSuccessor(1);  // The false destination
 
-  Instruction *I1 = BB1->begin(), *I2 = BB2->begin();
+  BasicBlock::iterator BB1_Itr = BB1->begin();
+  BasicBlock::iterator BB2_Itr = BB2->begin();
+
+  Instruction *I1 = BB1_Itr++, *I2 = BB2_Itr++;
+  while (isa<DbgInfoIntrinsic>(I1))
+    I1 = BB1_Itr++;
+  while (isa<DbgInfoIntrinsic>(I2))
+    I2 = BB2_Itr++;
   if (I1->getOpcode() != I2->getOpcode() || isa<PHINode>(I1) || 
       isa<InvokeInst>(I1) || !I1->isIdenticalTo(I2))
     return false;
@@ -874,8 +882,12 @@
       I2->replaceAllUsesWith(I1);
     BB2->getInstList().erase(I2);
 
-    I1 = BB1->begin();
-    I2 = BB2->begin();
+    I1 = BB1_Itr++;
+    while (isa<DbgInfoIntrinsic>(I1))
+      I1 = BB1_Itr++;
+    I2 = BB2_Itr++;
+    while (isa<DbgInfoIntrinsic>(I2))
+      I2 = BB2_Itr++;
   } while (I1->getOpcode() == I2->getOpcode() && I1->isIdenticalTo(I2));
 
   return true;
@@ -1262,7 +1274,7 @@
     DomBlock = *pred_begin(Pred);
     for (BasicBlock::iterator I = Pred->begin();
          !isa<TerminatorInst>(I); ++I)
-      if (!AggressiveInsts.count(I)) {
+      if (!AggressiveInsts.count(I) && !isa<DbgInfoIntrinsic>(I)) {
         // This is not an aggressive instruction that we can promote.
         // Because of this, we won't be able to get rid of the control
         // flow, so the xform is not worth it.
@@ -1276,7 +1288,7 @@
     DomBlock = *pred_begin(Pred);
     for (BasicBlock::iterator I = Pred->begin();
          !isa<TerminatorInst>(I); ++I)
-      if (!AggressiveInsts.count(I)) {
+      if (!AggressiveInsts.count(I) && !isa<DbgInfoIntrinsic>(I)) {
         // This is not an aggressive instruction that we can promote.
         // Because of this, we won't be able to get rid of the control
         // flow, so the xform is not worth it.
@@ -1318,6 +1330,20 @@
   return true;
 }
 
+/// isTerminatorFirstRelevantInsn - Return true if Term is very first 
+/// instruction ignoring Phi nodes and dbg intrinsics.
+static bool isTerminatorFirstRelevantInsn(BasicBlock *BB, Instruction *Term) {
+  BasicBlock::iterator BBI = Term;
+  while (BBI != BB->begin()) {
+    --BBI;
+    if (!isa<DbgInfoIntrinsic>(BBI))
+      break;
+  }
+  if (isa<PHINode>(BBI) || &*BBI == Term)
+    return true;
+  return false;
+}
+
 /// SimplifyCondBranchToTwoReturns - If we found a conditional branch that goes
 /// to two returning blocks, try to merge them together into one return,
 /// introducing a select if the return values disagree.
@@ -1331,12 +1357,10 @@
   // Check to ensure both blocks are empty (just a return) or optionally empty
   // with PHI nodes.  If there are other instructions, merging would cause extra
   // computation on one path or the other.
-  BasicBlock::iterator BBI = TrueRet;
-  if (BBI != TrueSucc->begin() && !isa<PHINode>(--BBI))
-    return false;  // Not empty with optional phi nodes.
-  BBI = FalseRet;
-  if (BBI != FalseSucc->begin() && !isa<PHINode>(--BBI))
-    return false;  // Not empty with optional phi nodes.
+  if (!isTerminatorFirstRelevantInsn(TrueSucc, TrueRet))
+    return false;
+  if (!isTerminatorFirstRelevantInsn(FalseSucc, FalseRet))
+    return false;
 
   // Okay, we found a branch that is going to two return nodes.  If
   // there is no return value for this function, just change the
@@ -1418,14 +1442,24 @@
   // Only allow this if the condition is a simple instruction that can be
   // executed unconditionally.  It must be in the same block as the branch, and
   // must be at the front of the block.
+  BasicBlock::iterator FrontIt = BB->front();
+  // Ignore dbg intrinsics.
+  while(isa<DbgInfoIntrinsic>(FrontIt))
+    ++FrontIt;
   if ((!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) ||
-      Cond->getParent() != BB || &BB->front() != Cond || !Cond->hasOneUse())
+      Cond->getParent() != BB || &*FrontIt != Cond || !Cond->hasOneUse()) {
     return false;
+  }
   
   // Make sure the instruction after the condition is the cond branch.
   BasicBlock::iterator CondIt = Cond; ++CondIt;
-  if (&*CondIt != BI)
+  // Ingore dbg intrinsics.
+  while(isa<DbgInfoIntrinsic>(CondIt))
+    ++CondIt;
+  if (&*CondIt != BI) {
+    assert (!isa<DbgInfoIntrinsic>(CondIt) && "Hey do not forget debug info!");
     return false;
+  }
 
   // Cond is known to be a compare or binary operator.  Check to make sure that
   // neither operand is a potentially-trapping constant expression.
@@ -1728,8 +1762,7 @@
   // different return values, fold the replace the branch/return with a select
   // and return.
   if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
-    BasicBlock::iterator BBI = BB->getTerminator();
-    if (BBI == BB->begin() || isa<PHINode>(--BBI)) {
+    if (isTerminatorFirstRelevantInsn(BB, BB->getTerminator())) {
       // Find predecessors that end with branches.
       SmallVector<BasicBlock*, 8> UncondBranchPreds;
       SmallVector<BranchInst*, 8> CondBranchPreds;
@@ -1855,6 +1888,9 @@
       BasicBlock::iterator BBI = BB->getFirstNonPHI();
 
       BasicBlock *Succ = BI->getSuccessor(0);
+      // Ignore dbg intrinsics.
+      while (isa<DbgInfoIntrinsic>(BBI))
+        ++BBI;
       if (BBI->isTerminator() &&  // Terminator is the only non-phi instruction!
           Succ != BB)             // Don't hurt infinite loops!
         if (TryToSimplifyUncondBranchFromEmptyBlock(BB, Succ))
@@ -1870,14 +1906,26 @@
             return SimplifyCFG(BB) || 1;
 
         // This block must be empty, except for the setcond inst, if it exists.
+        // Ignore dbg intrinsics.
         BasicBlock::iterator I = BB->begin();
-        if (&*I == BI ||
-            (&*I == cast<Instruction>(BI->getCondition()) &&
-             &*++I == BI))
+        // Ignore dbg intrinsics.
+        while (isa<DbgInfoIntrinsic>(I))
+          ++I;
+        if (&*I == BI) {
           if (FoldValueComparisonIntoPredecessors(BI))
             return SimplifyCFG(BB) | true;
+        } else if (&*I == cast<Instruction>(BI->getCondition())){
+          ++I;
+          // Ignore dbg intrinsics.
+          while (isa<DbgInfoIntrinsic>(I))
+            ++I;
+          if(&*I == BI) {
+            if (FoldValueComparisonIntoPredecessors(BI))
+              return SimplifyCFG(BB) | true;
+          }
+        }
       }
-      
+
       // If this is a branch on a phi node in the current block, thread control
       // through this block if any PHI node entries are constants.
       if (PHINode *PN = dyn_cast<PHINode>(BI->getCondition()))

Added: llvm/branches/Apple/Dib/test/Transforms/CondProp/basictest-dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/CondProp/basictest-dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/CondProp/basictest-dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/CondProp/basictest-dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,45 @@
+; RUN: llvm-as < %s | opt -condprop | llvm-dis | \
+; RUN:    not grep {br label}
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+
+define i32 @test(i1 %C) {
+        br i1 %C, label %T1, label %F1
+
+T1:             ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        br label %Cont
+
+F1:             ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        br label %Cont
+
+Cont:           ; preds = %F1, %T1
+        %C2 = phi i1 [ false, %F1 ], [ true, %T1 ]              ; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        br i1 %C2, label %T2, label %F2
+
+T2:             ; preds = %Cont
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        call void @bar( )
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 17
+
+F2:             ; preds = %Cont
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 1
+}
+
+declare void @bar()
+

Added: llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,58 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \
+; RUN:   not grep switch
+
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+; Test folding all to same dest
+define i32 @test3(i1 %C) {
+        br i1 %C, label %Start, label %TheDest
+Start:          ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        switch i32 3, label %TheDest [
+                 i32 0, label %TheDest
+                 i32 1, label %TheDest
+                 i32 2, label %TheDest
+                 i32 5, label %TheDest
+        ]
+TheDest:                ; preds = %Start, %Start, %Start, %Start, %Start, %0
+        ret i32 1234
+}
+
+; Test folding switch -> branch
+define i32 @test4(i32 %C) {
+        switch i32 %C, label %L1 [
+                 i32 0, label %L2
+        ]
+L1:             ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 0
+L2:             ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 1
+}
+
+; Can fold into a cond branch!
+define i32 @test5(i32 %C) {
+        switch i32 %C, label %L1 [
+                 i32 0, label %L2
+                 i32 123, label %L1
+        ]
+L1:             ; preds = %0, %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 0
+L2:             ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        ret i32 1
+}
+

Added: llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/branch_fold_dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/branch_fold_dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/branch_fold_dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/branch_fold_dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,122 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep br
+; END.
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+
+define void @main() {
+entry:
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.14.i19 = icmp eq i32 0, 2		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.14.i19, label %endif.1.i20, label %read_min.exit
+endif.1.i20:		; preds = %entry
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.9.i.i = icmp eq i8* null, null		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.9.i.i, label %then.i12.i, label %then.i.i
+then.i.i:		; preds = %endif.1.i20
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+then.i12.i:		; preds = %endif.1.i20
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.9.i4.i = icmp eq i8* null, null		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.9.i4.i, label %endif.2.i33, label %then.i5.i
+then.i5.i:		; preds = %then.i12.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+endif.2.i33:		; preds = %then.i12.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %loopexit.0.i40, label %no_exit.0.i35
+no_exit.0.i35:		; preds = %no_exit.0.i35, %endif.2.i33
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.130.i = icmp slt i32 0, 0		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.130.i, label %loopexit.0.i40.loopexit, label %no_exit.0.i35
+loopexit.0.i40.loopexit:		; preds = %no_exit.0.i35
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br label %loopexit.0.i40
+loopexit.0.i40:		; preds = %loopexit.0.i40.loopexit, %endif.2.i33
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.341.i = icmp eq i32 0, 0		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.341.i, label %loopentry.1.i, label %read_min.exit
+loopentry.1.i:		; preds = %loopexit.0.i40
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.347.i = icmp sgt i32 0, 0		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.347.i, label %no_exit.1.i41, label %loopexit.2.i44
+no_exit.1.i41:		; preds = %endif.5.i, %loopentry.1.i
+	%indvar.i42 = phi i32 [ %indvar.next.i, %endif.5.i ], [ 0, %loopentry.1.i ]		; <i32> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.355.i = icmp eq i32 0, 3		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.355.i, label %endif.5.i, label %read_min.exit
+endif.5.i:		; preds = %no_exit.1.i41
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.34773.i = icmp sgt i32 0, 0		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%indvar.next.i = add i32 %indvar.i42, 1		; <i32> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.34773.i, label %no_exit.1.i41, label %loopexit.1.i.loopexit
+loopexit.1.i.loopexit:		; preds = %endif.5.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+loopexit.2.i44:		; preds = %loopentry.1.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+read_min.exit:		; preds = %no_exit.1.i41, %loopexit.0.i40, %entry
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.23 = icmp eq i32 0, 0		; <i1> [#uses=1]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 %tmp.23, label %endif.1, label %then.1
+then.1:		; preds = %read_min.exit
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %endif.0.i, label %then.0.i
+then.0.i:		; preds = %then.1
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %endif.1.i, label %then.1.i
+endif.0.i:		; preds = %then.1
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %endif.1.i, label %then.1.i
+then.1.i:		; preds = %endif.0.i, %then.0.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %getfree.exit, label %then.2.i
+endif.1.i:		; preds = %endif.0.i, %then.0.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %getfree.exit, label %then.2.i
+then.2.i:		; preds = %endif.1.i, %then.1.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+getfree.exit:		; preds = %endif.1.i, %then.1.i
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+endif.1:		; preds = %read_min.exit
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	%tmp.27.i = getelementptr i32* null, i32 0		; <i32*> [#uses=0]
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %loopexit.0.i15, label %no_exit.0.i14
+no_exit.0.i14:		; preds = %endif.1
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+loopexit.0.i15:		; preds = %endif.1
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16
+no_exit.1.i16:		; preds = %no_exit.1.i16, %loopexit.0.i15
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16
+primal_start_artificial.exit:		; preds = %no_exit.1.i16, %loopexit.0.i15
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+	ret void
+}

Added: llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,33 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep br
+
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+declare void @bar(i32)
+
+define void @test(i1 %P, i32* %Q) {
+        br i1 %P, label %T, label %F
+T:              ; preds = %0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        store i32 1, i32* %Q
+        %A = load i32* %Q               ; <i32> [#uses=1]
+        call void @bar( i32 %A )
+        ret void
+F:              ; preds = %0
+        store i32 1, i32* %Q
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %B = load i32* %Q               ; <i32> [#uses=1]
+        call void @bar( i32 %B )
+        ret void
+}
+

Added: llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/switch_formation.dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/switch_formation.dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/switch_formation.dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/switch_formation.dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,49 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep br
+; END.
+
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+define i1 @_ZN4llvm11SetCondInst7classofEPKNS_11InstructionE({ i32, i32 }* %I) {
+entry:
+        %tmp.1.i = getelementptr { i32, i32 }* %I, i64 0, i32 1         ; <i32*> [#uses=1]
+        %tmp.2.i = load i32* %tmp.1.i           ; <i32> [#uses=6]
+        %tmp.2 = icmp eq i32 %tmp.2.i, 14               ; <i1> [#uses=1]
+        br i1 %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0
+shortcirc_next.0:               ; preds = %entry
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp.6 = icmp eq i32 %tmp.2.i, 15               ; <i1> [#uses=1]
+        br i1 %tmp.6, label %shortcirc_done.4, label %shortcirc_next.1
+shortcirc_next.1:               ; preds = %shortcirc_next.0
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp.11 = icmp eq i32 %tmp.2.i, 16              ; <i1> [#uses=1]
+        br i1 %tmp.11, label %shortcirc_done.4, label %shortcirc_next.2
+shortcirc_next.2:               ; preds = %shortcirc_next.1
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp.16 = icmp eq i32 %tmp.2.i, 17              ; <i1> [#uses=1]
+        br i1 %tmp.16, label %shortcirc_done.4, label %shortcirc_next.3
+shortcirc_next.3:               ; preds = %shortcirc_next.2
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp.21 = icmp eq i32 %tmp.2.i, 18              ; <i1> [#uses=1]
+        br i1 %tmp.21, label %shortcirc_done.4, label %shortcirc_next.4
+shortcirc_next.4:               ; preds = %shortcirc_next.3
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp.26 = icmp eq i32 %tmp.2.i, 19              ; <i1> [#uses=1]
+        br label %UnifiedReturnBlock
+shortcirc_done.4:               ; preds = %shortcirc_next.3, %shortcirc_next.2, %shortcirc_next.1, %shortcirc_next.0, %entry
+        br label %UnifiedReturnBlock
+UnifiedReturnBlock:             ; preds = %shortcirc_done.4, %shortcirc_next.4
+        %UnifiedRetVal = phi i1 [ %tmp.26, %shortcirc_next.4 ], [ true, %shortcirc_done.4 ]             ; <i1> [#uses=1]
+        ret i1 %UnifiedRetVal
+}
+

Added: llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll?rev=63912&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll Thu Feb  5 20:14:15 2009
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep br
+
+        %llvm.dbg.anchor.type = type { i32, i32 }
+        %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
+
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata"		; 
+
+ at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
+ at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata"	; <[6 x i8]*> [#uses=1]
+ at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata"		; <[55 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata"		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
+
+define i1 @qux(i8* %m, i8* %n, i8* %o, i8* %p) nounwind  {
+entry:
+        %tmp7 = icmp eq i8* %m, %n
+        br i1 %tmp7, label %bb, label %UnifiedReturnBlock
+
+bb:
+call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
+        %tmp15 = icmp eq i8* %o, %p
+        br label %UnifiedReturnBlock
+
+UnifiedReturnBlock:
+        %result = phi i1 [ 0, %entry ], [ %tmp15, %bb ]
+        ret i1 %result
+}





More information about the llvm-commits mailing list