diff options
author | Arthur Eubanks <aeubanks@google.com> | 2020-11-16 11:47:50 -0800 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2020-11-16 20:39:46 -0800 |
commit | 7de6dcd24644eee6af9e642cb9e0402a47018413 (patch) | |
tree | 66cbf6df0b528da82242ba8314a10da6de82987e /llvm/lib/Transforms/Utils/Debugify.cpp | |
parent | 74207e78cf26a52a59efaf95104d7ca0e5f801bf (diff) | |
download | llvm-7de6dcd24644eee6af9e642cb9e0402a47018413.zip llvm-7de6dcd24644eee6af9e642cb9e0402a47018413.tar.gz llvm-7de6dcd24644eee6af9e642cb9e0402a47018413.tar.bz2 |
[Debugify] Skip debugifying on special/immutable passes
With a function pass manager, it would insert debuginfo metadata before
getting to function passes while processing the pass manager, causing
debugify to skip while running the function passes.
Skip special passes + verifier + printing passes. Compared to the legacy
implementation of -debugify-each, this additionally skips verifier
passes. Probably no need to update the legacy version since it will be
obsolete soon.
This fixes 2 instcombine tests using -debugify-each under NPM.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D91558
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Debugify.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp index 526083c..cb6985f 100644 --- a/llvm/lib/Transforms/Utils/Debugify.cpp +++ b/llvm/lib/Transforms/Utils/Debugify.cpp @@ -20,6 +20,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" +#include "llvm/IR/PassInstrumentation.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" @@ -530,9 +531,18 @@ PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M, return PreservedAnalyses::all(); } +static bool isIgnoredPass(StringRef PassID) { + return isSpecialPass(PassID, {"PassManager", "PassAdaptor", + "AnalysisManagerProxy", "PrintFunctionPass", + "PrintModulePass", "BitcodeWriterPass", + "ThinLTOBitcodeWriterPass", "VerifierPass"}); +} + void DebugifyEachInstrumentation::registerCallbacks( PassInstrumentationCallbacks &PIC) { PIC.registerBeforeNonSkippedPassCallback([](StringRef P, Any IR) { + if (isIgnoredPass(P)) + return; if (any_isa<const Function *>(IR)) applyDebugify(*const_cast<Function *>(any_cast<const Function *>(IR))); else if (any_isa<const Module *>(IR)) @@ -540,6 +550,8 @@ void DebugifyEachInstrumentation::registerCallbacks( }); PIC.registerAfterPassCallback([this](StringRef P, Any IR, const PreservedAnalyses &PassPA) { + if (isIgnoredPass(P)) + return; if (any_isa<const Function *>(IR)) { auto &F = *const_cast<Function *>(any_cast<const Function *>(IR)); Module &M = *F.getParent(); |