[llvm] 6e04da0 - [DCE] Port -redundant-dbg-inst-elim to NPM
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 14 16:55:37 PST 2020
Author: Arthur Eubanks
Date: 2020-11-14T16:55:20-08:00
New Revision: 6e04da0a5ac98e776fa94a6ae240d3fed2d8be57
URL: https://github.com/llvm/llvm-project/commit/6e04da0a5ac98e776fa94a6ae240d3fed2d8be57
DIFF: https://github.com/llvm/llvm-project/commit/6e04da0a5ac98e776fa94a6ae240d3fed2d8be57.diff
LOG: [DCE] Port -redundant-dbg-inst-elim to NPM
This is used to test RemoveRedundantDbgInstrs(), which is used by other
passes.
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D91477
Added:
Modified:
llvm/include/llvm/Transforms/Scalar/DCE.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Scalar/DCE.cpp
llvm/test/Transforms/DCE/dbg-value-removal.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Scalar/DCE.h b/llvm/include/llvm/Transforms/Scalar/DCE.h
index 974e4b20d152..4d83296b1d86 100644
--- a/llvm/include/llvm/Transforms/Scalar/DCE.h
+++ b/llvm/include/llvm/Transforms/Scalar/DCE.h
@@ -23,6 +23,12 @@ class DCEPass : public PassInfoMixin<DCEPass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
+
+class RedundantDbgInstEliminationPass
+ : public PassInfoMixin<RedundantDbgInstEliminationPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
}
#endif // LLVM_TRANSFORMS_SCALAR_DCE_H
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 343cb93680cd..48039b85366a 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -285,6 +285,7 @@ FUNCTION_PASS("print-alias-sets", AliasSetsPrinterPass(dbgs()))
FUNCTION_PASS("print-predicateinfo", PredicateInfoPrinterPass(dbgs()))
FUNCTION_PASS("print-mustexecute", MustExecutePrinterPass(dbgs()))
FUNCTION_PASS("reassociate", ReassociatePass())
+FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass())
FUNCTION_PASS("reg2mem", RegToMemPass())
FUNCTION_PASS("scalarizer", ScalarizerPass())
FUNCTION_PASS("separate-const-offset-from-gep", SeparateConstOffsetFromGEPPass())
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 500165530225..badf0e1503b6 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -69,6 +69,18 @@ Pass *llvm::createRedundantDbgInstEliminationPass() {
return new RedundantDbgInstElimination();
}
+PreservedAnalyses
+RedundantDbgInstEliminationPass::run(Function &F, FunctionAnalysisManager &AM) {
+ bool Changed = false;
+ for (auto &BB : F)
+ Changed |= RemoveRedundantDbgInstrs(&BB);
+ if (!Changed)
+ return PreservedAnalyses::all();
+ PreservedAnalyses PA;
+ PA.preserveSet<CFGAnalyses>();
+ return PA;
+}
+
//===--------------------------------------------------------------------===//
// DeadCodeElimination pass implementation
//
diff --git a/llvm/test/Transforms/DCE/dbg-value-removal.ll b/llvm/test/Transforms/DCE/dbg-value-removal.ll
index 3231cf62e523..65a81ff223ff 100644
--- a/llvm/test/Transforms/DCE/dbg-value-removal.ll
+++ b/llvm/test/Transforms/DCE/dbg-value-removal.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -redundant-dbg-inst-elim | FileCheck %s
+; RUN: opt < %s -S -passes=redundant-dbg-inst-elim | FileCheck %s
; All dbg.value with location "!dbg !19" are redundant in the input.
; FIXME: We do not handle non-overlapping/overlapping fragments perfectly yet.
More information about the llvm-commits
mailing list