llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Certain 48 bit operations still aren't being legalized

Open fundudeone opened this issue 1 year ago • 1 comments

The compiler crashes and fails to legalize 48 bit not and comparison

fundudeone avatar Jan 14 '24 22:01 fundudeone

48-bit bswap fails

fatal error: error in backend: unable to legalize instruction: %5:_(s48) = G_BSWAP %0:_ (in function: i48bswap_)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\CEdev\\bin\\ez80-clang.exe -S -mllvm -profile-guided-section-prefix=false -Os -mllvm -inline-threshold=100 -Wall -Wextra C:/CEdev/examples/standalone_examples/math_test/obj/lto.bc -o C:/CEdev/examples/standalone_examples/math_test/obj/lto.src   
1.      Code generation
2.      Running pass 'Function Pass Manager' on module 'C:/CEdev/examples/standalone_examples/math_test/obj/lto.bc'.
3.      Running pass 'Legalizer' on function '@i48bswap_'
0x7675B282 (0xE0000046 0x00000000 0x00000000 0x00000000), RaiseException() + 0x62 bytes(s)
0x0087AFA6 (0x03010100 0x00000000 0x00000020 0x00000013)
0x01000000 (0x00000000 0x00000020 0x00000013 0x0000000A)
0x03010100 (0x00000020 0x00000013 0x0000000A 0x0000000A)
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 15.0.0 (https://github.com/CE-Programming/llvm-project 23b78267b5d376b232475d0805a937e54b61e0d0)
Target: ez80
Thread model: posix
InstalledDir: C:\CEdev\bin
ez80-clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

Demonstration: https://discord.com/channels/432891584451706892/1184990251769397380/1305595352837263361

Error compiling the code: int48_t foo(int48_t x) { return __builtin_bswap64(x) >> 16; }

runer112 avatar Nov 11 '24 17:11 runer112

I have a similar issue with a simple C function :

int nbdigits(intptr_t n) {
    int count = 0;
    while (n > 0) {
        n -= n%10;
        n /= 10;
        count ++;
    }
    return count;
}

The error is :

fatal error: error in backend: unable to legalize instruction: %33:_(s48) = G_LSHR %31:_, %34:_(s8)
      (in function: nbdigits)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\CEdev\\bin\\ez80-clang.exe -S -mllvm -profile-guided-section-prefix=false -O3 "C:/Users/rapha/Desktop/Dossier de travail Neon/repo/neon/build/ti_ez80/obj/lto.bc" -o "C:/Users/rapha/Desktop/Dossier de travail Neon/repo/neon/build/ti_ez80/obj/lto.src"
1.      Code generation
2.      Running pass 'Function Pass Manager' on module 'C:/Users/rapha/Desktop/Dossier de travail Neon/repo/neon/build/ti_ez80/obj/lto.bc'.
3.      Running pass 'Legalizer' on function '@nbdigits'
0x76410714 (0xE0000046 0x00000000 0x00000000 0x00000000), RaiseException() + 0x64 bytes(s)
0x00C71BA6 (0x654E0100 0x00000000 0x00000020 0x00000013)
0x01000000 (0x00000000 0x00000020 0x00000013 0x0000000A)
0x654E0100 (0x00000020 0x00000013 0x0000000A 0x0000000A) <unknown module>
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 15.0.0 (https://github.com/jacobly0/llvm-project 5f8512f22751066573aa48ac848a6d2195838ac3)
Target: ez80
Thread model: posix
InstalledDir: C:\CEdev\bin
ez80-clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
make: *** [obj/lto.src] Error 1

Bobb56 avatar Aug 30 '25 14:08 Bobb56

This repo isn't maintained anymore for now - have you tried on this fork? https://github.com/CE-Programming/llvm-project/

adriweb avatar Aug 30 '25 18:08 adriweb