[llvm] r333977 - [opt] Introduce -strip-named-metadata
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 17:56:08 PDT 2018
Author: vedantk
Date: Mon Jun 4 17:56:08 2018
New Revision: 333977
URL: http://llvm.org/viewvc/llvm-project?rev=333977&view=rev
Log:
[opt] Introduce -strip-named-metadata
This renames and generalizes -strip-module-flags to erase all named
metadata from a module. This makes it easier to diff IR.
Modified:
llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll
llvm/trunk/test/DebugInfo/debugify-each.ll
llvm/trunk/test/DebugInfo/strip-module-flags.ll
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll?rev=333977&r1=333976&r2=333977&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll (original)
+++ llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll Mon Jun 4 17:56:08 2018
@@ -1,8 +1,8 @@
; RUN: opt < %s -globals-aa -functionattrs | \
-; RUN: opt -S -strip -strip-dead-prototypes -strip-module-flags > %t.no_dbg
+; RUN: opt -S -strip -strip-dead-prototypes -strip-named-metadata > %t.no_dbg
; RUN: opt < %s -debugify-each -globals-aa -functionattrs | \
-; RUN: opt -S -strip -strip-dead-prototypes -strip-module-flags > %t.with_dbg
+; RUN: opt -S -strip -strip-dead-prototypes -strip-named-metadata > %t.with_dbg
; RUN: diff %t.no_dbg %t.with_dbg
Modified: llvm/trunk/test/DebugInfo/debugify-each.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify-each.ll?rev=333977&r1=333976&r2=333977&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify-each.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify-each.ll Mon Jun 4 17:56:08 2018
@@ -16,17 +16,17 @@
; Check that stripped textual IR compares equal before and after applying
; debugify.
; RUN: opt -O1 < %s -S -o - | \
-; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.before
+; RUN: opt -strip -strip-dead-prototypes -strip-named-metadata -S -o %t.before
; RUN: opt -O1 -debugify-each < %s -S -o - | \
-; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.after
+; RUN: opt -strip -strip-dead-prototypes -strip-named-metadata -S -o %t.after
; RUN: diff %t.before %t.after
; Check that stripped IR compares equal before and after applying debugify.
; RUN: opt -O1 < %s | \
-; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
+; RUN: opt -strip -strip-dead-prototypes -strip-named-metadata | \
; RUN: llvm-dis -o %t.before
; RUN: opt -O1 -debugify-each < %s | \
-; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
+; RUN: opt -strip -strip-dead-prototypes -strip-named-metadata | \
; RUN: llvm-dis -o %t.after
; RUN: diff %t.before %t.after
Modified: llvm/trunk/test/DebugInfo/strip-module-flags.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/strip-module-flags.ll?rev=333977&r1=333976&r2=333977&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/strip-module-flags.ll (original)
+++ llvm/trunk/test/DebugInfo/strip-module-flags.ll Mon Jun 4 17:56:08 2018
@@ -1,7 +1,10 @@
-; RUN: opt -strip-module-flags < %s -S -o - | FileCheck %s
+; RUN: opt -strip-named-metadata < %s -S -o - | FileCheck %s
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
+!llvm.debugify = !{!0}
+
; CHECK-NOT: llvm.module.flags
; CHECK-NOT: Debug Info Version
+; CHECK-NOT: llvm.debugify
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=333977&r1=333976&r2=333977&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Mon Jun 4 17:56:08 2018
@@ -121,11 +121,12 @@ static cl::opt<bool>
StripDebug("strip-debug",
cl::desc("Strip debugger symbol info from translation unit"));
-static cl::opt<bool> StripModuleFlags("strip-module-flags",
- cl::desc("Strip module flags metadata"));
-
static cl::opt<bool>
-DisableInline("disable-inlining", cl::desc("Do not run the inliner pass"));
+ StripNamedMetadata("strip-named-metadata",
+ cl::desc("Strip module-level named metadata"));
+
+static cl::opt<bool> DisableInline("disable-inlining",
+ cl::desc("Do not run the inliner pass"));
static cl::opt<bool>
DisableOptimizations("disable-opt",
@@ -503,10 +504,13 @@ int main(int argc, char **argv) {
if (StripDebug)
StripDebugInfo(*M);
- // Erase module flags metadata, if requested.
- if (StripModuleFlags)
- if (NamedMDNode *ModFlags = M->getModuleFlagsMetadata())
- M->eraseNamedMetadata(ModFlags);
+ // Erase module-level named metadata, if requested.
+ if (StripNamedMetadata) {
+ while (!M->named_metadata_empty()) {
+ NamedMDNode *NMD = &*M->named_metadata_begin();
+ M->eraseNamedMetadata(NMD);
+ }
+ }
// If we are supposed to override the target triple or data layout, do so now.
if (!TargetTriple.empty())
More information about the llvm-commits
mailing list