[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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user