[PATCH] D43601: [bugpoint] Add NoStripSymbols option.

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 16:41:47 PST 2018


hintonda updated this revision to Diff 135562.
hintonda added a comment.

- Don't clone module when stripping.
- Address more comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D43601

Files:
  include/llvm/Transforms/IPO.h
  lib/Transforms/IPO/StripSymbols.cpp
  test/BugPoint/strip-names-and-types.ll
  tools/bugpoint/CrashDebugger.cpp


Index: tools/bugpoint/CrashDebugger.cpp
===================================================================
--- tools/bugpoint/CrashDebugger.cpp
+++ tools/bugpoint/CrashDebugger.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Cloning.h"
@@ -61,6 +62,9 @@
 cl::opt<bool> NoStripDebugTypeInfo("disable-strip-debug-types",
                                cl::desc("Do not strip debug type info metadata"),
                                cl::init(false));
+cl::opt<bool> NoStripSymbols("disable-strip-symbols",
+                             cl::desc("Do not strip symbol and type names"),
+                             cl::init(false));
 cl::opt<bool> VerboseErrors("verbose-errors",
                             cl::desc("Print the output of crashing program"),
                             cl::init(false));
@@ -1127,6 +1131,10 @@
     outs() << "\n*** Attempting to strip the debug type info: ";
     stripMetadata(stripNonLineTableDebugInfo);
   }
+  if (!NoStripSymbols && !BugpointIsInterrupted) {
+    outs() << "\n*** Attempting to strip symbol and type names: ";
+    StripSymbolNames(BD.getProgram(), true);
+  }
 
   if (!NoNamedMDRM) {
     if (!BugpointIsInterrupted) {
Index: test/BugPoint/strip-names-and-types.ll
===================================================================
--- /dev/null
+++ test/BugPoint/strip-names-and-types.ll
@@ -0,0 +1,20 @@
+; REQUIRES: loadable_module
+; RUN: bugpoint %s -output-prefix %t -silence-passes -safe-run-llc
+; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck %s
+; RUN: bugpoint %s -output-prefix %t -disable-strip-symbols -silence-passes -safe-run-llc
+; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck --check-prefix=DISABLE %s
+
+%type0 = type { i32, i64 }
+
+define i1 @foo(i1 %A) {
+  ret i1 %A
+}
+
+; CHECK-LABEL: define i32 @test
+define i32 @test() {
+  %A = icmp eq %type0* undef, undef
+; CHECK: icmp eq %0* undef, undef
+; DISABLE: icmp eq %type0* undef, undef
+  call i1 @foo(i1 %A)
+  ret i32 0
+}
Index: lib/Transforms/IPO/StripSymbols.cpp
===================================================================
--- lib/Transforms/IPO/StripSymbols.cpp
+++ lib/Transforms/IPO/StripSymbols.cpp
@@ -202,7 +202,7 @@
 }
 
 /// StripSymbolNames - Strip symbol names.
-static bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
+bool llvm::StripSymbolNames(Module &M, bool PreserveDbgInfo) {
 
   SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
   findUsedValues(M.getGlobalVariable("llvm.used"), llvmUsedValues);
Index: include/llvm/Transforms/IPO.h
===================================================================
--- include/llvm/Transforms/IPO.h
+++ include/llvm/Transforms/IPO.h
@@ -31,6 +31,8 @@
 class GlobalValue;
 class raw_ostream;
 
+bool StripSymbolNames(Module &M, bool PreserveDbgInfo);
+
 //===----------------------------------------------------------------------===//
 //
 // These functions removes symbols from functions and modules.  If OnlyDebugInfo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43601.135562.patch
Type: text/x-patch
Size: 3193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/d5daee60/attachment.bin>


More information about the llvm-commits mailing list