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

Division by multiple of 3 causes compiler to crash #31

Closed mateoconlechuga closed 1 year ago

mateoconlechuga commented 1 year ago
int a(int b) { return b / (__SIZE_TYPE__)3; }

This causes a compiler crash when compiled with any -O flag except -Oz:

fatal error: error in backend: unable to legalize instruction: %21:_(s48) = G_LSHR %19:_, %22:_(s8) (in function: a)
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: /home/hew/CEdev/bin/ez80-clang -S -Os src/main.c
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'src/main.c'.
4.  Running pass 'Legalizer' on function '@a'
 #0 0x000000000201d1e3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/hew/CEdev/bin/ez80-clang+0x201d1e3)
 #1 0x000000000201b10e llvm::sys::RunSignalHandlers() (/home/hew/CEdev/bin/ez80-clang+0x201b10e)
 #2 0x000000000201c70d llvm::sys::CleanupOnSignal(unsigned long) (/home/hew/CEdev/bin/ez80-clang+0x201c70d)
 #3 0x0000000001f94e2a (/home/hew/CEdev/bin/ez80-clang+0x1f94e2a)
 #4 0x0000000001f94dcb (/home/hew/CEdev/bin/ez80-clang+0x1f94dcb)
 #5 0x00000000020174c7 llvm::sys::Process::Exit(int, bool) (/home/hew/CEdev/bin/ez80-clang+0x20174c7)
 #6 0x00000000011d0dc2 (/home/hew/CEdev/bin/ez80-clang+0x11d0dc2)
 #7 0x0000000001f98a38 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/hew/CEdev/bin/ez80-clang+0x1f98a38)
 #8 0x0000000002de4fa4 (/home/hew/CEdev/bin/ez80-clang+0x2de4fa4)
 #9 0x0000000002de52cd llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, char const*, llvm::StringRef, llvm::MachineInstr const&) (/home/hew/CEdev/bin/ez80-clang+0x2de52cd)
#10 0x0000000002d8d175 llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) (/home/hew/CEdev/bin/ez80-clang+0x2d8d175)
#11 0x00000000015957ee llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/hew/CEdev/bin/ez80-clang+0x15957ee)
#12 0x0000000001959a8d llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/hew/CEdev/bin/ez80-clang+0x1959a8d)
#13 0x000000000195f703 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/hew/CEdev/bin/ez80-clang+0x195f703)
#14 0x000000000195a0cf llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/hew/CEdev/bin/ez80-clang+0x195a0cf)
#15 0x000000000229d914 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/hew/CEdev/bin/ez80-clang+0x229d914)
#16 0x0000000002b066f8 (/home/hew/CEdev/bin/ez80-clang+0x2b066f8)
#17 0x00000000039c3b03 clang::ParseAST(clang::Sema&, bool, bool) (/home/hew/CEdev/bin/ez80-clang+0x39c3b03)
#18 0x0000000002a592a7 clang::FrontendAction::Execute() (/home/hew/CEdev/bin/ez80-clang+0x2a592a7)
#19 0x00000000029d0aa6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/hew/CEdev/bin/ez80-clang+0x29d0aa6)
#20 0x0000000002b00c6b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/hew/CEdev/bin/ez80-clang+0x2b00c6b)
#21 0x00000000011d0a78 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/hew/CEdev/bin/ez80-clang+0x11d0a78)
#22 0x00000000011cebab (/home/hew/CEdev/bin/ez80-clang+0x11cebab)
#23 0x0000000002858a42 (/home/hew/CEdev/bin/ez80-clang+0x2858a42)
#24 0x0000000001f94dad llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/hew/CEdev/bin/ez80-clang+0x1f94dad)
#25 0x0000000002858574 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/home/hew/CEdev/bin/ez80-clang+0x2858574)
#26 0x000000000281bae4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/hew/CEdev/bin/ez80-clang+0x281bae4)
#27 0x000000000281bf77 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/hew/CEdev/bin/ez80-clang+0x281bf77)
#28 0x00000000028386f8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/hew/CEdev/bin/ez80-clang+0x28386f8)
#29 0x00000000011ce2b7 main (/home/hew/CEdev/bin/ez80-clang+0x11ce2b7)
#30 0x00007fa6b7c97083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#31 0x00000000011cb8ae _start (/home/hew/CEdev/bin/ez80-clang+0x11cb8ae)
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 6d9aa7a16db70f3d02ae304b08d4a03011281fef)
Target: ez80
Thread model: posix
InstalledDir: /home/hew/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: /tmp/main-b2e0d4.c
ez80-clang: note: diagnostic msg: /tmp/main-b2e0d4.sh
ez80-clang: note: diagnostic msg: 

********************