Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86_64/GlobalISel] Returning half type causes error "Cannot emit physreg copy instruction" #64435

Open
HazyFish opened this issue Aug 4, 2023 · 2 comments
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:globalisel

Comments

@HazyFish
Copy link
Contributor

HazyFish commented Aug 4, 2023

Description

Returning half type will crash the x86_64 Global ISel backend with LLVM ERROR: Cannot emit physreg copy instruction during Post-RA pseudo instruction expansion pass.

The problem does not exist when targeting i686 or aarch64.
The problem also does not exist when not using Global ISel.

Minimal Reproduction

https://godbolt.org/z/G1rszzf1n

Code

define half @f(ptr %0) {
  %h = load half, ptr %0
  ret half %h
}

Stack Trace

LLVM ERROR: Cannot emit physreg copy instruction
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 --global-isel <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'Post-RA pseudo instruction expansion pass' on function '@f'
 #0 0x0000000003398418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3398418)
 #1 0x0000000003395d0c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f6d11af4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f6d115b700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f6d11596859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x0000000000695331 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x695331)
 #6 0x00000000032ee9e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x32ee9e8)
 #7 0x0000000001d4ef15 llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::MCRegister, llvm::MCRegister, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1d4ef15)
 #8 0x0000000002937b38 llvm::TargetInstrInfo::lowerCopy(llvm::MachineInstr*, llvm::TargetRegisterInfo const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2937b38)
 #9 0x000000000253ff67 (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#10 0x0000000002680049 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#11 0x0000000002bf8bb9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8bb9)
#12 0x0000000002bf8df1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8df1)
#13 0x0000000002bf9612 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf9612)
#14 0x000000000075e092 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#15 0x000000000069a7e6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x69a7e6)
#16 0x00007f6d11598083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#17 0x0000000000754a4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x754a4e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@HazyFish
Copy link
Contributor Author

HazyFish commented Aug 4, 2023

@DataCorrupted

@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 4, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 4, 2023

@llvm/issue-subscribers-backend-x86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:globalisel
Projects
None yet
Development

No branches or pull requests

4 participants