llvm-mos / llvm-mos

Port of LLVM to the MOS 6502 and related processors
Other
416 stars 46 forks source link

rustc crash #442

Closed mrk-its closed 7 months ago

mrk-its commented 8 months ago

Following rust program: https://github.com/mrk-its/aoc2022/blob/main/day05/src/main.rs crashes the rusrc compiler. It may be reproduced by compiling attached file with mos-sim-clang:

mos-sim-clang target/mos-sim-none/release/deps/day05-c39004a0911df3d9.day05.a72b6b71c914faa1-cgu.0.rcgu.ll  -v
clang version 19.0.0git
Target: mos-sim
Thread model: posix
InstalledDir: /usr/local/bin
Configuration file: /usr/local/bin/mos-sim.cfg
 "/usr/local/bin/clang-19" -cc1 -triple mos-sim -emit-llvm-bc -flto=full -flto-unit -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name day05-c39004a0911df3d9.day05.a72b6b71c914faa1-cgu.0.rcgu.ll -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -nostdsysteminc -fexperimental-assignment-tracking=disabled -mllvm -force-precise-rotation-cost -mllvm -jump-inst-cost=6 -mllvm -force-loop-cold-block -mllvm -phi-node-folding-threshold=0 -mllvm -speculate-blocks=0 -mllvm -align-large-globals=false -mllvm -disable-spill-hoist -mllvm -lsr-complexity-limit=10000000 -debugger-tuning=gdb -fdebug-compilation-dir=/workspaces/aoc2022 -v -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/workspaces/aoc2022 -resource-dir /usr/local/lib/clang/19 -ferror-limit 19 -fshort-enums -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/day05-c39004a0911df3d9-995e31.o -x ir target/mos-sim-none/release/deps/day05-c39004a0911df3d9.day05.a72b6b71c914faa1-cgu.0.rcgu.ll
clang -cc1 version 19.0.0git based upon LLVM 19.0.0git default target mos-unknown-unknown
warning: overriding the module target triple with mos-sim [-Woverride-module]
1 warning generated.
 "/usr/local/bin/ld.lld" --gc-sections --sort-section=alignment /tmp/day05-c39004a0911df3d9-995e31.o -plugin-opt=-function-sections=1 -plugin-opt=-data-sections=1 -mllvm -force-precise-rotation-cost -mllvm -jump-inst-cost=6 -mllvm -force-loop-cold-block -mllvm -phi-node-folding-threshold=0 -mllvm -speculate-blocks=0 -mllvm -align-large-globals=false -mllvm -disable-spill-hoist -mllvm -lsr-complexity-limit=10000000 -mllvm -zp-avail=224 -L/usr/local/bin/../mos-platform/sim/lib -L/usr/local/bin/../mos-platform/common/lib -l:crt0.o -lcrt0 -lcrt -lc -Tlink.ld -o a.out
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/local/bin/ld.lld --gc-sections --sort-section=alignment /tmp/day05-c39004a0911df3d9-995e31.o -plugin-opt=-function-sections=1 -plugin-opt=-data-sections=1 -mllvm -force-precise-rotation-cost -mllvm -jump-inst-cost=6 -mllvm -force-loop-cold-block -mllvm -phi-node-folding-threshold=0 -mllvm -speculate-blocks=0 -mllvm -align-large-globals=false -mllvm -disable-spill-hoist -mllvm -lsr-complexity-limit=10000000 -mllvm -zp-avail=224 -L/usr/local/bin/../mos-platform/sim/lib -L/usr/local/bin/../mos-platform/common/lib -l:crt0.o -lcrt0 -lcrt -lc -Tlink.ld -o a.out
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'Finalize ISel and expand pseudo-instructions' on function '@main'
 #0 0x000055614a5ede63 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/ld.lld+0x6e5e63)
 #1 0x000055614a5ec6bc llvm::sys::RunSignalHandlers() (/usr/local/bin/ld.lld+0x6e46bc)
 #2 0x000055614a5ed261 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fdee7815520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000055614b0c423f std::vector<llvm::MachineBasicBlock*, std::allocator<llvm::MachineBasicBlock*>>::push_back(llvm::MachineBasicBlock* const&) (/usr/local/bin/ld.lld+0x11bc23f)
 #5 0x000055614b0c4e2f llvm::MachineBasicBlock::addSuccessor(llvm::MachineBasicBlock*, llvm::BranchProbability) (/usr/local/bin/ld.lld+0x11bce2f)
 #6 0x000055614aca9a45 emitCMPTermZMB(llvm::MachineInstr&, llvm::MachineBasicBlock*) MOSISelLowering.cpp:0:0
 #7 0x000055614b08e06b (anonymous namespace)::FinalizeISel::runOnMachineFunction(llvm::MachineFunction&) FinalizeISel.cpp:0:0
 #8 0x000055614b0e8f10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #9 0x000055614bd33aa6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/ld.lld+0x1e2baa6)
#10 0x000055614bd33c2f llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/ld.lld+0x1e2bc2f)
#11 0x000055614bd34122 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/ld.lld+0x1e2c122)
#12 0x000055614af7cf10 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#13 0x000055614af7d0ae llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/usr/local/bin/ld.lld+0x10750ae)
#14 0x000055614af76596 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/usr/local/bin/ld.lld+0x106e596)
#15 0x000055614af76890 llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/usr/local/bin/ld.lld+0x106e890)
#16 0x000055614a6ee232 lld::elf::BitcodeCompiler::compile() (/usr/local/bin/ld.lld+0x7e6232)
#17 0x000055614a68fbb2 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, false>>(bool) (/usr/local/bin/ld.lld+0x787bb2)
#18 0x000055614a696715 lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) (/usr/local/bin/ld.lld+0x78e715)
#19 0x000055614a69ec00 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/local/bin/ld.lld+0x796c00)
#20 0x000055614a69fc2a lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/local/bin/ld.lld+0x797c2a)
#21 0x000055614a6094c4 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/local/bin/ld.lld+0x7014c4)
#22 0x000055614a5a9b98 lld_main(int, char**, llvm::ToolContext const&) (/usr/local/bin/ld.lld+0x6a1b98)
#23 0x000055614a425af6 main (/usr/local/bin/ld.lld+0x51daf6)
#24 0x00007fdee77fcd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x00007fdee77fce40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x000055614a5a9715 _start (/usr/local/bin/ld.lld+0x6a1715)
mos-sim-clang: error: unable to execute command: Segmentation fault (core dumped)
mos-sim-clang: error: ld.lld command failed due to signal (use -v to see invocation)
mysterymath commented 7 months ago

Fixed by a367c3bb51d0e86cb0c9844b8422e96114d27fca

mrk-its commented 7 months ago

It was huge change. Thanks!