[patch] Produce .weak_def_can_be_hidden for some linkonce_odr values
Nick Lewycky
nlewycky at google.com
Mon Oct 28 20:30:50 PDT 2013
On 28 October 2013 19:56, Rafael EspĂndola <rafael.espindola at gmail.com>wrote:
> Ping.
>
- if (Linkage != GlobalValue::LinkOnceODRAutoHideLinkage)
+
+ bool CanBeHidden = Linkage ==
GlobalValue::LinkOnceODRAutoHideLinkage;
+
+ if (!CanBeHidden && Linkage == GlobalValue::LinkOnceODRLinkage) {
+ if (GV->hasUnnamedAddr()) {
+ CanBeHidden = true;
+ } else {
+ GlobalStatus GS;
+ if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
Ah, really? Put another way, why should we pay this penalty *here*? This is
something we can compute in the mid-level optimizer and should compute in
the mid-level optimizer, and we shouldn't waste our time second-guessing it
here.
I assume the real problem is that we don't do a second run of globalopt at
the end of the TU to mark more things with unnamed_addr? How much do we
lose if you don't do this recomparison, is that tolerable? I realize that
getting a second run of globalopt at the end is going to be time consuming
to prove worthwhile, but I really think it's the right way to go.
+ CanBeHidden = true;
+ }
+ }
+
+ if (!CanBeHidden)
Everything else about the patch LGTM.
I just tested this with the linker in Xcode 5 and the results are:
>
> $ nm build-with-master/bin/clang-3.4 | grep ' T ' | wc
>
> 21053 63159 1790901
>
> $ nm build-with-patch/bin/clang-3.4 | grep ' T ' | wc
>
> 19049 57147 1547425
>
Nice!!
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131028/43c0f989/attachment.html>
More information about the llvm-commits
mailing list