Revert "Simplify blockaddress usage before giving up in MergeBlockIntoPredecessor"
authorXin Tong <trent.xin.tong@gmail.com>
Mon, 18 Jun 2018 23:20:08 +0000 (23:20 +0000)
committerXin Tong <trent.xin.tong@gmail.com>
Mon, 18 Jun 2018 23:20:08 +0000 (23:20 +0000)
This reverts commit f976cf4cca0794267f28b54e468007fd476d37d9.

I am reverting this because it causes break in a few bots and its going
to take me sometime to look at this.

llvm-svn: 334993

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
llvm/unittests/Transforms/Utils/BasicBlockUtils.cpp

index 4b89b04..5983704 100644 (file)
@@ -119,14 +119,7 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DominatorTree *DT,
                                      LoopInfo *LI,
                                      MemoryDependenceResults *MemDep) {
   // Don't merge away blocks who have their address taken.
-  if (BB->hasAddressTaken()) {
-    // If the block has its address taken, it may be a tree of dead constants
-    // hanging off of it.  These shouldn't keep the block alive.
-    BlockAddress *BA = BlockAddress::get(BB);
-    BA->removeDeadConstantUsers();
-    if (!BA->use_empty())
-      return false;
-  }
+  if (BB->hasAddressTaken()) return false;
 
   // Can't merge if there are multiple predecessors, or no predecessors.
   BasicBlock *PredBB = BB->getUniquePredecessor();
index a15cdd6..036a615 100644 (file)
@@ -37,7 +37,10 @@ define void @test_indirectbr(i32 %x) {
 entry:
 ; CHECK-LABEL: @test_indirectbr(
 ; CHECK-NEXT: entry:
-; CHECK-NEXT: ret void
+; Ideally this should now check:
+;   CHK-NEXT: ret void
+; But that doesn't happen yet. Instead:
+; CHECK-NEXT: br label %L1
 
   %label = bitcast i8* blockaddress(@test_indirectbr, %L1) to i8*
   indirectbr i8* %label, [label %L1, label %L2]
index 590e7f6..2d0a930 100644 (file)
@@ -50,31 +50,3 @@ TEST(BasicBlockUtils, SplitBlockPredecessors) {
   SplitBlockPredecessors(&F->getEntryBlock(), {}, "split.entry", &DT);
   EXPECT_TRUE(DT.verify());
 }
-
-TEST(BasicBlockUtils, MergeBlockIntoPredecessor) {
-  LLVMContext C;
-  std::unique_ptr<Module> M = parseIR(C,
-                                      R"(
-
-      define i32 @f(i8* %str) {
-      entry:
-        %dead = extractvalue [1 x i8*] [ i8* blockaddress(@f, %L0) ], 0
-        br label %L0
-      L0:
-        ret i32 0
-      }
-      )");
-
-  // First remove the dead instruction to empty the usage of the constant
-  // containing blockaddress(@f, %L0)
-  Function *F = M->getFunction("f");
-  auto BBI = F->begin();
-  Instruction *DI = &*((*BBI).begin());
-  EXPECT_TRUE(DI->use_empty());
-  DI->eraseFromParent();
-
-  // Get L0 and make sure that it can be merged into entry block.
-  ++BBI;
-  BasicBlock *BB = &(*BBI);
-  EXPECT_TRUE(MergeBlockIntoPredecessor(BB));
-}