mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[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. llvm-svn: 333977
This commit is contained in:
parent
85503c73b3
commit
563a747bd5
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user