[llvm] [PowerPC] Enable using HwMode for instructions (PR #191051)

Nathan Chancellor via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 20:58:11 PDT 2026


nathanchance wrote:

This patch causes a crash when building the Linux kernel for me.

`cvise` spits out:

```c
struct bunzip_data {
  int writeCurrent;
  int totalCRC, writeCRC;
  int dbuf;
} *read_bunzip_bd;
int *read_bunzip_dbuf;
int read_bunzip_xcurrent, read_bunzip_gotcount = 0, read_bunzip_previous,
                          read_bunzip_pos;
int get_next_block(struct bunzip_data *);
int read_bunzip() {
  read_bunzip_dbuf = &read_bunzip_bd->dbuf;
  for (;;)
  decode_next_byte:
    if (read_bunzip_bd)
      break;
  read_bunzip_previous = read_bunzip_xcurrent;
  read_bunzip_pos = read_bunzip_dbuf[read_bunzip_pos];
  read_bunzip_bd->writeCRC =
      ~read_bunzip_bd->totalCRC ^ read_bunzip_bd->writeCRC;
  read_bunzip_previous = get_next_block(read_bunzip_bd);
  if (read_bunzip_previous)
    return read_bunzip_gotcount;
  read_bunzip_xcurrent = read_bunzip_bd->writeCurrent;
  goto decode_next_byte;
}
```

```
$ clang --target=powerpc64le-linux-gnu -O2 -c -o /dev/null decompress_bunzip2.i
Impossible reg-to-reg copy
UNREACHABLE executed at /src/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1911!
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: clang --target=powerpc64le-linux-gnu -O2 -c -o /dev/null decompress_bunzip2.i
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'decompress_bunzip2.i'.
4.	Running pass 'Post-RA pseudo instruction expansion pass' on function '@read_bunzip'
 #0 0x0000562198401d26 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/install/bin/clang-23+0x63a9d26)
 #1 0x00005621983fe9f1 llvm::sys::RunSignalHandlers() (/install/bin/clang-23+0x63a69f1)
 #2 0x000056219840080f llvm::sys::CleanupOnSignal(unsigned long) (/install/bin/clang-23+0x63a880f)
 #3 0x000056219837239d CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f46e203e2d0 (/usr/lib/libc.so.6+0x3e2d0)
 #5 0x00007f46e2098a2c (/usr/lib/libc.so.6+0x98a2c)
 #6 0x00007f46e203e1a0 raise (/usr/lib/libc.so.6+0x3e1a0)
 #7 0x00007f46e20255fe abort (/usr/lib/libc.so.6+0x255fe)
 #8 0x00005621983795ef (/install/bin/clang-23+0x63215ef)
 #9 0x0000562196b4a6ce llvm::PPCInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::Register, llvm::Register, bool, bool, bool) const PPCInstrInfo.cpp:0:0
#10 0x0000562197bb6295 llvm::TargetInstrInfo::lowerCopy(llvm::MachineInstr*, llvm::TargetRegisterInfo const*) const (/install/bin/clang-23+0x5b5e295)
#11 0x0000562197795ed8 (anonymous namespace)::ExpandPostRA::run(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#12 0x000056219779687a (anonymous namespace)::ExpandPostRALegacy::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#13 0x00005621978b59a3 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/install/bin/clang-23+0x585d9a3)
#14 0x0000562197e8f1ec llvm::FPPassManager::runOnFunction(llvm::Function&) (/install/bin/clang-23+0x5e371ec)
#15 0x0000562197e96ce2 llvm::FPPassManager::runOnModule(llvm::Module&) (/install/bin/clang-23+0x5e3ece2)
#16 0x0000562197e8fc1c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/install/bin/clang-23+0x5e37c1c)
#17 0x0000562198d95bf7 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*) (/install/bin/clang-23+0x6d3dbf7)
#18 0x0000562198dab3ff clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/install/bin/clang-23+0x6d533ff)
#19 0x000056219a4e0869 clang::ParseAST(clang::Sema&, bool, bool) (/install/bin/clang-23+0x8488869)
#20 0x0000562199312d54 clang::FrontendAction::Execute() (/install/bin/clang-23+0x72bad54)
#21 0x000056219926885a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/install/bin/clang-23+0x721085a)
#22 0x0000562199400816 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/install/bin/clang-23+0x73a8816)
#23 0x0000562196025982 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/install/bin/clang-23+0x3fcd982)
#24 0x00005621960213c5 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#25 0x0000562196023a58 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x0000562199096f39 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::$_0>(long) Job.cpp:0:0
#27 0x00005621983720be llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/install/bin/clang-23+0x631a0be)
#28 0x000056219909671d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/install/bin/clang-23+0x703e71d)
#29 0x00005621990532e8 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/install/bin/clang-23+0x6ffb2e8)
#30 0x0000562199053527 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/install/bin/clang-23+0x6ffb527)
#31 0x0000562199072129 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/install/bin/clang-23+0x701a129)
#32 0x0000562196020b96 clang_main(int, char**, llvm::ToolContext const&) (/install/bin/clang-23+0x3fc8b96)
#33 0x0000562196031a8c main (/install/bin/clang-23+0x3fd9a8c)
#34 0x00007f46e20276c1 (/usr/lib/libc.so.6+0x276c1)
#35 0x00007f46e20277f9 __libc_start_main (/usr/lib/libc.so.6+0x277f9)
#36 0x000056219601ec65 _start (/install/bin/clang-23+0x3fc6c65)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
ClangBuiltLinux clang version 23.0.0git (https://github.com/llvm/llvm-project.git 2a83068537786696d4950ce694e7d34480631f48)
...
```

`llvm-reduce` spits out:

```llvm
target datalayout = "e-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64le-unknown-linux-gnu"

define i32 @read_bunzip(i32 %0) {
entry:
  %1 = load i32, ptr null, align 4
  %2 = xor i32 %1, %0
  %xor11 = xor i32 %2, -1
  ret i32 %xor11
}
```

```
$ llc -o /dev/null reduced.ll
Impossible reg-to-reg copy
UNREACHABLE executed at /src/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1911!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: llc -o /dev/null reduced.ll
1.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.	Running pass 'Post-RA pseudo instruction expansion pass' on function '@read_bunzip'
 #0 0x00005629e3c72636 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/install/bin/llc+0x62f6636)
 #1 0x00005629e3c6f2e1 llvm::sys::RunSignalHandlers() (/install/bin/llc+0x62f32e1)
 #2 0x00005629e3c73464 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f1dbf63e2d0 (/usr/lib/libc.so.6+0x3e2d0)
 #4 0x00007f1dbf698a2c (/usr/lib/libc.so.6+0x98a2c)
 #5 0x00007f1dbf63e1a0 raise (/usr/lib/libc.so.6+0x3e1a0)
 #6 0x00007f1dbf6255fe abort (/usr/lib/libc.so.6+0x255fe)
 #7 0x00005629e3bc7dbf (/install/bin/llc+0x624bdbf)
 #8 0x00005629e1945c2e llvm::PPCInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::Register, llvm::Register, bool, bool, bool) const PPCInstrInfo.cpp:0:0
 #9 0x00005629e2b9df55 llvm::TargetInstrInfo::lowerCopy(llvm::MachineInstr*, llvm::TargetRegisterInfo const*) const (/install/bin/llc+0x5221f55)
#10 0x00005629e26f84d8 (anonymous namespace)::ExpandPostRA::run(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#11 0x00005629e26f8e7a (anonymous namespace)::ExpandPostRALegacy::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#12 0x00005629e2836863 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/install/bin/llc+0x4eba863)
#13 0x00005629e2e0aa3c llvm::FPPassManager::runOnFunction(llvm::Function&) (/install/bin/llc+0x548ea3c)
#14 0x00005629e2e127b2 llvm::FPPassManager::runOnModule(llvm::Module&) (/install/bin/llc+0x54967b2)
#15 0x00005629e2e0b4fc llvm::legacy::PassManagerImpl::run(llvm::Module&) (/install/bin/llc+0x548f4fc)
#16 0x00005629e0e8f222 compileModule(char**, llvm::SmallVectorImpl<llvm::PassPlugin>&, llvm::LLVMContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) llc.cpp:0:0
#17 0x00005629e0e8c106 main (/install/bin/llc+0x3510106)
#18 0x00007f1dbf6276c1 (/usr/lib/libc.so.6+0x276c1)
#19 0x00007f1dbf6277f9 __libc_start_main (/usr/lib/libc.so.6+0x277f9)
#20 0x00005629e0e87b65 _start (/install/bin/llc+0x350bb65)
```

https://github.com/llvm/llvm-project/pull/191051


More information about the llvm-commits mailing list