llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.04k stars 11.98k forks source link

[ARM] Assertion failure in `llvm::SDNode::getValueType()` for `use-soft-float=true` and `target-features=+armv7-a` #105978

Open alexrp opened 2 months ago

alexrp commented 2 months ago
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "arm-unknown-linux-musleabi"

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #0

define arm_aapcscc i64 @__aeabi_lmul() #1 {
Entry:
  call void @llvm.memcpy.p0.p0.i32(ptr null, ptr null, i32 8, i1 false)
  ret i64 0
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "target-features"="+armv7-a" "use-soft-float"="true" }
❯ llc --version | head -n2
LLVM (http://llvm.org/):
  LLVM version 19.1.0-rc3
❯ llc --float-abi=soft reduced.ll
llc: /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8909: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, const llvm::SDLoc&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `MemVT.getScalarType().bitsLT(VT.getScalarType()) && "Should only be an extending load, not truncating!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'ARM Instruction Selection' on function '@__aeabi_lmul'
 #0 0x00007ecb6943dcf2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:727:3
 #1 0x00007ecb6943b65f llvm::sys::RunSignalHandlers() /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Signals.cpp:105:20
 #2 0x00007ecb6943b9f6 SignalHandler(int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007ecb67e42990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)
 #4 0x00007ecb67e99a1b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007ecb67e99a1b __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007ecb67e99a1b pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007ecb67e428e6 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007ecb67e268b7 abort ./stdlib/abort.c:81:7
 #9 0x00007ecb67e267db _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007ecb67e39206 (/lib/x86_64-linux-gnu/libc.so.6+0x39206)
#11 0x00007ecb69fc586b llvm::SDNode::getValueType(unsigned int) const /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8909:5
#12 0x00007ecb69fc586b llvm::SDValue::getValueType() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1187:28
#13 0x00007ecb69fc586b llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8924:14
#14 0x00007ecb69fc59fe llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, llvm::Align, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&, llvm::MDNode const*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8896:69
#15 0x00007ecb69fe086d llvm::SelectionDAG::getExtLoad(llvm::ISD::LoadExtType, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, llvm::MaybeAlign, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8974:52
#16 0x00007ecb69fff97a getMemcpyLoadsAndStores(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, unsigned long, llvm::Align, bool, bool, llvm::MachinePointerInfo, llvm::MachinePointerInfo, llvm::AAMDNodes const&, llvm::AAResults*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7941:13
#17 0x00007ecb6a00074c llvm::SelectionDAG::getMemcpy(llvm::SDValue, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::Align, bool, bool, llvm::CallInst const*, std::optional<bool>, llvm::MachinePointerInfo, llvm::MachinePointerInfo, llvm::AAMDNodes const&, llvm::AAResults*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8272:5
#18 0x00007ecb69faa6ab llvm::SelectionDAGBuilder::updateDAGForMaybeTailCall(llvm::SDValue) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:11913:3
#19 0x00007ecb69faa6ab llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:6471:30
#20 0x00007ecb69faca30 llvm::Value::getValueID() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Value.h:533:12
#21 0x00007ecb69faca30 llvm::Instruction::getOpcode() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Instruction.h:274:49
#22 0x00007ecb69faca30 llvm::Instruction::isTerminator() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Instruction.h:277:50
#23 0x00007ecb69faca30 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:1348:22
#24 0x00007ecb6a0335cc llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, llvm::BasicBlock>, true>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#25 0x00007ecb6a0335cc llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node.h:125:66
#26 0x00007ecb6a0335cc llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>::operator++() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:345:25
#27 0x00007ecb6a0335cc 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&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:836:79
#28 0x00007ecb6a034270 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1864:33
#29 0x00007ecb6a035b4c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:632:22
#30 0x00007ecb6c86f7a8 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:72:3
#31 0x00007ecb6a021007 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:268:11
#32 0x00007ecb6a021007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:375:1
#33 0x00007ecb6a021007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:346:6
#34 0x00007ecb69995b7f llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:33
#35 0x00007ecb6960c6d7 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1450:7
#36 0x00007ecb6960c911 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#37 0x00007ecb6960c911 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node.h:117:66
#38 0x00007ecb6960c911 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#39 0x00007ecb6960c911 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1485:22
#40 0x00007ecb6960d194 runOnModule /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1562:7
#41 0x00007ecb6960d194 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:541:55
#42 0x000057b619381a3c compileModule(char**, llvm::LLVMContext&) /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:742:34
#43 0x000057b619375f77 main /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:409:35
#44 0x00007ecb67e28150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#45 0x00007ecb67e28209 call_init ./csu/../csu/libc-start.c:128:20
#46 0x00007ecb67e28209 __libc_start_main ./csu/../csu/libc-start.c:347:5
#47 0x000057b619376cf5 _start (/opt/llvm-19/bin/llc+0x13cf5)

If you add e.g. -vfp2 to the target-features, there's no assertion failure.

I understand that Clang doesn't hit this because it removes VFP target features when targeting soft float (as in soft, not softfp). In Zig, we would rather not have to replicate that part of Clang's frontend logic. I would expect this case to just work since use-soft-float=true is a policy attribute that should ultimately win over any VFP target features that may happen to be enabled. That seems to be the case for other LLVM targets.

alexrp commented 2 months ago

When compiling the same Zig source file that this repro was reduced from, I've also seen this error:

SoftenFloatOperand Op #0: t45: v2f32 = BUILD_VECTOR t13, t19, mulc3.zig:0 @[ mulsc3.zig:13:23 ]
LLVM ERROR: Do not know how to soften this operator's operand!

This was actually what prompted me to investigate originally. Unfortunately, I've not been able to repro this outside of the Zig driver yet; I get the above assertion failure instead.

alexrp commented 2 months ago

Ok, managed to find a repro for that one too:

target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv4t-unknown-linux-musleabi"

define i32 @clock_adjtime() #0 {
entry:
  call void @llvm.memset.p0.i32(ptr null, i8 0, i32 44, i1 false)
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg) #1

attributes #0 = { "target-features"="+armv7-a" "use-soft-float"="true" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
❯ llc --version | head -n2
LLVM (http://llvm.org/):
  LLVM version 19.1.0-rc3
❯ llc --float-abi=soft reduced.ll
SoftenFloatOperand Op #0: t5: v2f64 = BUILD_VECTOR ConstantFP:f64<0.000000e+00>, ConstantFP:f64<0.000000e+00>

LLVM ERROR: Do not know how to soften this operator's operand!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc --float-abi=soft reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'ARM Instruction Selection' on function '@clock_adjtime'
 #0 0x000072804a83dcf2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:727:3
 #1 0x000072804a83b65f llvm::sys::RunSignalHandlers() /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Signals.cpp:105:20
 #2 0x000072804a83b9f6 SignalHandler(int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x0000728049242990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)
 #4 0x0000728049299a1b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x0000728049299a1b __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x0000728049299a1b pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007280492428e6 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007280492268b7 abort ./stdlib/abort.c:81:7
 #9 0x000072804a57fc78 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_replace(unsigned long, unsigned long, char const*, unsigned long) /usr/include/c++/13/bits/basic_string.tcc:540:21
#10 0x000072804a57fc78 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::assign(char const*) (.isra.0.cold) /usr/include/c++/13/bits/basic_string.h:1672:19
#11 0x000072804a75dc55 (/opt/llvm-19/bin/../lib/libLLVM.so.19.1-rc3+0xd5dc55)
#12 0x000072804b276dfa llvm::SDNode::getValueType(unsigned int) const /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:996:23
#13 0x000072804b276dfa llvm::DAGTypeLegalizer::SoftenFloatOperand(llvm::SDNode*, unsigned int) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:1040:3
#14 0x000072804b2bd941 llvm::DAGTypeLegalizer::run() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:333:17
#15 0x000072804b2be7a4 llvm::SelectionDAG::LegalizeTypes() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:1057:10
#16 0x000072804b42f863 llvm::TimeRegion::~TimeRegion() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/Support/Timer.h:155:9
#17 0x000072804b42f863 llvm::NamedRegionTimer::~NamedRegionTimer() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/Support/Timer.h:163:8
#18 0x000072804b42f863 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:954:3
#19 0x000072804b434270 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1864:33
#20 0x000072804b435b4c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:632:22
#21 0x000072804dc6f7a8 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:72:3
#22 0x000072804b421007 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:268:11
#23 0x000072804b421007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:375:1
#24 0x000072804b421007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:346:6
#25 0x000072804ad95b7f llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:33
#26 0x000072804aa0c6d7 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1450:7
#27 0x000072804aa0c911 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#28 0x000072804aa0c911 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node.h:117:66
#29 0x000072804aa0c911 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#30 0x000072804aa0c911 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1485:22
#31 0x000072804aa0d194 runOnModule /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1562:7
#32 0x000072804aa0d194 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:541:55
#33 0x00005bbf5d651a3c compileModule(char**, llvm::LLVMContext&) /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:742:34
#34 0x00005bbf5d645f77 main /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:409:35
#35 0x0000728049228150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#36 0x0000728049228209 call_init ./csu/../csu/libc-start.c:128:20
#37 0x0000728049228209 __libc_start_main ./csu/../csu/libc-start.c:347:5
#38 0x00005bbf5d646cf5 _start (/opt/llvm-19/bin/llc+0x13cf5)

Again, no crash with -vfp2.

llvmbot commented 2 months ago

@llvm/issue-subscribers-backend-arm

Author: Alex Rønne Petersen (alexrp)

```llvm target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" target triple = "arm-unknown-linux-musleabi" ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #0 define arm_aapcscc i64 @__aeabi_lmul() #1 { Entry: call void @llvm.memcpy.p0.p0.i32(ptr null, ptr null, i32 8, i1 false) ret i64 0 } attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) } attributes #1 = { "target-features"="+armv7-a" "use-soft-float"="true" } ``` ```console ❯ llc --version | head -n2 LLVM (http://llvm.org/): LLVM version 19.1.0-rc3 ❯ llc --float-abi=soft reduced.ll llc: /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8909: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, const llvm::SDLoc&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `MemVT.getScalarType().bitsLT(VT.getScalarType()) && "Should only be an extending load, not truncating!"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: llc reduced.ll 1. Running pass 'Function Pass Manager' on module 'reduced.ll'. 2. Running pass 'ARM Instruction Selection' on function '@__aeabi_lmul' #0 0x00007ecb6943dcf2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:727:3 #1 0x00007ecb6943b65f llvm::sys::RunSignalHandlers() /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Signals.cpp:105:20 #2 0x00007ecb6943b9f6 SignalHandler(int) /home/alexrp/Source/llvm-project-19/llvm/lib/Support/Unix/Signals.inc:413:1 #3 0x00007ecb67e42990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990) #4 0x00007ecb67e99a1b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x00007ecb67e99a1b __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #6 0x00007ecb67e99a1b pthread_kill ./nptl/pthread_kill.c:89:10 #7 0x00007ecb67e428e6 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #8 0x00007ecb67e268b7 abort ./stdlib/abort.c:81:7 #9 0x00007ecb67e267db _nl_load_domain ./intl/loadmsgcat.c:1177:9 #10 0x00007ecb67e39206 (/lib/x86_64-linux-gnu/libc.so.6+0x39206) #11 0x00007ecb69fc586b llvm::SDNode::getValueType(unsigned int) const /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8909:5 #12 0x00007ecb69fc586b llvm::SDValue::getValueType() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1187:28 #13 0x00007ecb69fc586b llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8924:14 #14 0x00007ecb69fc59fe llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, llvm::Align, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&, llvm::MDNode const*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8896:69 #15 0x00007ecb69fe086d llvm::SelectionDAG::getExtLoad(llvm::ISD::LoadExtType, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, llvm::MaybeAlign, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8974:52 #16 0x00007ecb69fff97a getMemcpyLoadsAndStores(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, unsigned long, llvm::Align, bool, bool, llvm::MachinePointerInfo, llvm::MachinePointerInfo, llvm::AAMDNodes const&, llvm::AAResults*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7941:13 #17 0x00007ecb6a00074c llvm::SelectionDAG::getMemcpy(llvm::SDValue, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::Align, bool, bool, llvm::CallInst const*, std::optional<bool>, llvm::MachinePointerInfo, llvm::MachinePointerInfo, llvm::AAMDNodes const&, llvm::AAResults*) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8272:5 #18 0x00007ecb69faa6ab llvm::SelectionDAGBuilder::updateDAGForMaybeTailCall(llvm::SDValue) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:11913:3 #19 0x00007ecb69faa6ab llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:6471:30 #20 0x00007ecb69faca30 llvm::Value::getValueID() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Value.h:533:12 #21 0x00007ecb69faca30 llvm::Instruction::getOpcode() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Instruction.h:274:49 #22 0x00007ecb69faca30 llvm::Instruction::isTerminator() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/IR/Instruction.h:277:50 #23 0x00007ecb69faca30 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:1348:22 #24 0x00007ecb6a0335cc llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, llvm::BasicBlock>, true>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node_base.h:42:38 #25 0x00007ecb6a0335cc llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node.h:125:66 #26 0x00007ecb6a0335cc llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>::operator++() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:345:25 #27 0x00007ecb6a0335cc 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&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:836:79 #28 0x00007ecb6a034270 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1864:33 #29 0x00007ecb6a035b4c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:632:22 #30 0x00007ecb6c86f7a8 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:72:3 #31 0x00007ecb6a021007 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:268:11 #32 0x00007ecb6a021007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:375:1 #33 0x00007ecb6a021007 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:346:6 #34 0x00007ecb69995b7f llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Source/llvm-project-19/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:33 #35 0x00007ecb6960c6d7 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1450:7 #36 0x00007ecb6960c911 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node_base.h:42:38 #37 0x00007ecb6960c911 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_node.h:117:66 #38 0x00007ecb6960c911 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Source/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:187:25 #39 0x00007ecb6960c911 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1485:22 #40 0x00007ecb6960d194 runOnModule /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:1562:7 #41 0x00007ecb6960d194 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Source/llvm-project-19/llvm/lib/IR/LegacyPassManager.cpp:541:55 #42 0x000057b619381a3c compileModule(char**, llvm::LLVMContext&) /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:742:34 #43 0x000057b619375f77 main /home/alexrp/Source/llvm-project-19/llvm/tools/llc/llc.cpp:409:35 #44 0x00007ecb67e28150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #45 0x00007ecb67e28209 call_init ./csu/../csu/libc-start.c:128:20 #46 0x00007ecb67e28209 __libc_start_main ./csu/../csu/libc-start.c:347:5 #47 0x000057b619376cf5 _start (/opt/llvm-19/bin/llc+0x13cf5) ``` If you add e.g. `-vfp2` to the `target-features`, there's no assertion failure. I understand that Clang doesn't hit this because it removes VFP target features when targeting soft float (as in `soft`, not `softfp`). In Zig, we would rather not have to replicate that part of Clang's frontend logic. I would expect this case to just work since `use-soft-float=true` is a policy attribute that should ultimately win over any VFP target features that may happen to be enabled. That seems to be the case for other LLVM targets.
tcwzxx commented 2 months ago

https://github.com/llvm/llvm-project/blob/0a272d3a1703415abca42dc2e2cc2b57cb30734e/llvm/lib/Target/ARM/ARMISelLowering.cpp#L19201-L19206

Should v2f64 be disabled for soft float? There is no LIBCALL to transform that.

alexrp commented 2 months ago

Should v2f64 be disabled for soft float? There is no LIBCALL to transform that.

At first glance, that looks quite reasonable to me FWIW.

I guess in the meantime, we can work around this with noimplicitfloat.