[CodeGen][TargetPassConfig] Add unreachable-mbb-elimination pass explicitly
authorEvgeny Leviant <eleviant@accesssoftek.com>
Thu, 23 Jul 2020 15:05:11 +0000 (18:05 +0300)
committerEvgeny Leviant <eleviant@accesssoftek.com>
Thu, 23 Jul 2020 15:05:11 +0000 (18:05 +0300)
Differential revision: https://reviews.llvm.org/D84228

llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/AArch64/partial-pipeline-execution.ll

index 856e1200f43635b6e0a661c16a2ab7a172b76e22..64511940249cab09a4187c86aa945a214aadff26 100644 (file)
@@ -1183,6 +1183,11 @@ void TargetPassConfig::addOptimizedRegAlloc() {
   // LiveVariables can be removed completely, and LiveIntervals can be directly
   // computed. (We still either need to regenerate kill flags after regalloc, or
   // preferably fix the scavenger to not depend on them).
+  // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
+  // When LiveVariables is removed this has to be removed/moved either.
+  // Explicit addition of UnreachableMachineBlockElim allows stopping before or
+  // after it with -stop-before/-stop-after.
+  addPass(&UnreachableMachineBlockElimID, false);
   addPass(&LiveVariablesID, false);
 
   // Edge splitting is smarter with machine loop info.
index 82cb0a35f2a58b2d32d82607f7d36ef3fe726bf8..067da9123fab89c1f84cdfaa2acfc346f99add03 100644 (file)
@@ -7,6 +7,11 @@
 ; optimize the loop differently
 ; RUN: cmp %t.s %t2.s
 
+; Check that we can do the same with unreachable-mbb-elimination pass
+; RUN: llc -O3 -stop-after=unreachable-mbb-elimination %s -o %t-mbb-elim.mir
+; RUN: llc -O3 -start-after=unreachable-mbb-elimination %t-mbb-elim.mir -o %t3.s
+; RUN: cmp %t.s %t3.s
+
 ; ModuleID = 'loop.c'
 source_filename = "loop.c"
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"