> >
> > I would add a dump file which shows what asm statements made symbol to
> > go global for easier debugging later (I suppose eventually this may get
> > us surprises)
> > > +
> > > + l = 0;
> > > + }
> > > +
> > > + /* Prevent overflow. */
> > > + if (l >= ident_buffer_size)
> > > + {
> > > + ident_buffer_size *= 2;
> > > + ident = (char*) xrealloc (ident, ident_buffer_size);
> >
> > Perhas auto_vec<char> and safe_push would be more readable (and less
> > effecient) way to do this in this millenia?
> > Honza
>
> Changes in v3:
> Applied the suggested changes.
>
> ---
>
> This new pass heuristically detects symbols referenced by toplevel
> assembly to prevent their optimization.
>
> Heuristics is done by comparing identifiers in assembly to known
> symbols.
>
> The pass is split into 2 passes, in LGEN and in WPA.
> There must be one pass for WPA to be able to reference any symbol.
> However in WPA there may be multiple symbols with the same name,
> so we handle those local symbols in LGEN.
>
> gcc/ChangeLog:
>
> * asm-toplevel.cc (mark_fragile_ref_by_asm):
> Add marked_local to handle symbol as local.
> (ipa_asm_heuristics): New.
> (class pass_ipa_asm): New.
> (make_pass_ipa_asm_lgen): New.
> (make_pass_ipa_asm_wpa): New.
> * common.opt: New flto-toplevel-asm-heuristics.
> * passes.def: New asm passes.
> * timevar.def (TV_IPA_LTO_ASM): New.
> * tree-pass.h (make_pass_ipa_asm_lgen): New.
> (make_pass_ipa_asm_wpa): New.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/lto/toplevel-simple-asm-1_0.c: New test.
> * gcc.dg/lto/toplevel-simple-asm-1_1.c: New test.
> * gcc.dg/lto/toplevel-simple-asm-2_0.c: New test.
> * gcc.dg/lto/toplevel-simple-asm-2_1.c: New test.
OK,
Honza