From dab999d54f39af3ebb6a23e850dbc9742016fac8 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 20 Jan 2015 19:24:59 +0000 Subject: [llvm link] Destroy ConstantArrays in LLVMContext if they are not used. ConstantArrays constructed during linking can cause quadratic memory explosion. An example is the ConstantArrays constructed when linking in GlobalVariables with appending linkage. Releasing all unused constants can cause a 20% LTO compile-time slowdown for a large application. So this commit releases unused ConstantArrays only. rdar://19040716. It reduces memory footprint from 20+G to 6+G. llvm-svn: 226592 --- llvm/lib/Linker/LinkModules.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Linker/LinkModules.cpp') diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 767d465d1be..dc002d8a576 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -1721,7 +1721,9 @@ void Linker::deleteModule() { bool Linker::linkInModule(Module *Src) { ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, DiagnosticHandler); - return TheLinker.run(); + bool RetCode = TheLinker.run(); + Composite->dropTriviallyDeadConstantArrays(); + return RetCode; } //===----------------------------------------------------------------------===// -- cgit v1.2.3