Skip to content

Commit c02bdd4

Browse files
authored
[AMDGPU] Fix handling of FP in cs.chain functions (#161194)
In case there is an dynamic alloca / an alloca which is not in the entry block, cs.chain functions do not set up an FP, but are reported to need one. This results in a failed assertion in `SIFrameLowering::emitPrologue()` (Assertion `(!HasFP || FPSaved) && "Needed to save FP but didn't save it anywhere"' failed.) This commit changes `hasFPImpl` so that the need for an SP in a cs.chain function does not directly imply the need for an FP anymore. This LLVM defect was identified via the AMD Fuzzing project.
1 parent f74e909 commit c02bdd4

File tree

2 files changed

+522
-1
lines changed

2 files changed

+522
-1
lines changed

llvm/lib/Target/AMDGPU/SIFrameLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,9 @@ bool SIFrameLowering::hasFPImpl(const MachineFunction &MF) const {
21702170
return MFI.getStackSize() != 0;
21712171
}
21722172

2173-
return frameTriviallyRequiresSP(MFI) || MFI.isFrameAddressTaken() ||
2173+
return (frameTriviallyRequiresSP(MFI) &&
2174+
!MF.getInfo<SIMachineFunctionInfo>()->isChainFunction()) ||
2175+
MFI.isFrameAddressTaken() ||
21742176
MF.getSubtarget<GCNSubtarget>().getRegisterInfo()->hasStackRealignment(
21752177
MF) ||
21762178
mayReserveScratchForCWSR(MF) ||

0 commit comments

Comments
 (0)