[llvm] r193718 - Produce .weak_def_can_be_hidden for some linkonce_odr values

Rafael Espíndola rafael.espindola at gmail.com
Fri Feb 7 08:29:31 PST 2014


> 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.

Cheers,
Rafael




More information about the llvm-commits mailing list