diff options
author | Vedant Kumar <vsk@apple.com> | 2020-04-10 14:58:13 -0700 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-04-13 10:55:17 -0700 |
commit | 122a6bfb07eb1ec7332ad1ee2e1a2136cc54a9c6 (patch) | |
tree | d59a869b727a63f9004d8b36c42ec6b57ab8dae0 /llvm/lib/CodeGen/MachineStripDebug.cpp | |
parent | 95e6f5c655fa39c26e4dc8d5ca65749af69cb484 (diff) | |
download | llvm-122a6bfb07eb1ec7332ad1ee2e1a2136cc54a9c6.zip llvm-122a6bfb07eb1ec7332ad1ee2e1a2136cc54a9c6.tar.gz llvm-122a6bfb07eb1ec7332ad1ee2e1a2136cc54a9c6.tar.bz2 |
[Debugify] Strip added metadata in the -debugify-each pipeline
Summary:
Share logic to strip debugify metadata between the IR and MIR level
debugify passes. This makes it simpler to hunt for bugs by diffing IR
with vs. without -debugify-each turned on.
As a drive-by, fix an issue causing CallGraphNodes to become invalid
when a dead llvm.dbg.value prototype is deleted.
Reviewers: dsanders, aprantl
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77915
Diffstat (limited to 'llvm/lib/CodeGen/MachineStripDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineStripDebug.cpp | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp index 240d657..48b50ce 100644 --- a/llvm/lib/CodeGen/MachineStripDebug.cpp +++ b/llvm/lib/CodeGen/MachineStripDebug.cpp @@ -16,6 +16,7 @@ #include "llvm/IR/DebugInfo.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Transforms/Utils/Debugify.h" #define DEBUG_TYPE "mir-strip-debug" @@ -73,33 +74,7 @@ struct StripDebugMachineModule : public ModulePass { } } - Changed |= StripDebugInfo(M); - - NamedMDNode *NMD = M.getNamedMetadata("llvm.debugify"); - if (NMD) { - NMD->eraseFromParent(); - Changed |= true; - } - - NMD = M.getModuleFlagsMetadata(); - if (NMD) { - // There must be an easier way to remove an operand from a NamedMDNode. - SmallVector<MDNode *, 4> Flags; - for (MDNode *Flag : NMD->operands()) - Flags.push_back(Flag); - NMD->clearOperands(); - for (MDNode *Flag : Flags) { - MDString *Key = dyn_cast_or_null<MDString>(Flag->getOperand(1)); - if (Key->getString() == "Debug Info Version") { - Changed |= true; - continue; - } - NMD->addOperand(Flag); - } - // If we left it empty we might as well remove it. - if (NMD->getNumOperands() == 0) - NMD->eraseFromParent(); - } + Changed |= stripDebugifyMetadata(M); return Changed; } |