<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div>In r226592.<div class=""><br class=""></div><div class="">Thanks for reviewing!</div><div class=""><br class=""></div><div class="">Manman</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 19, 2015, at 12:34 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On 2015-Jan-19, at 11:25, Manman Ren <<a href="mailto:mren@apple.com" class="">mren@apple.com</a>> wrote:<br class=""><br class="">Thanks Rafael and Duncan.<br class=""><br class="">Updated patch is attached. It adds<br class="">+ /// Destroy ConstantArrays in LLVMContext if they are not used.<br class="">+ /// ConstantArrays constructed during linking can cause quadratic memory<br class="">+ /// explosion. Releasing all unused constants can cause a 20% LTO compile-time<br class="">+ /// slowdown for a large application.<br class="">+ /// NOTE: Constants are currently owned by LLVMContext. This can then only<br class="">+ /// be called where all uses of the LLVMContext are understood.<br class="">+ void dropTriviallyDeadConstantArrays();<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jan 16, 2015, at 6:17 PM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com" class="">rafael.espindola@gmail.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">A 20% slowdown seems excessive. Do I understand correctly that if you<br class="">don't delete unused `ConstantExpr`s there's no real slowdown?<br class=""></blockquote></blockquote><br class="">Without deleting “ConstantExprs”, the run time is 10 minutes, and it reduces the memory footprint from 22GB to 6GB.<br class="">If we delete unused “ConstantExprs”, the run time is 12 minutes, the memory footprint is about the same.<br class=""><br class="">Thanks,<br class="">Manman<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">LGTM, once you fix a couple of comment nitpicks:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Index: include/llvm/IR/Module.h<br class="">===================================================================<br class="">--- include/llvm/IR/Module.h<span class="Apple-tab-span" style="white-space: pre;"> </span>(revision 226024)<br class="">+++ include/llvm/IR/Module.h<span class="Apple-tab-span" style="white-space: pre;"> </span>(working copy)<br class="">@@ -630,6 +630,11 @@<br class=""> named_metadata_end());<br class=""> }<br class=""><br class="">+ /// Destroy ConstantArrays in LLVMContext if they are not used.<br class="">+ /// ConstantArrays constructed during linking can cause quadratic memory<br class="">+ /// explosion. Releasing all unused constants can cause a 20% LTO compile-time<br class="">+ /// slowdown for a large application.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Can you add an empty (but commented) line here? This makes the NOTE</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">jump out a bit more clearly.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> ///</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+ /// NOTE: Constants are currently owned by LLVMContext. This can then only<br class="">+ /// be called where all uses of the LLVMContext are understood.<br class="">+ void dropTriviallyDeadConstantArrays();<br class="">+<br class="">/// @}<br class="">/// @name Utility functions for printing and dumping Module objects<br class="">/// @{<br class="">Index: lib/IR/LLVMContextImpl.cpp<br class="">===================================================================<br class="">--- lib/IR/LLVMContextImpl.cpp<span class="Apple-tab-span" style="white-space: pre;"> </span>(revision 226024)<br class="">+++ lib/IR/LLVMContextImpl.cpp<span class="Apple-tab-span" style="white-space: pre;"> </span>(working copy)<br class="">@@ -154,6 +154,95 @@<br class=""> MDStringCache.clear();<br class="">}<br class=""><br class="">+void LLVMContextImpl::dropTriviallyDeadConstantArrays() {<br class="">+ bool Changed;<br class="">+ do {<br class="">+ Changed = false;<br class="">+<br class="">+ for (auto I = ArrayConstants.map_begin(), E = ArrayConstants.map_end();<br class="">+ I != E; ) {<br class="">+ auto *C = I->first;<br class="">+ I++;<br class="">+ if (C->use_empty()) {<br class="">+ Changed = true;<br class="">+ C->destroyConstant();<br class="">+ }<br class="">+ }<br class="">+<br class="">+ } while (Changed);<br class="">+}<br class="">+<br class="">+void Module::dropTriviallyDeadConstantArrays() {<br class="">+ Context.pImpl->dropTriviallyDeadConstantArrays();<br class="">+}<br class="">+<br class="">// ConstantsContext anchors<br class="">void UnaryConstantExpr::anchor() { }<br class=""><br class="">Index: lib/IR/LLVMContextImpl.h<br class="">===================================================================<br class="">--- lib/IR/LLVMContextImpl.h<span class="Apple-tab-span" style="white-space: pre;"> </span>(revision 226024)<br class="">+++ lib/IR/LLVMContextImpl.h<span class="Apple-tab-span" style="white-space: pre;"> </span>(working copy)<br class="">@@ -392,6 +392,10 @@<br class=""><br class=""> LLVMContextImpl(LLVMContext &C);<br class=""> ~LLVMContextImpl();<br class="">+<br class="">+ /// Destroy the ConstantArrays if they are not<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">This comment is incomplete.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+ void dropTriviallyDeadConstantArrays();<br class="">};<br class=""><br class="">}<br class="">Index: lib/Linker/LinkModules.cpp<br class="">===================================================================<br class="">--- lib/Linker/LinkModules.cpp<span class="Apple-tab-span" style="white-space: pre;"> </span>(revision 226024)<br class="">+++ lib/Linker/LinkModules.cpp<span class="Apple-tab-span" style="white-space: pre;"> </span>(working copy)<br class="">@@ -1721,7 +1721,9 @@<br class="">bool Linker::linkInModule(Module *Src) {<br class=""> ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src,<br class=""> DiagnosticHandler);<br class="">- return TheLinker.run();<br class="">+ bool RetCode = TheLinker.run();<br class="">+ Composite->dropTriviallyDeadConstantArrays();<br class="">+ return RetCode;<br class="">}<br class=""><br class="">//===----------------------------------------------------------------------===//</blockquote></div></blockquote></div><br class=""></div></body></html>