[MLton] fixing -codegen c -profile time for the release

Florian Weimer fw@deneb.enyo.de
Wed, 16 Nov 2005 19:07:36 +0100

> Why would it blindly duplicate a block?

Inlining and various kinds of loop optimizations are like culprits.

> Is it assuming the block contains only local symbols??

Yes, it does.  More precisely, it expects that you use relative labels

> Gcc is not free to duplicate code that contains a global symbol.

GCC expects that you don't don't declare symbols in asm statements.

> And the labels are marked global,
> and gcc knows it (that's what the "g" annotation
> is for I think).

No, "g" means "any register, memory or immediate operand".  Your
snippet works by sheer luck only.

Mike Stump mentioned the %= variable, documented as:

|  `%=' outputs a number which is unique to each instruction in the
| entire compilation.  This is useful for making local labels to be
| referred to more than once in a single template that generates multiple
| assembler instructions.

The problem with that one is that you can't easily put in a reference
elsewhere to a label which contains such a unique nimber.

> I presume you have a specific test case where gcc is doing this ..
> I'm kind of curious what makes it think it can duplicate a pubdef.

extern int foo (int);

void bla (void)
  int i, n = foo (0);

  for (i = 0; (({{  __asm__ volatile ("foo_label:"); }}), i < n); i++)
    foo (i);

The statement expression is not strictly required, I think.  I just
started with the gcc.dg/tree-ssa/copy-headers.c test case and made a
minimal change to show the problem.

See <http://gcc.gnu.org/ml/gcc/2005-11/msg00593.html> for further