summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-03-10 01:28:54 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-03-10 01:28:54 +0000
commit09b4a8daa354382c294e736fc9db018621376728 (patch)
tree1a6cc1ee5bb32a566ed302b549c649ccde6c607c /llvm/lib/LTO
parentaaae5f87af8945cdeac81e86429a303954473a88 (diff)
downloadbcm5719-llvm-09b4a8daa354382c294e736fc9db018621376728.tar.gz
bcm5719-llvm-09b4a8daa354382c294e736fc9db018621376728.zip
Add a flag to the LLVMContext to disable name for Value other than GlobalValue
Summary: This is intended to be a performance flag, on the same level as clang cc1 option "--disable-free". LLVM will never initialize it by default, it will be up to the client creating the LLVMContext to request this behavior. Clang will do it by default in Release build (just like --disable-free). "opt" and "llc" can opt-in using -disable-named-value command line option. When performing LTO on llvm-tblgen, the initial merging of IR peaks at 92MB without this patch, and 86MB after this patch,setNameImpl() drops from 6.5MB to 0.5MB. The total link time goes from ~29.5s to ~27.8s. Compared to a compile-time flag (like the IRBuilder one), it performs very close. I profiled on SROA and obtain these results: 420ms with IRBuilder that preserve name 372ms with IRBuilder that strip name 375ms with IRBuilder that preserve name, and a runtime flag to strip Reviewers: chandlerc, dexonsmith, bogner Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17946 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263086
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp13
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp6
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index f36dc56774b..a85cf407e6a 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -65,9 +65,22 @@ const char* LTOCodeGenerator::getVersionString() {
#endif
}
+namespace llvm {
+cl::opt<bool> LTODiscardValueNames(
+ "discard-value-names",
+ cl::desc("Strip names from Value (other than GlobalValue)."),
+#ifdef NDEBUG
+ cl::init(true),
+#else
+ cl::init(false),
+#endif
+ cl::Hidden);
+}
+
LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
: Context(Context), MergedModule(new Module("ld-temp.o", Context)),
TheLinker(new Linker(*MergedModule)) {
+ Context.setDiscardValueNames(LTODiscardValueNames);
initializeLTOPasses();
}
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index b17ec2e916c..a99c6e4cf73 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -41,6 +41,11 @@
using namespace llvm;
+namespace llvm {
+// Flags -discard-value-names, defined in LTOCodeGenerator.cpp
+extern cl::opt<bool> LTODiscardValueNames;
+}
+
namespace {
static cl::opt<int> ThreadCount("threads",
@@ -361,6 +366,7 @@ void ThinLTOCodeGenerator::run() {
for (auto &ModuleBuffer : Modules) {
Pool.async([&](int count) {
LLVMContext Context;
+ Context.setDiscardValueNames(LTODiscardValueNames);
// Parse module now
auto TheModule = loadModuleFromBuffer(ModuleBuffer, Context, false);
OpenPOWER on IntegriCloud