Skip to content

[M68k] RTD must be implemented for 68010 baseline and higher #60554

Open
@glaubitz

Description

@glaubitz

As initially reported in #59161 (comment), the M68k backend needs to have the RTD instruction implemented in order to use a baseline of 68010 or higher.

The reason for this is that the code in llvm/lib/Target/M68k/M68kExpandPseudo.cpp M68kExpandPseudo::ExpandMI() wants to emit the RTD instead of RTS instruction when the baseline is set to 68010 or higher but RTD is not implemented:

glaubitz@node54:/data/home/glaubitz> /data/home/glaubitz/llvm-project/stage1.install/bin/clang -mcpu=68020 -target m68k-linux-gnu future.cc -o future -I /data/home/glaubitz/sid-m68k-sbuild/usr/m68k-linux-gnu/include/c++/12/m68k-linux-gnu/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/m68k-linux-gnu/include/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/include/c++/12/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/include/m68k-linux-gnu/c++/12/ -L /data/home/glaubitz/sid-m68k-sbuild/usr/lib/m68k-linux-gnu/ -L /data/home/glaubitz/sid-m68k-sbuild/usr/lib/gcc/m68k-linux-gnu/12/ -L /data/home/glaubitz/sid-m68k-sbuild/usr/lib/gcc/m68k-linux-gnu/12/ -fuse-ld=/usr/bin/m68k-suse-linux-ld
RTD is not implemented
UNREACHABLE executed at /data/home/glaubitz/llvm-project/llvm/lib/Target/M68k/M68kExpandPseudo.cpp:255!
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: /data/home/glaubitz/llvm-project/stage1.install/bin/clang-17 -cc1 -triple m68k-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -main-file-name future.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu M68020 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/data/home/glaubitz -resource-dir /data/home/glaubitz/llvm-project/stage1.install/lib/clang/17 -I /data/home/glaubitz/sid-m68k-sbuild/usr/m68k-linux-gnu/include/c++/12/m68k-linux-gnu/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/m68k-linux-gnu/include/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/include/c++/12/ -I /data/home/glaubitz/sid-m68k-sbuild/usr/include/m68k-linux-gnu/c++/12/ -internal-isystem /data/home/glaubitz/llvm-project/stage1.install/lib/clang/17/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/data/home/glaubitz -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/future-3f8909.o -x c++ future.cc
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'future.cc'.
4.      Running pass 'M68k pseudo instruction expansion pass' on function '@"_ZSt5asyncIZ4mainE3$_0JEESt6futureINSt15__invoke_resultINSt5decayIT_E4typeEJDpNS3_IT0_E4typeEEE4typeEESt6launchOS4_DpOS7_"'
 #0 0x0000000002003f67 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x2003f67)
 #1 0x0000000002001a1c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f95f03a88c0 __restore_rt (/lib64/libpthread.so.0+0x168c0)
 #3 0x00007f95eead8cbb raise (/lib64/libc.so.6+0x4acbb)
 #4 0x00007f95eeada355 abort (/lib64/libc.so.6+0x4c355)
 #5 0x0000000001f6ad7a (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x1f6ad7a)
 #6 0x0000000000f537bd (anonymous namespace)::M68kExpandPseudo::ExpandMI(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>) M68kExpandPseudo.cpp:0:0
 #7 0x0000000000f53ab2 (anonymous namespace)::M68kExpandPseudo::runOnMachineFunction(llvm::MachineFunction&) M68kExpandPseudo.cpp:0:0
 #8 0x00000000013633e2 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.71) MachineFunctionPass.cpp:0:0
 #9 0x0000000001900658 llvm::FPPassManager::runOnFunction(llvm::Function&) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x1900658)
#10 0x0000000001900979 llvm::FPPassManager::runOnModule(llvm::Module&) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x1900979)
#11 0x00000000019017d8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x19017d8)
#12 0x00000000023853a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x23853a8)
#13 0x00000000030de451 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x30de451)
#14 0x0000000003dec2d9 clang::ParseAST(clang::Sema&, bool, bool) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x3dec2d9)
#15 0x00000000030dd0a0 clang::CodeGenAction::ExecuteAction() (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x30dd0a0)
#16 0x0000000002a847e9 clang::FrontendAction::Execute() (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x2a847e9)
#17 0x0000000002a1cc3a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x2a1cc3a)
#18 0x0000000002b544cb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0x2b544cb)
#19 0x0000000000bb8ec1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0xbb8ec1)
#20 0x0000000000bb4398 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#21 0x0000000000bb688c clang_main(int, char**) (/data/home/glaubitz/llvm-project/stage1.install/bin/clang-17+0xbb688c)
#22 0x00007f95eeac329d __libc_start_main (/lib64/libc.so.6+0x3529d)
#23 0x0000000000bae7ba _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
clang-17: error: unable to execute command: Aborted (core dumped)
clang-17: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (https://github.com/llvm/llvm-project.git b72330cd54f985f3454d3538b504027c3eff8711)
Target: m68k-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/home/glaubitz/llvm-project/stage1.install/bin
clang-17: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-17: note: diagnostic msg: /tmp/future-76c283.cpp
clang-17: note: diagnostic msg: /tmp/future-76c283.sh
clang-17: note: diagnostic msg: 

********************
glaubitz@node54:/data/home/glaubitz>

The 68020 baseline is required in order to be able to use the newly implemented support for atomics and also the upcoming TLS Support (#60354).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions