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] extractelement v1i1 crashes on icelake-server #64322

Closed
tinkerrc opened this issue Aug 2, 2023 · 3 comments
Closed

[x86_64] extractelement v1i1 crashes on icelake-server #64322

tinkerrc opened this issue Aug 2, 2023 · 3 comments
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@tinkerrc
Copy link
Contributor

tinkerrc commented Aug 2, 2023

Demo on Compiler Explorer

  • The bug goes away when -mcpu=icelake-server is removed.
  • Using a constant v1i1 doesn't crash.

Code:

@G = global <1 x i1> <i1 true>
@G.1 = global i1 false

define void @foo(i32 %x) {
  %LGV = load <1 x i1>, ptr @G
  ; This works:
  ;%E = extractelement <1 x i1> <i1 true>, i32 %x
  ; This doesn't:
  %E = extractelement <1 x i1> %LGV, i32 %x
  store i1 %E, ptr @G.1
  ret void
}

Crash backtrace:

LLVM ERROR: Cannot select: 0x8191910: i8 = truncate 0x81912f0
  0x81912f0: i128 = bitcast 0x81917c0
    0x81917c0: v1i128 = sign_extend 0x8191440
      0x8191440: v1i1,ch = load<(dereferenceable load (s8) from @G)> 0x8115160, 0x8191ad0, undef:i64
        0x8191ad0: i64,ch = load<(load (s64) from got)> 0x8115160, 0x8191a60, undef:i64
          0x8191a60: i64 = X86ISD::WrapperRIP TargetGlobalAddress:i64<ptr @G> 0 [TF=5]
            0x8191590: i64 = TargetGlobalAddress<ptr @G> 0 [TF=5]
          0x81913d0: i64 = undef
        0x81913d0: i64 = undef
In function: foo
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-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mcpu=icelake-server <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x000000000305a128 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x305a128)
 #1 0x0000000003057cec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f785178e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f785125100b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f7851230859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000000000069de84 llvm::RISCVISAInfo::updateImplication() (.cold) RISCVISAInfo.cpp:0:0
 #6 0x0000000002e42ef4 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e42ef4)
 #7 0x0000000002e48585 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e48585)
 #8 0x000000000196ed1d (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x0000000002e40557 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e40557)
#10 0x0000000002e4ce15 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4ce15)
#11 0x0000000002e4f869 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4f869)
#12 0x0000000002e51f36 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000001978741 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000000002439700 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x000000000291aeb2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291aeb2)
#16 0x000000000291b031 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291b031)
#17 0x000000000291cba0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291cba0)
#18 0x00000000007673f0 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x00000000006a8b82 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x6a8b82)
#20 0x00007f7851232083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#21 0x000000000075f33e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x75f33e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@tinkerrc
Copy link
Contributor Author

tinkerrc commented Aug 2, 2023

@DataCorrupted
@HazyFish

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

llvmbot commented Aug 2, 2023

@llvm/issue-subscribers-backend-x86

@phoebewang
Copy link
Contributor

Candidate patch: https://reviews.llvm.org/D156855

doru1004 pushed a commit to doru1004/llvm-project that referenced this issue Aug 3, 2023
razmser pushed a commit to razmser/llvm-project that referenced this issue Sep 8, 2023
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]
Projects
None yet
Development

No branches or pull requests

4 participants