Issue 173749
Summary Fata backend error: "unable to legalize instruction" when compiling specific function for ez80.
Labels new issue
Assignees
Reporter GeometricParrot
    This is my first bug report for anything. I am eager to learn how I can improve if I made any mistakes.
I am working on a project for Ti84+ CE calculator and am using [https://github.com/CE-Programming/toolchain](url) to build which uses llvm to compile. I ran into the following error with clang while compiling. I created a smaller project to recreate it. This is the function that causes the error: 
```
unsigned char foo(unsigned char bar) {
	if (bar == 1)
		return bar + 1;
	else {
		return bar + foo(bar - 1);
	}
}
```
And this is the output.
```
C:\CEdev\bugs\CEdev\examples\hello_world>C:\\CEdev\\bugs\\CEdev\\bin\\ez80-clang.exe -S -mllvm -profile-guided-section-prefix=false -Wall -Wextra -Oz C:/CEdev/bugs/CEdev/examples/hello_world/obj/lto.bc -o C:/CEdev/bugs/CEdev/examples/hello_world/obj/lto.src
fatal error: error in backend: unable to legalize instruction: %9:_(s9) = G_CONSTANT i9 1 (in function: foo)
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\\\\bugs\\\\CEdev\\\\bin\\\\ez80-clang.exe -S -mllvm -profile-guided-section-prefix=false -Wall -Wextra -Oz C:/CEdev/bugs/CEdev/examples/hello_world/obj/lto.bc -o C:/CEdev/bugs/CEdev/examples/hello_world/obj/lto.src
1.      Code generation
2.      Running pass 'Function Pass Manager' on module 'C:/CEdev/bugs/CEdev/examples/hello_world/obj/lto.bc'.
3.      Running pass 'Legalizer' on function '@foo'
Exception Code: 0xE0000046
0x76711E54, C:\WINDOWS\System32\KERNELBASE.dll(0x00000000765B0000) + 0x161E54 byte(s), RaiseException() + 0x64 byte(s)
0x007871E6, C:\CEdev\bugs\CEdev\bin\ez80-clang.exe(0x0000000000390000) + 0x3F71E6 byte(s)
0x01000000, C:\CEdev\bugs\CEdev\bin\ez80-clang.exe(0x0000000000390000) + 0xC70000 byte(s)
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 15.0.7 (https://github.com/CE-Programming/llvm-project 263e6374ab7ac991c1bac4ed5ae7821242623cc5)
Target: ez80
Thread model: posix
InstalledDir: C:\\CEdev\\bugs\\CEdev\\bin
ez80-clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
```
Reading the how to submit a bug instructions tells me to also attach this .bc file. Github didn't like that format so I threw a .txt on the end but did not modify it.

[foo.bc.txt](https://github.com/user-attachments/files/24357402/foo.bc.txt)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to