Issue 76402
Summary [compiler-rt][builtins][PPC] Compiler-rt builtins divtc3 compilation crashes compiler backend
Labels new issue
Assignees
Reporter Ubsefor
    PowerPC DAG->DAG Pattern Instruction Selection fails to run on __divtc3 function (code example below) with PowerPC targets

After changes, applied in 696ea67f197ff0818cb649db61d51df8e81eb16e

Broken after changes by 7d6c2e18114de9900d1b012cf9c219803b183f63

example of code (from divtc3.c):

```c
long double _Complex __divtc3_test(long double __a, long double __b,
                                  long double __c, long double __d) {
  int __ilogbw = 0;
  long double __logbw =
 __builtin_logbl(__builtin_fmaxl(__builtin_fabsl(__c), __builtin_fabsl(__d)));
  if (__builtin_isfinite(__logbw)) {
 __ilogbw = (int)__logbw;
    __c = __builtin_scalbnl(__c, -__ilogbw);
 __d = __builtin_scalbnl(__d, -__ilogbw);
  }
  return 0;
}
```

Compile command: clang -O3 -std=gnu99 -ffreestanding -fno-short-enums -nostdlib -target powerpc-gnu-linux-eabi -mcpu=e500mc -msoft-float -ffp-contract=off -v -c divtc3.c -o divtc3.o

Full compiler log: 
<details>

```sh
clang -O3 -std=gnu99 -ffreestanding -fno-short-enums -nostdlib -target powerpc-gnu-linux-eabi -mcpu=e500mc -msoft-float -ffp-contract=off -v -I./crtextra -c src/llvm-project-17.0.6.src/compiler-rt/lib/builtins/divtc3.c -o divtc3.o
clang version 17.0.6
Target: powerpc-gnu-linux-eabi
Thread model: posix
InstalledDir: /bin
 (in-process)
 "/bin/clang-17" -cc1 -triple powerpc-gnu-linux-eabi -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name divtc3.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=off -fno-rounding-math -mconstructor-aliases -ffreestanding -target-cpu e500mc -target-feature -hard-float -msoft-float -mfloat-abi soft -debugger-tuning=gdb -target-linker-version 1022.1 -v -fcoverage-compilation-dir=./ -resource-dir /lib/clang/17 -I ./crtextra -internal-isystem /lib/clang/17/include/ppc_wrappers -internal-isystem /lib/clang/17/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=gnu99 -fdebug-compilation-dir=./ -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o divtc3.o -x c src/llvm-project-17.0.6.src/compiler-rt/lib/builtins/divtc3.c
clang -cc1 version 17.0.6 based upon LLVM 17.0.6 default target arm64-apple-darwin23.2.0
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 ./crtextra
 /lib/clang/17/include/ppc_wrappers
 /lib/clang/17/include
 /usr/local/include
End of search list.
fatal error: error in backend: Do not know how to soften the result of this operator!
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: clang -O3 -std=gnu99 -ffreestanding -fno-short-enums -nostdlib -target powerpc-gnu-linux-eabi -mcpu=e500mc -msoft-float -ffp-contract=off -v -I./crtextra -c src/llvm-project-17.0.6.src/compiler-rt/lib/builtins/divtc3.c -o divtc3.o
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'src/llvm-project-17.0.6.src/compiler-rt/lib/builtins/divtc3.c'.
4.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__divtc3'
 #0 0x0000000105b03acc (/bin/clang-17+0x10121bacc)
 #1 0x0000000105b03508 (/bin/clang-17+0x10121b508)
 #2 0x0000000105a90bc8 (/bin/clang-17+0x1011a8bc8)
 #3 0x0000000105a90b78 (/bin/clang-17+0x1011a8b78)
 #4 0x0000000105b004c8 (/bin/clang-17+0x1012184c8)
 #5 0x00000001048eeb80 (/bin/clang-17+0x100006b80)
 #6 0x0000000105a96f74 (/bin/clang-17+0x1011aef74)
 #7 0x0000000105a96e48 (/bin/clang-17+0x1011aee48)
 #8 0x0000000106434ce8 (/bin/clang-17+0x101b4cce8)
 #9 0x000000010645bc4c (/bin/clang-17+0x101b73c4c)
#10 0x000000010645db70 (/bin/clang-17+0x101b75b70)
#11 0x00000001064fb6f4 (/bin/clang-17+0x101c136f4)
#12 0x00000001064fb3f8 (/bin/clang-17+0x101c133f8)
#13 0x00000001064f9ebc (/bin/clang-17+0x101c11ebc)
#14 0x0000000104ce6520 (/bin/clang-17+0x1003fe520)
#15 0x000000010532b75c (/bin/clang-17+0x100a4375c)
#16 0x00000001055c2768 (/bin/clang-17+0x100cda768)
#17 0x00000001055c5e98 (/bin/clang-17+0x100cdde98)
#18 0x00000001055c2b40 (/bin/clang-17+0x100cdab40)
#19 0x0000000105d48468 (/bin/clang-17+0x101460468)
#20 0x0000000105f8c378 (/bin/clang-17+0x1016a4378)
#21 0x0000000106bfdf90 (/bin/clang-17+0x102315f90)
#22 0x00000001061b76c4 (/bin/clang-17+0x1018cf6c4)
#23 0x0000000106170fb4 (/bin/clang-17+0x101888fb4)
#24 0x0000000106206914 (/bin/clang-17+0x10191e914)
#25 0x00000001048ee7c4 (/bin/clang-17+0x1000067c4)
#26 0x00000001048ec6e4 (/bin/clang-17+0x1000046e4)
#27 0x000000010606d9b0 (/bin/clang-17+0x1017859b0)
#28 0x0000000105a90b50 (/bin/clang-17+0x1011a8b50)
#29 0x000000010606d428 (/bin/clang-17+0x101785428)
#30 0x00000001060496e4 (/bin/clang-17+0x1017616e4)
#31 0x0000000106049800 (/bin/clang-17+0x101761800)
#32 0x0000000106058df0 (/bin/clang-17+0x101770df0)
#33 0x00000001048ec1a4 (/bin/clang-17+0x1000041a4)
#34 0x00000001048f5f74 (/bin/clang-17+0x10000df74)
#35 0x00000001814150e0
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 17.0.6
Target: powerpc-gnu-linux-eabi
Thread model: posix
InstalledDir: /bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/divtc3-784c30.c
clang: note: diagnostic msg: /tmp/divtc3-784c30.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/USER/Library/Logs/DiagnosticReports/clang-17_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:

********************
```
Note: Shorter version of diagnostic files is attached above, some paths are trimmed
</details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to