jacobly0 / llvm-project

This fork of the canonical git mirror of the LLVM subversion repository adds (e)Z80 targets. Please refer to the wiki for important build instructions.
https://github.com/jacobly0/llvm-project/wiki
123 stars 15 forks source link

Error in backend when using powf() with -Ofast #24

Closed PeterTillema closed 2 years ago

PeterTillema commented 2 years ago

Minimal code to reproduce:

#include <debug.h>
#include <math.h>
#include <stdint.h>

int main(int argc, char *argv[]) {
    float num = powf(10, (float) argc);

    // This line only exists such that "num" doesn't get optimized away
    dbg_sprintf(dbgout, "%f\n", num);

    return 0;
}

Compile this program with the -Ofast flag and using make debug. I get this error:

fatal error: error in backend: unable to legalize instruction: %7:_(s32) = nnan ninf nsz arcp contract afn reassoc G_FEXP2 %6:_ (in function: __main_argc_argv)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\CEdev\\bin\\ez80-clang.exe -S -nostdinc -isystem C:\\CEdev\\include -Isrc -Dinterrupt=__attribute__((__interrupt__)) -fno-threadsafe-statics -Xclang -fforce-mangle-main-argc-argv -mllvm -profile-guided-section-prefix=false -D_EZ80 -DDEBUG -DHAS_PRINTF=1 -gdwarf-5 -g3 -Wall -Wextra -Ofast C:/XXX/XXX/src/main.c -o C:/XXX/XXX/obj/src/main.c.src
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'C:/XXX/XXX/src/main.c'.
4.      Running pass 'Legalizer' on function '@__main_argc_argv'
0x771AB822 (0xE0000046 0x00000000 0x00000000 0x00000000), RaiseException() + 0x62 bytes(s)
0x011BFED6 (0x006D0D20 0x00000080 0x0000008F 0x03665CF4)
0x75E73C68 (0x006D0D20 0x0000008F 0x016DDBF5 0x006D0D20), free() + 0x18 bytes(s)
0x03665CF4 (0x006D0D20 0x016DDC03 0x036D22B0 0x00000000)
0x016DDBF5 (0x036D22B0 0x00000000 0x00000000 0x00000000)
0x016DDC03 (0x0484CD00 0x00000001 0x0484CD50 0x3FF26297)
0x011C0331 (0x009A0FB0 0x006F31D0 0x0484CF70 0x03B796DB)
0x013CB096 (0x009A0FB0 0x009A0FB0 0x009A0FB0 0x777A6600)
0x0138F68E (0x00741C44 0x00742190 0x0079DAA8 0x00000001)
0x00F1D2CC (0x00741C44 0x0079DAA8 0x00000000 0x00742C88)
0x00F22390 (0x00742C88 0x0484D3D0 0x00000002 0x00000001)
0x00F1D782 (0x00742C88 0x0000000F 0x92004000 0x0484E2F8)
0x01AA7190 (0x00000000 0x006F8138 0x00000000 0x00742C88)
0x01AA3E58 (0x006FDAC8 0x006F6F28 0x006F64D0 0x006F60C0)
0x01DBD33E (0x00733A68 0x00F24A07 0x0075CF68 0x0072A4C8)
0x029D02DC (0x00757EA0 0x00000000 0x00000000 0x0484E4C8)
0x01D2AF36 (0x00000007 0x3FF2483B 0x00000038 0x006FA798)
0x01D2AAAD (0x0484E69C 0x00000003 0x006F2B98 0x006F2B98)
0x012D7664 (0x006F8880 0x776B1213 0x006F2B98 0x006A6730)
0x0136DD18 (0x006F2B98 0x006A6730 0x00000001 0x0484E6F4)
0x776B1213 (0x006F8880 0x00000000 0x00000000 0x0484EC3C), RtlRunOnceComplete() + 0x73 bytes(s)
0x771AA544 (0x03D014D8 0x3FF2488F 0x006A6730 0x006F2B98), InitOnceComplete() + 0x14 bytes(s)
0x0120E0AD (0x0484ED48 0x00000047 0x006C2110 0x00DE1000)
0x00DE3AF0 (0x00000080 0x006C2110 0x03C9AFEF 0x03B89B99)
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 14.0.0 (https://github.com/jacobly0/llvm-project a139def90d26173f771eb1eca797633d1fbb2797)
Target: ez80
Thread model: posix
InstalledDir: C:\CEdev\bin
ez80-clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
ez80-clang: note: diagnostic msg: C:\Users\peter\AppData\Local\Temp\main-c4b151.c
ez80-clang: note: diagnostic msg: C:\Users\peter\AppData\Local\Temp\main-c4b151.sh
ez80-clang: note: diagnostic msg:

********************
make: *** [obj/src/main.c.src] Error 70
adriweb commented 2 years ago

Can confirm, with -Ofast and compiling in debug, I get the error on the latest version too (d3040c334d3ff4280ee73e71082761a9cff7a847):

fatal error: error in backend: unable to legalize instruction: %7:_(s32) = nnan ninf nsz arcp contract afn reassoc G_FEXP2 %6:_ (in function: __main_argc_argv)