summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-06-05 00:56:08 +0000
committerVedant Kumar <vsk@apple.com>2018-06-05 00:56:08 +0000
commitb6ed992de054e950547623b5605c6c18235979e9 (patch)
treeb3cb1158cc8b604cae61188cf8e88b26dc2fc4db /llvm/tools/opt
parent800255f9f1da61f65ab483f2c5aaaf870bdfa862 (diff)
downloadbcm5719-llvm-b6ed992de054e950547623b5605c6c18235979e9.tar.gz
bcm5719-llvm-b6ed992de054e950547623b5605c6c18235979e9.zip
[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
Diffstat (limited to 'llvm/tools/opt')
-rw-r--r--llvm/tools/opt/opt.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index f1221819f62..43771d5d75b 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -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())
OpenPOWER on IntegriCloud