[llvm] f4f7df0 - [DIE] Remove DeadInstEliminationPass

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 12:12:34 PDT 2020


Author: Arthur Eubanks
Date: 2020-09-21T12:12:25-07:00
New Revision: f4f7df037e71fa77b06a37d86f2596db47d583d0

URL: https://github.com/llvm/llvm-project/commit/f4f7df037e71fa77b06a37d86f2596db47d583d0
DIFF: https://github.com/llvm/llvm-project/commit/f4f7df037e71fa77b06a37d86f2596db47d583d0.diff

LOG: [DIE] Remove DeadInstEliminationPass

This pass is like DeadCodeEliminationPass, but only does one pass
through a function instead of iterating on users of eliminated
instructions.

DeadCodeEliminationPass should be used in all cases.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D87933

Added: 
    

Modified: 
    llvm/include/llvm/InitializePasses.h
    llvm/include/llvm/LinkAllPasses.h
    llvm/include/llvm/Transforms/Scalar.h
    llvm/lib/Transforms/Scalar/DCE.cpp
    llvm/lib/Transforms/Scalar/Scalar.cpp
    llvm/test/Feature/optnone-opt.ll
    llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
    llvm/test/Transforms/DeadArgElim/deadretval2.ll
    llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll
    llvm/test/Transforms/GVN/PRE/rle.ll
    llvm/test/Transforms/InstCombine/deadcode.ll
    llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll
    llvm/test/Transforms/InstSimplify/ConstProp/basictest.ll
    llvm/test/Transforms/InstSimplify/ConstProp/logicaltest.ll
    llvm/test/Transforms/InstSimplify/ConstProp/phi.ll
    llvm/test/Transforms/InstSimplify/ConstProp/remtest.ll
    llvm/test/Transforms/NewGVN/rle.ll
    llvm/test/Transforms/Reassociate/inverses.ll
    llvm/test/Transforms/Reassociate/otherops.ll
    llvm/test/Transforms/Reassociate/vaarg_movable.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 06dd5b19c74b..62b49906ab3f 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -123,7 +123,6 @@ void initializeDAHPass(PassRegistry&);
 void initializeDCELegacyPassPass(PassRegistry&);
 void initializeDSELegacyPassPass(PassRegistry&);
 void initializeDataFlowSanitizerLegacyPassPass(PassRegistry &);
-void initializeDeadInstEliminationPass(PassRegistry&);
 void initializeDeadMachineInstructionElimPass(PassRegistry&);
 void initializeDebugifyMachineModulePass(PassRegistry &);
 void initializeDelinearizationPass(PassRegistry&);

diff  --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 59284eecfbc7..157311a76b3d 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -93,7 +93,6 @@ namespace {
       (void) llvm::createCostModelAnalysisPass();
       (void) llvm::createDeadArgEliminationPass();
       (void) llvm::createDeadCodeEliminationPass();
-      (void) llvm::createDeadInstEliminationPass();
       (void) llvm::createDeadStoreEliminationPass();
       (void) llvm::createDependenceAnalysisWrapperPass();
       (void) llvm::createDomOnlyPrinterPass();

diff  --git a/llvm/include/llvm/Transforms/Scalar.h b/llvm/include/llvm/Transforms/Scalar.h
index 8c525c689569..9175a4d73162 100644
--- a/llvm/include/llvm/Transforms/Scalar.h
+++ b/llvm/include/llvm/Transforms/Scalar.h
@@ -37,13 +37,6 @@ FunctionPass *createAlignmentFromAssumptionsPass();
 //
 FunctionPass *createSCCPPass();
 
-//===----------------------------------------------------------------------===//
-//
-// DeadInstElimination - This pass quickly removes trivially dead instructions
-// without modifying the CFG of the function.  It is a FunctionPass.
-//
-Pass *createDeadInstEliminationPass();
-
 //===----------------------------------------------------------------------===//
 //
 // RedundantDbgInstElimination - This pass removes redundant dbg intrinsics

diff  --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 28947482e303..500165530225 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -32,57 +32,10 @@ using namespace llvm;
 
 #define DEBUG_TYPE "dce"
 
-STATISTIC(DIEEliminated, "Number of insts removed by DIE pass");
 STATISTIC(DCEEliminated, "Number of insts removed");
 DEBUG_COUNTER(DCECounter, "dce-transform",
               "Controls which instructions are eliminated");
 
-namespace {
-  //===--------------------------------------------------------------------===//
-  // DeadInstElimination pass implementation
-  //
-struct DeadInstElimination : public FunctionPass {
-  static char ID; // Pass identification, replacement for typeid
-  DeadInstElimination() : FunctionPass(ID) {
-    initializeDeadInstEliminationPass(*PassRegistry::getPassRegistry());
-  }
-  bool runOnFunction(Function &F) override {
-    if (skipFunction(F))
-      return false;
-    auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
-    TargetLibraryInfo *TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
-
-    bool Changed = false;
-    for (auto &BB : F) {
-      for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
-        Instruction *Inst = &*DI++;
-        if (isInstructionTriviallyDead(Inst, TLI)) {
-          if (!DebugCounter::shouldExecute(DCECounter))
-            continue;
-          salvageDebugInfo(*Inst);
-          Inst->eraseFromParent();
-          Changed = true;
-          ++DIEEliminated;
-        }
-      }
-    }
-    return Changed;
-  }
-
-    void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.setPreservesCFG();
-    }
-};
-}
-
-char DeadInstElimination::ID = 0;
-INITIALIZE_PASS(DeadInstElimination, "die",
-                "Dead Instruction Elimination", false, false)
-
-Pass *llvm::createDeadInstEliminationPass() {
-  return new DeadInstElimination();
-}
-
 //===--------------------------------------------------------------------===//
 // RedundantDbgInstElimination pass implementation
 //

diff  --git a/llvm/lib/Transforms/Scalar/Scalar.cpp b/llvm/lib/Transforms/Scalar/Scalar.cpp
index 8a740295b19c..0da2912cfd51 100644
--- a/llvm/lib/Transforms/Scalar/Scalar.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -41,7 +41,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
   initializeConstraintEliminationPass(Registry);
   initializeCorrelatedValuePropagationPass(Registry);
   initializeDCELegacyPassPass(Registry);
-  initializeDeadInstEliminationPass(Registry);
   initializeDivRemPairsLegacyPassPass(Registry);
   initializeScalarizerLegacyPassPass(Registry);
   initializeDSELegacyPassPass(Registry);

diff  --git a/llvm/test/Feature/optnone-opt.ll b/llvm/test/Feature/optnone-opt.ll
index 7025bfed32dc..f516aeeff99f 100644
--- a/llvm/test/Feature/optnone-opt.ll
+++ b/llvm/test/Feature/optnone-opt.ll
@@ -2,7 +2,7 @@
 ; RUN: opt -O1 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1
 ; RUN: opt -O2 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
 ; RUN: opt -O3 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
-; RUN: opt -dce -die -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
+; RUN: opt -dce -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
 ; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -enable-new-pm=0 -S -debug %s 2>&1 | FileCheck %s --check-prefix=LOOP
 ; RUN: opt -enable-npm-optnone     -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O0
 ; RUN: opt -enable-npm-optnone -O1 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1
@@ -65,7 +65,6 @@ attributes #0 = { optnone noinline }
 
 ; Additional IR passes that opt doesn't turn on by default.
 ; MORE-DAG: Skipping pass 'Dead Code Elimination'
-; MORE-DAG: Skipping pass 'Dead Instruction Elimination'
 ; NPM-MORE-DAG: Skipping pass: DCEPass
 ; NPM-MORE-DAG: Skipping pass: GVNHoistPass
 

diff  --git a/llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll b/llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
index 858c935bff7f..e3e50f14f18f 100644
--- a/llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
+++ b/llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -deadargelim -die -S > %t
+; RUN: opt < %s -deadargelim -dce -S > %t
 ; RUN: cat %t | grep 123
 
 ; This test tries to catch wrongful removal of return values for a specific case

diff  --git a/llvm/test/Transforms/DeadArgElim/deadretval2.ll b/llvm/test/Transforms/DeadArgElim/deadretval2.ll
index b0d2428fbdc0..36c13da0489b 100644
--- a/llvm/test/Transforms/DeadArgElim/deadretval2.ll
+++ b/llvm/test/Transforms/DeadArgElim/deadretval2.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -deadargelim -die -S > %t
+; RUN: opt < %s -deadargelim -dce -S > %t
 ; RUN: cat %t | not grep DEAD
 ; RUN: cat %t | grep LIVE | count 4
 

diff  --git a/llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll b/llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll
index 4fc446599f39..c56683dd1bf8 100644
--- a/llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll
+++ b/llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -data-layout="e-p:32:32:32-p1:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -S -die | FileCheck %s
+; RUN: opt < %s -data-layout="e-p:32:32:32-p1:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -S -dce | FileCheck %s
 
 define i8 @coerce_offset0_addrspacecast(i32 %V, i32* %P) {
   store i32 %V, i32* %P

diff  --git a/llvm/test/Transforms/GVN/PRE/rle.ll b/llvm/test/Transforms/GVN/PRE/rle.ll
index 4d4e2cbf121d..46f29b0f1022 100644
--- a/llvm/test/Transforms/GVN/PRE/rle.ll
+++ b/llvm/test/Transforms/GVN/PRE/rle.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -S -die | FileCheck %s
-; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32"      -basic-aa -gvn -S -die | FileCheck %s
+; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -S -dce | FileCheck %s
+; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32"      -basic-aa -gvn -S -dce | FileCheck %s
 
 ;; Trivial RLE test.
 define i32 @test0(i32 %V, i32* %P) {
@@ -772,7 +772,7 @@ entry:
 
   %tmp3 = load i8, i8* getelementptr inbounds (%widening1, %widening1* @f, i64 0, i32 4), align 1
   %conv4 = zext i8 %tmp3 to i32
-  %add3 = add nsw i32 %add2, %conv3
+  %add3 = add nsw i32 %add2, %conv4
 
   ret i32 %add3
 ; CHECK-LABEL: @test_widening2(

diff  --git a/llvm/test/Transforms/InstCombine/deadcode.ll b/llvm/test/Transforms/InstCombine/deadcode.ll
index c5fa58babdbc..5b2cdb1bf3af 100644
--- a/llvm/test/Transforms/InstCombine/deadcode.ll
+++ b/llvm/test/Transforms/InstCombine/deadcode.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -instcombine -S | grep "ret i32 %A"
-; RUN: opt < %s -die -S | not grep call.*llvm
+; RUN: opt < %s -dce -S | not grep call.*llvm
 
 define i32 @test(i32 %A) {
 	%X = or i1 false, false		

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll b/llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll
index 65ea22583c04..81a64f9903c7 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll
@@ -1,6 +1,6 @@
 ; SetCC on boolean values was not implemented!
 
-; RUN: opt < %s -instsimplify -die -S | \
+; RUN: opt < %s -instsimplify -dce -S | \
 ; RUN:   not grep set
 
 define i1 @test1() {

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/basictest.ll b/llvm/test/Transforms/InstSimplify/ConstProp/basictest.ll
index 3c1e97f3c9b5..c3aed62fda3f 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/basictest.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/basictest.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -instsimplify -die -S | FileCheck %s
+; RUN: opt < %s -instsimplify -dce -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.7.2"

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/logicaltest.ll b/llvm/test/Transforms/InstSimplify/ConstProp/logicaltest.ll
index e097d40c54e4..5fbf5213e039 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/logicaltest.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/logicaltest.ll
@@ -1,6 +1,6 @@
 ; Ensure constant propagation of logical instructions is working correctly.
 
-; RUN: opt < %s -instsimplify -die -S | FileCheck %s
+; RUN: opt < %s -instsimplify -dce -S | FileCheck %s
 ; CHECK-NOT:     {{and|or|xor}}
 
 define i32 @test1() {

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/phi.ll b/llvm/test/Transforms/InstSimplify/ConstProp/phi.ll
index 74dc328b8a6a..e07a2a89ef7a 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/phi.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/phi.ll
@@ -1,7 +1,7 @@
 ; This is a basic sanity check for constant propagation.  The add instruction
 ; should be eliminated.
 
-; RUN: opt < %s -instsimplify -die -S | not grep phi
+; RUN: opt < %s -instsimplify -dce -S | not grep phi
 
 define i32 @test(i1 %B) {
 BB0:

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/remtest.ll b/llvm/test/Transforms/InstSimplify/ConstProp/remtest.ll
index 3e6fc8dfcb13..39de31318169 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/remtest.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/remtest.ll
@@ -1,6 +1,6 @@
 ; Ensure constant propagation of remainder instructions is working correctly.
 
-; RUN: opt < %s -instsimplify -die -S | not grep rem
+; RUN: opt < %s -instsimplify -dce -S | not grep rem
 
 define i32 @test1() {
         %R = srem i32 4, 3              ; <i32> [#uses=1]

diff  --git a/llvm/test/Transforms/NewGVN/rle.ll b/llvm/test/Transforms/NewGVN/rle.ll
index 6a2becc88344..8d5d3c2745f2 100644
--- a/llvm/test/Transforms/NewGVN/rle.ll
+++ b/llvm/test/Transforms/NewGVN/rle.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -newgvn -S -die | FileCheck %s
-; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32"      -basic-aa -newgvn -S -die | FileCheck %s
+; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -newgvn -S -dce | FileCheck %s
+; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32"      -basic-aa -newgvn -S -dce | FileCheck %s
 ; memset -> i16 forwarding.
 define signext i16 @memset_to_i16_local(i16* %A) nounwind ssp {
 entry:

diff  --git a/llvm/test/Transforms/Reassociate/inverses.ll b/llvm/test/Transforms/Reassociate/inverses.ll
index 14753b1724b8..851686143716 100644
--- a/llvm/test/Transforms/Reassociate/inverses.ll
+++ b/llvm/test/Transforms/Reassociate/inverses.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -reassociate -die -S | FileCheck %s
+; RUN: opt < %s -reassociate -dce -S | FileCheck %s
 
 ; (A&B)&~A == 0
 define i32 @test1(i32 %a, i32 %b) {

diff  --git a/llvm/test/Transforms/Reassociate/otherops.ll b/llvm/test/Transforms/Reassociate/otherops.ll
index 72d8e01faf65..b82a6d13e7d5 100644
--- a/llvm/test/Transforms/Reassociate/otherops.ll
+++ b/llvm/test/Transforms/Reassociate/otherops.ll
@@ -1,6 +1,6 @@
 ; Reassociation should apply to Add, Mul, And, Or, & Xor
 ;
-; RUN: opt < %s -reassociate -instcombine -die -S | FileCheck %s
+; RUN: opt < %s -reassociate -instcombine -dce -S | FileCheck %s
 
 define i32 @test_mul(i32 %arg) {
 ; CHECK-LABEL: test_mul

diff  --git a/llvm/test/Transforms/Reassociate/vaarg_movable.ll b/llvm/test/Transforms/Reassociate/vaarg_movable.ll
index 625597ddca39..71884b2f4f96 100644
--- a/llvm/test/Transforms/Reassociate/vaarg_movable.ll
+++ b/llvm/test/Transforms/Reassociate/vaarg_movable.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -reassociate -die < %s | FileCheck %s
+; RUN: opt -S -reassociate -dce < %s | FileCheck %s
 
 ; The two va_arg instructions depend on the memory/context, are therfore not
 ; identical and the sub should not be optimized to 0 by reassociate.


        


More information about the llvm-commits mailing list