This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is it a bug allowing to copy GIMPLE_ASM with labels?
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Alexander Monakov <amonakov at ispras dot ru>
- Cc: "Bin.Cheng" <amker dot cheng at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Sat, 29 Dec 2018 08:40:59 -0600
- Subject: Re: Is it a bug allowing to copy GIMPLE_ASM with labels?
- References: <CAHFci29NA3-eZ3GN+O=hYFNEjbFt4==VAhnuBPJqLY_x+re0WA@mail.gmail.com> <alpine.LNX.2.20.13.1812291038290.25673@monopod.intra.ispras.ru>
Hi!
On Sat, Dec 29, 2018 at 10:41:54AM +0300, Alexander Monakov wrote:
> On Sat, 29 Dec 2018, Bin.Cheng wrote:
> > tracer-1.c: Assembler messages:
> > tracer-1.c:16: Error: symbol `foo_label' is already defined
> >
> > Root cause is in tracer.c which duplicates basic block without
> > checking if any GIMPLE_ASM defines labels.
> > Is this a bug or invalid code?
>
> This is invalid code, GCC documentation is clear that the compiler
> may duplicate inline asm statements (passes other than tracer can do
> that too, loop unswitching just to give one example).
>
> We don't provide a way to write an asm that wouldn't be duplicated.
But should there be? Is there (valid!) code for which it would be more
convenient?
We already have a hook targetm.cannot_copy_insn_p with which targets can
say not to copy certain insns. It will be trivial to do something like
that for "asm restrict" (or whatever is a better name :-) ) (so make some
cannot_copy_insn_p that for asm checks that flag, and for everything else
uses the hook... something like that).
Segher