aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineStripDebug.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2020-04-09 10:36:50 -0700
committerDaniel Sanders <daniel_l_sanders@apple.com>2020-04-10 15:24:14 -0700
commitdfca98d6a83c725db38a20c06df92f1b2b9ce16b (patch)
tree0e8ad1d83720c75327247e322d55be511c3dc38b /llvm/lib/CodeGen/MachineStripDebug.cpp
parentcbe42a9d5fa76eb56cbe615bd64cff2e6a8a9d65 (diff)
downloadllvm-dfca98d6a83c725db38a20c06df92f1b2b9ce16b.zip
llvm-dfca98d6a83c725db38a20c06df92f1b2b9ce16b.tar.gz
llvm-dfca98d6a83c725db38a20c06df92f1b2b9ce16b.tar.bz2
[mir-strip-debug] Optionally preserve debug info that wasn't from debugify/mir-debugify
Summary: A few tests start out with debug info and expect it to reach the output. For these tests we shouldn't strip the debug info Reviewers: aprantl, vsk, bogner Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77886
Diffstat (limited to 'llvm/lib/CodeGen/MachineStripDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineStripDebug.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp
index 0129718..aeb2789 100644
--- a/llvm/lib/CodeGen/MachineStripDebug.cpp
+++ b/llvm/lib/CodeGen/MachineStripDebug.cpp
@@ -15,15 +15,30 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE "mir-strip-debug"
using namespace llvm;
namespace {
+cl::opt<bool>
+ OnlyDebugifiedDefault("mir-strip-debugify-only",
+ cl::desc("Should mir-strip-debug only strip debug "
+ "info from debugified modules by default"),
+ cl::init(true));
struct StripDebugMachineModule : public ModulePass {
bool runOnModule(Module &M) override {
+ if (OnlyDebugified) {
+ NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
+ if (!DebugifyMD) {
+ LLVM_DEBUG(dbgs() << "Not stripping debug info"
+ " (debugify metadata not found)?\n");
+ return false;
+ }
+ }
+
MachineModuleInfo &MMI =
getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
@@ -89,7 +104,9 @@ struct StripDebugMachineModule : public ModulePass {
return Changed;
}
- StripDebugMachineModule() : ModulePass(ID) {}
+ StripDebugMachineModule() : StripDebugMachineModule(OnlyDebugifiedDefault) {}
+ StripDebugMachineModule(bool OnlyDebugified)
+ : ModulePass(ID), OnlyDebugified(OnlyDebugified) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<MachineModuleInfoWrapperPass>();
@@ -97,6 +114,9 @@ struct StripDebugMachineModule : public ModulePass {
}
static char ID; // Pass identification.
+
+protected:
+ bool OnlyDebugified;
};
char StripDebugMachineModule::ID = 0;
@@ -107,6 +127,6 @@ INITIALIZE_PASS_BEGIN(StripDebugMachineModule, DEBUG_TYPE,
INITIALIZE_PASS_END(StripDebugMachineModule, DEBUG_TYPE,
"Machine Strip Debug Module", false, false)
-ModulePass *createStripDebugMachineModulePass() {
- return new StripDebugMachineModule();
+ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified) {
+ return new StripDebugMachineModule(OnlyDebugified);
}