diff options
author | Piotr Padlewski <piotr.padlewski@gmail.com> | 2016-07-08 21:25:39 +0000 |
---|---|---|
committer | Piotr Padlewski <piotr.padlewski@gmail.com> | 2016-07-08 21:25:39 +0000 |
commit | d6efefa2b836d9c5cafd35508ae19ad8972020d1 (patch) | |
tree | 8c909d5e05293c885b1e7793faf9db97ec7c1d4d | |
parent | 3fb8f9eabff53c720b3b447a3649e373b8057295 (diff) | |
download | bcm5719-llvm-d6efefa2b836d9c5cafd35508ae19ad8972020d1.tar.gz bcm5719-llvm-d6efefa2b836d9c5cafd35508ae19ad8972020d1.zip |
Add 'thinlto_src_module' md with asserts or -enable-import-metadata
Summary:
This way the metadata will be only generated when asserts enabled,
or when -enable-import-metadata specified
Reviewers: tejohnson, eraman, mehdi_amini
Subscribers: mehdi_amini, llvm-commits
Differential Revision: http://reviews.llvm.org/D22167
llvm-svn: 274938
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 25 | ||||
-rw-r--r-- | llvm/test/Transforms/FunctionImport/funcimport.ll | 6 |
2 files changed, 22 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index f15d8cff6d9..c9d075e7632 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -58,6 +58,16 @@ static cl::opt<bool> DontForceImportReferencedDiscardableSymbols("disable-force-link-odr", cl::init(false), cl::Hidden); +static cl::opt<bool> EnableImportMetadata( + "enable-import-metadata", cl::init( +#if !defined(NDEBUG) + true /*Enabled with asserts.*/ +#else + false +#endif + ), + cl::Hidden, cl::desc("Enable import metadata like 'thinlto_src_module'")); + // Load lazily a module from \p FileName in \p Context. static std::unique_ptr<Module> loadFile(const std::string &FileName, LLVMContext &Context) { @@ -591,12 +601,15 @@ bool FunctionImporter::importFunctions( << SrcModule->getSourceFileName() << "\n"); if (Import) { F.materialize(); - // Add 'thinlto_src_module' metadata for statistics and debugging. - F.setMetadata("thinlto_src_module", - llvm::MDNode::get(DestModule.getContext(), - {llvm::MDString::get( - DestModule.getContext(), - SrcModule->getSourceFileName())})); + if (EnableImportMetadata) { + // Add 'thinlto_src_module' metadata for statistics and debugging. + F.setMetadata( + "thinlto_src_module", + llvm::MDNode::get( + DestModule.getContext(), + {llvm::MDString::get(DestModule.getContext(), + SrcModule->getSourceFileName())})); + } GlobalsToImport.insert(&F); } } diff --git a/llvm/test/Transforms/FunctionImport/funcimport.ll b/llvm/test/Transforms/FunctionImport/funcimport.ll index b61f8d59f5f..61d4dfaad0a 100644 --- a/llvm/test/Transforms/FunctionImport/funcimport.ll +++ b/llvm/test/Transforms/FunctionImport/funcimport.ll @@ -4,12 +4,12 @@ ; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID ; Do the import now -; RUN: opt -disable-force-link-odr -function-import -stats -print-imports -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF +; RUN: opt -disable-force-link-odr -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF ; "-stats" requires +Asserts. -; REQUIRES: asserts +; REQUIRES asserts ; Test import with smaller instruction limit -; RUN: opt -disable-force-link-odr -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5 +; RUN: opt -disable-force-link-odr -function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5 ; INSTLIM5-NOT: @staticfunc.llvm. ; Test import with smaller instruction limit and without the -disable-force-link-odr |