[llvm] r193718 - Produce .weak_def_can_be_hidden for some linkonce_odr values
John McCall
rjmccall at apple.com
Fri Feb 7 10:41:55 PST 2014
On Feb 7, 2014, at 8:29 AM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>> Hey, Rafael. Sorry to dredge up old-ish history. This is a great idea, but:
>>
>>> + if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
>>> + CanBeHidden = true;
>>
>> This doesn’t seem to be a complete list of conditions where this is safe. For a
>> mutable object, either a load or a store could require the object to be uniqued
>> across dynamic library boundaries to get the right semantics.
>>
>> Actually, I’m not sure what uses a mutable linkonce_odr object could possibly
>> have that would allow it to be hidden.
>
> Gosh. Thanks for catching this!
>
>> Of course, for an immutable object (like a Function or a const GlobalVariable),
>> loads and stores don’t matter; and it’s always allowed if unnamed_addr is
>> present.
>>
>> Simple clang test case:
>> inline int foo() {
>> static int CallCount = 0;
>> return CallCount++;
>> }
>>
>> int next() {
>> return foo();
>> }
>>
>> .section __DATA,__datacoal_nt,coalesced
>> .globl __ZZ3foovE9CallCount ## @_ZZ3foovE9CallCount
>> .weak_def_can_be_hidden __ZZ3foovE9CallCount
>> .align 2
>> __ZZ3foovE9CallCount:
>> .long 0 ## 0x0
>
> Fixed in r200977. Sorry for the breakage.
No problem. I actually only caught it by inspection — I was digging out a different problem exposed by this (but not your fault).
Thanks!
John.
More information about the llvm-commits
mailing list