-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
Description
Here is the llvm ir generated from mesa shader which contains llvm.amdgcn.fma.legacy:
Use llc to compile it
llc -march=amdgcn -mcpu=gfx1200 ps.ll.txt -o ps.s
just crash.
crash backtrace for llvm main branch when mesa driver compilation:
#6 0x00007ffff7c3b517 in __assert_fail (assertion=0x7fffeff03a18 "Opcode < NumOpcodes && \"Invalid opcode!\"",
file=0x7fffeff039d8 "/amd/opt/amd/llvm-project/llvm/include/llvm/MC/MCInstrInfo.h", line=91,
function=0x7fffeff03990 "const llvm::MCInstrDesc& llvm::MCInstrInfo::get(unsigned int) const") at ./assert/assert.c:105
#7 0x00007fffea5011eb in llvm::MCInstrInfo::get (this=0x7fffdc201ea8, Opcode=4294967295) at /amd/opt/amd/llvm-project/llvm/include/llvm/MC/MCInstrInfo.h:91
#8 0x00007fffef0b1663 in llvm::SIInstrInfo::getMCOpcodeFromPseudo (this=0x7fffdc201ea0, Opcode=9155) at /amd/opt/amd/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.h:1525
#9 0x00007fffef0a94a1 in llvm::SIInstrInfo::getInstSizeInBytes (this=0x7fffdc201ea0, MI=...) at /amd/opt/amd/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:9643
#10 0x00007fffea50dcf3 in (anonymous namespace)::BranchRelaxation::computeBlockSize (this=0x7fffe56b3730, MBB=...)
at /amd/opt/amd/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:218
#11 0x00007fffea50dada in (anonymous namespace)::BranchRelaxation::scanFunction (this=0x7fffe56b3730) at /amd/opt/amd/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:198
#12 0x00007fffea510d95 in (anonymous namespace)::BranchRelaxation::run (this=0x7fffe56b3730, mf=...) at /amd/opt/amd/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:797
#13 0x00007fffea50d2ea in (anonymous namespace)::BranchRelaxationLegacy::runOnMachineFunction (this=0x555555612df0, MF=...)
at /amd/opt/amd/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:130
#14 0x00007fffea90e8d7 in llvm::MachineFunctionPass::runOnFunction (this=0x555555612df0, F=...) at /amd/opt/amd/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108
#15 0x00007fffea175ae8 in llvm::FPPassManager::runOnFunction (this=0x55555560f610, F=...) at /amd/opt/amd/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1398
#16 0x00007fffed2a6c3f in (anonymous namespace)::CGPassManager::RunPassOnSCC (this=0x55555560ca80, P=0x55555560f610, CurSCC=..., CG=..., CallGraphUpToDate=@0x7fffe56b3e7d: true,
DevirtualizedCall=@0x7fffe56b3fb0: false) at /amd/opt/amd/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:179
#17 0x00007fffed2a7d60 in (anonymous namespace)::CGPassManager::RunAllPassesOnSCC (this=0x55555560ca80, CurSCC=..., CG=..., DevirtualizedCall=@0x7fffe56b3fb0: false)
at /amd/opt/amd/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:468
#18 0x00007fffed2a80e5 in (anonymous namespace)::CGPassManager::runOnModule (this=0x55555560ca80, M=...) at /amd/opt/amd/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:533
#19 0x00007fffea17621d in (anonymous namespace)::MPPassManager::runOnModule (this=0x55555555d600, M=...) at /amd/opt/amd/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1513
#20 0x00007fffea1711e4 in llvm::legacy::PassManagerImpl::run (this=0x5555555e7bc0, M=...) at /amd/opt/amd/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:531
#21 0x00007fffea176b13 in llvm::legacy::PassManager::run (this=0x5555555d4118, M=...) at /amd/opt/amd/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1640
It's OK for gfx1100. I can reproduce this problem from llvm 18 to current main branch.
Seems due to the llvm.amdgcn.fma.legacy is translated to V_FMAC_LEGACY_F32_e64 which mapped to v_fmac_dx9_zero_f32 on gfx11, but it's not available on gfx12. gfx12 has V_FMA_LEGACY_F32 which mapped to v_fma_dx9_zero_f32, so it should support llvm.amdgcn.fma.legacy.
And is there other way to use legacy fma, so I can work around in mesa driver?
mesa driver issue for this: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14359