summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2016-10-25 18:44:13 +0000
committerMichael Ilseman <milseman@apple.com>2016-10-25 18:44:13 +0000
commit5bd98bf7d66398d66b4b07a3a5db20e9abea07cd (patch)
tree08ca75ae3493565bea48a2f98cfba3510c529a0d /tools/bugpoint
parente05a7ffa08ea6f128050be2838b945ded860ee1d (diff)
Add -strip-nonlinetable-debuginfo capability
This adds a new function to DebugInfo.cpp that takes an llvm::Module as input and removes all debug info metadata that is not directly needed for line tables, thus effectively stripping all type and variable information from the module. The primary motivation for this feature was the bitcode work flow (cf. http://lists.llvm.org/pipermail/llvm-dev/2016-June/100643.html for more background). This is not wired up yet, but will be in subsequent patches. For testing, the new functionality is exposed to opt with a -strip-nonlinetable-debuginfo option. The secondary use-case (and one that works right now!) is as a reduction pass in bugpoint. I added two new bugpoint options (-disable-strip-debuginfo and -disable-strip-debug-types) to control the new features. By default it will first attempt to remove all debug information, then only the type info, and then proceed to hack at any remaining MDNodes. Thanks to Adrian Prantl for stewarding this patch! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index a472fff0975..0cae0669477 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -19,6 +19,7 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LegacyPassManager.h"
@@ -54,6 +55,12 @@ cl::opt<bool> DontReducePassList("disable-pass-list-reduction",
cl::opt<bool> NoNamedMDRM("disable-namedmd-remove",
cl::desc("Do not remove global named metadata"),
cl::init(false));
+cl::opt<bool> NoStripDebugInfo("disable-strip-debuginfo",
+ cl::desc("Do not strip debug info metadata"),
+ cl::init(false));
+cl::opt<bool> NoStripDebugTypeInfo("disable-strip-debug-types",
+ cl::desc("Do not strip debug type info metadata"),
+ cl::init(false));
cl::opt<bool> VerboseErrors("verbose-errors",
cl::desc("Print the output of crashing program"),
cl::init(false));
@@ -1123,6 +1130,22 @@ static Error DebugACrash(BugDriver &BD,
if (Error E = ReduceInsts(BD, TestFn))
return E;
+ // Attempt to strip debug info metadata.
+ auto stripMetadata = [&](std::function<bool(Module &)> strip) {
+ std::unique_ptr<Module> M = CloneModule(BD.getProgram());
+ strip(*M);
+ if (TestFn(BD, M.get()))
+ BD.setNewProgram(M.release());
+ };
+ if (!NoStripDebugInfo && !BugpointIsInterrupted) {
+ outs() << "\n*** Attempting to strip the debug info: ";
+ stripMetadata(StripDebugInfo);
+ }
+ if (!NoStripDebugTypeInfo && !BugpointIsInterrupted) {
+ outs() << "\n*** Attempting to strip the debug type info: ";
+ stripMetadata(stripNonLineTableDebugInfo);
+ }
+
if (!NoNamedMDRM) {
if (!BugpointIsInterrupted) {
// Try to reduce the amount of global metadata (particularly debug info),