[LLVMdev] [cfe-dev] weak_odr constant versus weak_odr global

Rafael Espíndola rafael.espindola at gmail.com
Mon Nov 21 09:05:47 PST 2011


> Unfortunately, making the comdat be for the entire function is not
> conformant with the ABI, which says that you either put the variable
> and its guard in different comdats or you put them in a single comdat
> named for the variable.  It also doesn't actually help unless we disable
> inlining.

I see. Using two comdats would still cause the same problem for us,
no? So the solution in the end is to emit:

TU1:
--------------------------------
@_ZN1UI1SE1kE = weak_odr constant i32 42, align 4, comdat _ZN1UI1SE1kE
@_ZGVN1UI1SE1kE = weak_odr global i64 1, comdat _ZN1UI1SE1kE
--------------------------------

TU2:
-----------------------------------
@_ZN1UI1SE1kE = weak_odr global i32 0, align 4, comdat _ZN1UI1SE1kE
@_ZGVN1UI1SE1kE = weak_odr global i64 0, comdat _ZN1UI1SE1kE
...
@llvm.global_ctors = ....
define internal void @_GLOBAL__I_a() nounwind section ".text.startup" ....
-----------------------------------

>
> John.

Thanks,
Rafael




More information about the llvm-dev mailing list