[PATCH] D91477: [DCE] Port -redundant-dbg-inst-elim to NPM
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 23:41:25 PST 2020
aeubanks created this revision.
aeubanks added reviewers: asbirlea, ychen.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aeubanks requested review of this revision.
This is used to test RemoveRedundantDbgInstrs(), which is used by other
passes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91477
Files:
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
Index: llvm/test/Transforms/DCE/dbg-value-removal.ll
===================================================================
--- llvm/test/Transforms/DCE/dbg-value-removal.ll
+++ 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.
Index: llvm/lib/Transforms/Scalar/DCE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DCE.cpp
+++ llvm/lib/Transforms/Scalar/DCE.cpp
@@ -21,6 +21,7 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/DebugCounter.h"
@@ -69,6 +70,18 @@
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
//
Index: llvm/lib/Passes/PassRegistry.def
===================================================================
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -285,6 +285,7 @@
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())
Index: llvm/include/llvm/Transforms/Scalar/DCE.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/DCE.h
+++ llvm/include/llvm/Transforms/Scalar/DCE.h
@@ -23,6 +23,12 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91477.305306.patch
Type: text/x-patch
Size: 2750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201114/d4a4f13e/attachment.bin>
More information about the llvm-commits
mailing list