Open alexrp opened 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.
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
.
@llvm/issue-subscribers-backend-arm
Author: Alex Rønne Petersen (alexrp)
Should v2f64 be disabled for soft float? There is no LIBCALL to transform that.
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
.
If you add e.g.
-vfp2
to thetarget-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
, notsoftfp
). In Zig, we would rather not have to replicate that part of Clang's frontend logic. I would expect this case to just work sinceuse-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.