Eric Botcazou wrote:
-ftrapv is not practically usable because (1) it generates awful code and
(2) it badly interacts with the RTL optimizers.

please before you say this compare it with the truly awful front end
code we generate, which for sure inteferes badly with the optimizers.


Right, the code generated by the front end is not pretty either, but at least the front-end knows what it is doing Ada-wise. -ftrapv is so dumb at the moment that it emits checks for virtually anything.

No, it just emits it for signed operations. If we use -ftrapv, then we have
to make sure that operations labeled by the front end as not requiring an
overflow check are transformed into unsigned operations by gigi.

As for the interaction with the optimizers:

int foo(int a, int b)
{
  return a + b;
}

gcc -S -O -ftrapv on SPARC:
foo:
        jmp     %o7+8
         add    %o0, %o1, %o0
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.1.0 20050604 (experimental)"

And I have a slightly more contrived example with the same problem at -O0!

I don't see that's so terrible, the jmp will be free in practice anyway
so I don't think you will find this slows things down.


I think we cannot use -ftrapv alone for Ada because it is too low-level. Its general mechanism certainly can help (once it is fixed) but it must be driven by something more Ada-aware.

Again, please compare it with the simply awful mechanism used by the
front end right now.




Reply via email to