[llvm-commits] [patch] Enable unnamed_addr in declarations again

Nick Lewycky nicholas at mxc.ca
Sat Jan 15 00:01:08 PST 2011


Rafael Ávila de Espíndola wrote:
>> * module 1 has strong const unnamed_addr symbol foo and an internal
>> unnamed_add const bar with the same init as foo
>> * module 2 has weak symbols foo and its address matters
>>
>> We optimize 1 and constmerge does its job and bar is merged with foo. We
>> now link 1 and 2, and 2's assumptions are already wrong.
>
> Sorry for replying to myself, but this is still a bit confusing to me.
>
> I think I understand you now. If we say that a symbol whose address
> matters is only guaranteed to have an address different from all other
> symbols whose address matters, we get a much simpler model. Maybe that
> is what you were thinking.

Yes exactly. The only gotcha is that for non-local-linkage unnamed_addr, 
the address has to be irrelevant for everyone we link to too.

  Under these rules
>
> * Constmerge *can* merge two constants as long as *one* of them is
> unnamed_addr. The resulting constant is unnamed_addr if and only if both
> original ones are.
> * Weak symbols are really not an exception and the linker always uses an
> 'and' in all cases.

Yep!

Nick

>
> I will give that a try, thanks a lot.
>
> Cheers,
> Rafael
>




More information about the llvm-commits mailing list