summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2016-10-06 17:58:38 +0000
committerMichael Ilseman <milseman@apple.com>2016-10-06 17:58:38 +0000
commitbda4e020b82a295637735837ea714a9375f42382 (patch)
tree4179688c62c37da837c403f639330c65d03feaad /tools/bugpoint
parentde50b32fba3e5ad1a32c536fff3926e86c1ce3bd (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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283473 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index cdbf57f90e8..4e13251459d 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,30 @@ static Error DebugACrash(BugDriver &BD,
if (Error E = ReduceInsts(BD, TestFn))
return E;
+ if (!NoStripDebugInfo) {
+ if (!BugpointIsInterrupted) {
+ outs() << "\n*** Attempting to strip the debug info: ";
+ Module *M = CloneModule(BD.getProgram()).release();
+ StripDebugInfo(*M);
+ if (TestFn(BD, M))
+ BD.setNewProgram(M);
+ else
+ delete M;
+ }
+ }
+
+ if (!NoStripDebugTypeInfo) {
+ if (!BugpointIsInterrupted) {
+ outs() << "\n*** Attempting to strip the debug type info: ";
+ Module *M = CloneModule(BD.getProgram()).release();
+ stripNonLineTableDebugInfo(*M);
+ if (TestFn(BD, M))
+ BD.setNewProgram(M);
+ else
+ delete M;
+ }
+ }
+
if (!NoNamedMDRM) {
if (!BugpointIsInterrupted) {
// Try to reduce the amount of global metadata (particularly debug info),