r218287 - Don't use comdats for initializers on platforms that don't support it

Reid Kleckner rnk at google.com
Tue Sep 23 15:01:46 PDT 2014


Yes, it's globalopt. Here's the reduction:

$ cat t.ll
$comdat_global = comdat any
@comdat_global = weak_odr global i8 0, comdat $comdat_global
@simple_global = internal global i8 0
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [
    { i32, void ()*, i8* } { i32 65535, void ()* @init_comdat_global, i8*
@comdat_global },
    { i32, void ()*, i8* } { i32 65535, void ()* @init_simple_global, i8*
null }
]
define void @init_comdat_global() {
  store i8 42, i8* @comdat_global
  ret void
}
define void @init_simple_global() comdat $comdat_global {
  store i8 42, i8* @simple_global
  ret void
}

$ opt t.ll -globalopt -S -o -
; ModuleID = 't.ll'

$comdat_global = comdat any

@comdat_global = weak_odr global i8 0, comdat $comdat_global
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32,
void ()*, i8* } { i32 65535, void ()* @init_comdat_global, i8* null }]

define void @init_comdat_global() {
  store i8 42, i8* @comdat_global
  ret void
}

define void @init_simple_global() comdat $comdat_global {
  ret void
}

Note the missing comdat field in global_ctors.

On Tue, Sep 23, 2014 at 11:52 AM, Reid Kleckner <rnk at google.com> wrote:

> I reverted this. It needs more investigation. With optimizations enabled,
> I'm seeing a comdat group that looks like:
>
> COMDAT group section [    2] `.group' [_ZN...kNameE] contains 4 sections:
>    [Index]    Name
>    [   43]   .text.startup
>    [   76]   .bss._ZN...kNameE
>    [   83]   .bss._ZGV..kNameE
>    [   44]   .rela.text.startup
>
> Note that there is no .ctors section in the group. Maybe -globalopt fired?
>
> On Mon, Sep 22, 2014 at 9:39 PM, Anton Korobeynikov <
> anton at korobeynikov.info> wrote:
>
>> Yeah, the only difference between .ctors and .init_array is the order
>> which the initializers are emitted in the section in.
>>
>> On Tue, Sep 23, 2014 at 4:58 AM, Rafael Avila de Espindola
>> <rafael.espindola at gmail.com> wrote:
>> >
>> >
>> > Sent from my iPhone
>> >
>> > On Sep 22, 2014, at 20:55, Reid Kleckner <rnk at google.com> wrote:
>> >
>> > On Mon, Sep 22, 2014 at 5:32 PM, Rafael Avila de Espindola
>> > <rafael.espindola at gmail.com> wrote:
>> >>
>> >>
>> >> > URL: http://llvm.org/viewvc/llvm-project?rev=218287&view=rev
>> >> > Log:
>> >> > Don't use comdats for initializers on platforms that don't support it
>> >> >
>> >> > In particular, pre-.init_array ELF uses the .ctors section mechanism.
>> >> > MinGW COFF also uses .ctors, now that I think about it.
>> >>
>> >> Why doesn't it work with .ctors? It is just a list of pointers like
>> >> .init_array.
>> >
>> >
>> > I didn't think it was implemented. Are you saying it's possible and
>> should
>> > be easy, or that it should already work? We're having issues with my
>> > favorite gold error, "relocation refers to discarded section".
>> >
>> >
>> > I though I had implemented comdat in both .ctors and .init_array in the
>> same
>> > commit in LLVM.
>> >
>> > Would you mind reporting a bug with a testcase that used to fail? I will
>> > take a look as soon as I get back.
>> >
>> > Thanks,
>> > Rafael
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>>
>>
>>
>> --
>> With best regards, Anton Korobeynikov
>> Faculty of Mathematics and Mechanics, Saint Petersburg State University
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140923/f094ddce/attachment.html>


More information about the cfe-commits mailing list