[macppc] clang-10: issue with ppc dag to dag pattern instruction selection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[macppc] clang-10: issue with ppc dag to dag pattern instruction selection

Charlene Wendling
Hi,

In the current macppc bulk, graphics/babl and emulators/mednafen are
failing similarly with:

> 1.      <eof> parser at end of file
> 2.      Code generation
> 3.      Running pass 'Function Pass Manager' on module
> '../babl-0.1.80/babl/base/model-ycbcr.c'.
> 4.      Running pass 'PowerPC DAG->DAG Pattern Instruction Selection'
> on function '@rgba_to_ycbcr'
> cc: error: clang frontend command failed  due to signal (use -v to
> see invocation)

While the current bulk uses clang 10.0.0, George has been able to
reproduce the issue with emulators/mednafen with 10.0.1. I'm attaching
the reproduction cases.

Charlène.

clang10_dag2dag.tgz (1M) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [macppc] clang-10: issue with ppc dag to dag pattern instruction selection

George Koehler-2
On Tue, 18 Aug 2020 08:39:30 +0200
Charlene Wendling <[hidden email]> wrote:

> In the current macppc bulk, graphics/babl and emulators/mednafen are
> failing similarly with:
>
> > 1.      <eof> parser at end of file
> > 2.      Code generation
> > 3.      Running pass 'Function Pass Manager' on module
> > '../babl-0.1.80/babl/base/model-ycbcr.c'.
> > 4.      Running pass 'PowerPC DAG->DAG Pattern Instruction Selection'
> > on function '@rgba_to_ycbcr'
> > cc: error: clang frontend command failed  due to signal (use -v to
> > see invocation)

babl and mednafen are passing -fno-unsafe-math-optimizations to clang;
this flag implies -ftrapping-math, which seems to be broken in the
PowerPC backend.  Another name for -ftrapping-math is
-ffp-exception-behavior=strict

mednafen is also broken on powerpc64 (but the error message is
different: "Cannot select: ...: i64 = fp_to_sint ...");
babl has a powerpc64 snap package.

One may run the crash reproducers on any clang with the PowerPC
backend, like base-clang on powerpc64, or ports-clang on amd64 (after
you edit the .sh to use ports-clang); but mednafen's reproducer from
macppc doesn't crash on powerpc64 nor amd64.  By not crashing, it
emits a 32-bit PowerPC elf.

I reproduced a crash on amd64 by taking medafen's reproducer from
powerpc64.  I edited the reproducer to remove most cc1 flags.
Removing -ffp-exception-behavior=strict prevents the crash.  So far,
I have used clang 10.0.1.  If I use clang-12 (from upstream's git
master), then no crash happens; clang-12 warns,

warning: overriding currently unsupported use of floating point exceptions on th
is target [-Wunsupported-floating-point-opt]

Upstream might have disabled -ftrapping-math for PowerPC to work
around the bug.  To be more sure, I need to try building babl or
mednafen on macppc without -fno-unsafe-math-optimizations.  If that
works, I will want to backport something from upstream.

--George

Reply | Threaded
Open this post in threaded view
|

Re: [macppc] clang-10: issue with ppc dag to dag pattern instruction selection

George Koehler-2
On Thu, 27 Aug 2020 22:34:23 -0400
George Koehler <[hidden email]> wrote:

> babl and mednafen are passing -fno-unsafe-math-optimizations to clang;
> this flag implies -ftrapping-math, which seems to be broken in the
> PowerPC backend.  Another name for -ftrapping-math is
> -ffp-exception-behavior=strict

I want to correct the record: -ftrapping-math is not exactly the same
as -ffp-exception-behavior=strict.

When you pass -fno-unsafe-math-optimizations to clang, it passes
-ffp-exception-behavior=strict to the internal cc1.  The strict
flag enables at least -ftrapping-math and -frounding-math.  The
problem with mednafen on powerpc64 is in -frounding-math, not
-ftrapping-math.

I confirm that deleting -fno-unsafe-math-optimizations fixes the builds
of babl and mednafen on macppc.  I am waiting for my macppc to build
clang with a backport of llvm 11's
https://github.com/llvm/llvm-project/commit/d4ce862