Skip to content

[RISCV] Crash at -O2: SubRange for this mask not foundΒ #170298

@cardigan1008

Description

@cardigan1008

This code crashed at -O2:

static int a;
#include "riscv_vector.h"
int b(short c) {
  char e[] = {2000000000};
  char *f = e;
  short g = c;
  long h = 0;
  __rvv_bool4_t i;
  __rvv_uint16m4_t j = __riscv_vmv_s_x_u16m4(g, h);
  long k;
  __rvv_int8m2x3_t l ;
  __riscv_vsoxseg3ei16_v_i8m2x3_m(i, e, j, l, k);
}
int n(int o) {
  int p = a;
  a = o;
  o + p &&b(9);
}
int q() {
  {
    int p = a;
    a = 0;
    p &&b(9);
  }
}
int r();
void s(int t, int u, int v) {
  if (r())
    v = 1;
  v + t - u &&q();
}
void main() {
  s(59, 2, 47);
  n(7);
  r();
  {
    a&&b(9);
  {
      char d = 0;
      char e[] = {2, d, d, d, d, d, d, d, d, d};
      char *f = e;
      short g = 9;
      long h = 0;
      __rvv_bool4_t i;
      __rvv_uint16m4_t j = __riscv_vmv_s_x_u16m4(g, h);
      long k;
      __rvv_int8m2x3_t l = __riscv_vlseg3e8ff_v_i8m2x3(f, &k, h);
      __riscv_vsoxseg3ei16_v_i8m2x3_m(i, e, j, l, k);
    }
  }
}

Compiler Explorer: https://godbolt.org/z/n95EqK1YT

Crash:

SubRange for this mask not found
UNREACHABLE executed at /root/llvm-project/llvm/lib/CodeGen/SplitKit.cpp:402!

Backtrace:

Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics --target=riscv64-unknown-linux-gnu -march=rv64gcv -mabi=lp64d -menable-experimental-extensions -O2 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'Greedy Register Allocator' on function '@main'
 #0 0x000000000427b8f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x427b8f8)
 #1 0x0000000004278d24 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4278d24)
 #2 0x00000000041bca58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000719e72c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000719e72c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000719e72c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x0000719e72c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00000000041c872a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41c872a)
 #8 0x00000000037dc79c llvm::SplitEditor::extendPHIKillRanges() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37dc79c)
 #9 0x00000000037e71cb llvm::SplitEditor::finish(llvm::SmallVectorImpl<unsigned int>*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37e71cb)
#10 0x000000000371442b llvm::RAGreedy::tryBlockSplit(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl<llvm::Register>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x371442b)
#11 0x0000000003720491 llvm::RAGreedy::trySplit(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3720491)
#12 0x0000000003727449 llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>>&, llvm::SmallVector<std::pair<llvm::LiveInterval const*, llvm::MCRegister>, 8u>&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3727449)
#13 0x0000000003727cd7 llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3727cd7)
#14 0x00000000039a6aa0 llvm::RegAllocBase::allocatePhysRegs() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39a6aa0)
#15 0x00000000037238ab llvm::RAGreedy::run(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37238ab)
#16 0x00000000037244fa (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) RegAllocGreedy.cpp:0:0
#17 0x000000000352f5d9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x0000000003b74126 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b74126)
#19 0x0000000003b744d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b744d1)
#20 0x0000000003b74d3f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b74d3f)
#21 0x0000000004539e66 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4539e66)
#22 0x0000000004bcac77 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bcac77)
#23 0x0000000006962ddc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6962ddc)
#24 0x0000000004bcb0d8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bcb0d8)
#25 0x0000000004eb6945 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4eb6945)
#26 0x0000000004e36afe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e36afe)
#27 0x0000000004faf97d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4faf97d)
#28 0x0000000000dc7740 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc7740)
#29 0x0000000000dbe1ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#30 0x0000000000dbe33d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#31 0x0000000004c338c9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x00000000041bcef4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41bcef4)
#33 0x0000000004c33edf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x0000000004bf46d2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bf46d2)
#35 0x0000000004bf567e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bf567e)
#36 0x0000000004bfcab5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bfcab5)
#37 0x0000000000dc3b61 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc3b61)
#38 0x0000000000c72574 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc72574)
#39 0x0000719e72c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x0000719e72c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000dbdc55 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdbdc55)

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions