[llvm] PPC: Split 64bit target feature into 64bit and 64bit-support (PR #157206)
Nathan Chancellor via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 19 13:19:12 PDT 2025
nathanchance wrote:
I have bisected [a crash that folks have seen in the Linux kernel](https://lore.kernel.org/aM071XHb5cppdEKK@stanley.mountain/) to this change.
```
# bad: [334013b090eef5b97cef8bc1817ed9ff67680488] Mark STATISTIC variables as maybe_unused when stats are disabled. (#159103)
# good: [3270d98641e29e25f7a34e42baf853c2816e25b0] [AArch64] Verify OPERAND_SHIFT_MSL and OPERAND_IMPLICIT_IMM_0 (#157031)
git bisect start '334013b090eef5b97cef8bc1817ed9ff67680488' '3270d98641e29e25f7a34e42baf853c2816e25b0'
# good: [9ee1f159dccbee1e19ab7584e678af9be1054e2d] [MLIR] Apply clang-tidy fixes for llvm-qualified-auto in MPIToLLVM.cpp (NFC)
git bisect good 9ee1f159dccbee1e19ab7584e678af9be1054e2d
# good: [0741209385ae62fc8c529f807c6f4f9777d94bc3] [flang][OpenMP] Guard lastprivate scoping on DO (#157760)
git bisect good 0741209385ae62fc8c529f807c6f4f9777d94bc3
# bad: [0d927752f3f0391ee6c6444796262255963a06d9] [RISCV] Use X_X0 instead of literal 0. NFC (#158753)
git bisect bad 0d927752f3f0391ee6c6444796262255963a06d9
# good: [dbc96f41f15fc30d4fc6198eb1c2dcb57547a160] [libc++] Escape spaces in GoogleBenchmark microbenchmarks
git bisect good dbc96f41f15fc30d4fc6198eb1c2dcb57547a160
# good: [7b6db769c3470d75b0d010f16c50582ec3535dea] [NFC][DecoderEmitter] Code cleanup in `DecoderEmitter::emitTable` (#158014)
git bisect good 7b6db769c3470d75b0d010f16c50582ec3535dea
# good: [b9b92d72313b080aa83adee485d441c72a1445c8] [NFC] Rename FixedLenDecoderEmitter to just DecoderEmitter (#158766)
git bisect good b9b92d72313b080aa83adee485d441c72a1445c8
# good: [fdb06d9792afc8121e77b367cb6dce0be29b2b5b] [AMDGPU] Refactor out common exec mask opcode patterns (NFCI) (#154718)
git bisect good fdb06d9792afc8121e77b367cb6dce0be29b2b5b
# bad: [e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410] PPC: Split 64bit target feature into 64bit and 64bit-support (#157206)
git bisect bad e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410
# good: [f74184ccc9053268a5baba129fcfde554cf0d255] [MemProf] Add NodeId field to ContextNode for debugging (#158736)
git bisect good f74184ccc9053268a5baba129fcfde554cf0d255
# first bad commit: [e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410] PPC: Split 64bit target feature into 64bit and 64bit-support (#157206)
```
A C reproducer from `cvise`:
```c
enum { false } typedef bool;
typedef int size_t;
struct vgetrandom_state {
long generation;
} __arch_chacha20_blocks_nostack(unsigned *);
void *__cvdso_getrandom_data_buffer, *__cvdso_getrandom_data_opaque_state;
unsigned __cvdso_getrandom_data_counter[1];
size_t __cvdso_getrandom_data_len;
void getrandom_syscall(void *, size_t);
int __cvdso_getrandom_data() {
struct vgetrandom_state *state = __cvdso_getrandom_data_opaque_state;
size_t batch_len, orig_len = __cvdso_getrandom_data_len;
bool in_use;
void *orig_buffer = __cvdso_getrandom_data_buffer;
long current_generation;
in_use = 0;
if (__builtin_expect(in_use, 0))
goto fallback_syscall;
retry_generation:
current_generation = 0;
if (__builtin_expect(state->generation != current_generation, 0))
more_batch:
batch_len = 0;
if (batch_len)
goto retry_generation;
__arch_chacha20_blocks_nostack(__cvdso_getrandom_data_counter);
goto more_batch;
fallback_syscall:
getrandom_syscall(orig_buffer, orig_len);
return __cvdso_getrandom_data_len;
}
```
```
$ clang --target=powerpc-linux-gnu -mcpu=e5500 -c -o /dev/null vgetrandom-32.i
clang: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7677: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, SDValue, const SDNodeFlags): Assertion `N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"' failed.
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=powerpc-linux-gnu -mcpu=e5500 -c -o /dev/null vgetrandom-32.i
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'vgetrandom-32.i'.
4. Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__cvdso_getrandom_data'
#0 0x0000557c66f85058 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang-22+0x37e9058)
#1 0x0000557c66f82795 llvm::sys::RunSignalHandlers() (clang-22+0x37e6795)
#2 0x0000557c66f04666 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fb5a203e540 (/usr/lib/libc.so.6+0x3e540)
#4 0x00007fb5a209894c (/usr/lib/libc.so.6+0x9894c)
#5 0x00007fb5a203e410 raise (/usr/lib/libc.so.6+0x3e410)
#6 0x00007fb5a202557a abort (/usr/lib/libc.so.6+0x2557a)
#7 0x00007fb5a20254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
#8 0x0000557c689ecec3 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (clang-22+0x5250ec3)
#9 0x0000557c65b62a32 llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const::$_0::operator()() const PPCISelLowering.cpp:0:0
#10 0x0000557c65b5da4e llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const PPCISelLowering.cpp:0:0
#11 0x0000557c65b5a870 llvm::PPCTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const PPCISelLowering.cpp:0:0
#12 0x0000557c68980b38 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (clang-22+0x51e4b38)
#13 0x0000557c689a3b87 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (clang-22+0x5207b87)
#14 0x0000557c6898a233 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (clang-22+0x51ee233)
#15 0x0000557c68972144 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (clang-22+0x51d6144)
#16 0x0000557c689644b1 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (clang-22+0x51c84b1)
#17 0x0000557c68a293f5 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (clang-22+0x528d3f5)
#18 0x0000557c68a28618 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (clang-22+0x528c618)
#19 0x0000557c68a25c20 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (clang-22+0x5289c20)
#20 0x0000557c65bb589e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#21 0x0000557c68a236e0 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (clang-22+0x52876e0)
#22 0x0000557c664e2433 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (clang-22+0x2d46433)
#23 0x0000557c66a671a5 llvm::FPPassManager::runOnFunction(llvm::Function&) (clang-22+0x32cb1a5)
#24 0x0000557c66a6e942 llvm::FPPassManager::runOnModule(llvm::Module&) (clang-22+0x32d2942)
#25 0x0000557c66a67b80 llvm::legacy::PassManagerImpl::run(llvm::Module&) (clang-22+0x32cbb80)
#26 0x0000557c676d03d3 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*) (clang-22+0x3f343d3)
#27 0x0000557c676e5fb8 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (clang-22+0x3f49fb8)
#28 0x0000557c68d15ec9 clang::ParseAST(clang::Sema&, bool, bool) (clang-22+0x5579ec9)
#29 0x0000557c67c2a956 clang::FrontendAction::Execute() (clang-22+0x448e956)
#30 0x0000557c67b8b8fd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang-22+0x43ef8fd)
#31 0x0000557c67d00a9b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang-22+0x4564a9b)
#32 0x0000557c65b11a83 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang-22+0x2375a83)
#33 0x0000557c65b0da3f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000557c679b01d9 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
#35 0x0000557c66f0434e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang-22+0x376834e)
#36 0x0000557c679afa13 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang-22+0x4213a13)
#37 0x0000557c6796ab23 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang-22+0x41ceb23)
#38 0x0000557c6796ad47 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (clang-22+0x41ced47)
#39 0x0000557c67988178 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang-22+0x41ec178)
#40 0x0000557c65b0d122 clang_main(int, char**, llvm::ToolContext const&) (clang-22+0x2371122)
#41 0x0000557c65b1e3a7 main (clang-22+0x23823a7)
#42 0x00007fb5a2027675 (/usr/lib/libc.so.6+0x27675)
#43 0x00007fb5a2027729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#44 0x0000557c65b0b465 _start (clang-22+0x236f465)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 22.0.0git (https://github.com/llvm/llvm-project.git e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410)
...
```
`llvm-reduce` took it much further but I am not sure if it is legitimate?
```llvm
target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32"
target triple = "powerpc-unknown-linux-gnu"
define i32 @__cvdso_getrandom_data() #0 {
entry:
br label %if.end4
if.end4: ; preds = %if.end4, %entry
call void null(ptr null, ptr null)
br label %if.end4
}
attributes #0 = { "target-cpu"="e5500" }
```
```
llc: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7677: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, SDValue, const SDNodeFlags): Assertion `N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"' failed.
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 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__cvdso_getrandom_data'
#0 0x0000563a0a3ffad8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llc+0x354bad8)
#1 0x0000563a0a3fd1a5 llvm::sys::RunSignalHandlers() (llc+0x35491a5)
#2 0x0000563a0a400881 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fb29103e540 (/usr/lib/libc.so.6+0x3e540)
#4 0x00007fb29109894c (/usr/lib/libc.so.6+0x9894c)
#5 0x00007fb29103e410 raise (/usr/lib/libc.so.6+0x3e410)
#6 0x00007fb29102557a abort (/usr/lib/libc.so.6+0x2557a)
#7 0x00007fb2910254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
#8 0x0000563a0a19eee3 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (llc+0x32eaee3)
#9 0x0000563a0898c8f2 llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const::$_0::operator()() const PPCISelLowering.cpp:0:0
#10 0x0000563a0898790e llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const PPCISelLowering.cpp:0:0
#11 0x0000563a08984730 llvm::PPCTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const PPCISelLowering.cpp:0:0
#12 0x0000563a0a126178 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (llc+0x3272178)
#13 0x0000563a0a149247 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (llc+0x3295247)
#14 0x0000563a0a12f873 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (llc+0x327b873)
#15 0x0000563a0a117124 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (llc+0x3263124)
#16 0x0000563a0a109421 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (llc+0x3255421)
#17 0x0000563a0a1de235 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (llc+0x332a235)
#18 0x0000563a0a1dd8cb llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (llc+0x33298cb)
#19 0x0000563a0a1daa60 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (llc+0x3326a60)
#20 0x0000563a089dfa4e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#21 0x0000563a0a1d8520 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (llc+0x3324520)
#22 0x0000563a093f2e53 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (llc+0x253ee53)
#23 0x0000563a0996d9d5 llvm::FPPassManager::runOnFunction(llvm::Function&) (llc+0x2ab99d5)
#24 0x0000563a09975382 llvm::FPPassManager::runOnModule(llvm::Module&) (llc+0x2ac1382)
#25 0x0000563a0996e440 llvm::legacy::PassManagerImpl::run(llvm::Module&) (llc+0x2aba440)
#26 0x0000563a0890fe9e compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#27 0x0000563a0890d67d main (llc+0x1a5967d)
#28 0x00007fb291027675 (/usr/lib/libc.so.6+0x27675)
#29 0x00007fb291027729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#30 0x0000563a089095e5 _start (llc+0x1a555e5)
```
https://github.com/llvm/llvm-project/pull/157206
More information about the llvm-commits
mailing list