Skip to content

Commit e898ba2

Browse files
committed
[X86] Slightly improve our attempted error recovery for 64-bit -mno-sse2 in LowerCallResult to use FP1 if there are two return values.
If the return value is a struct of 2 doubles we need two return registers. If SSE2 is disabled we can't return in XMM registers like the ABI says. After logging an error we attempt to recover by using FP0 instead of an XMM register. But if the return needs two registers, we may have already used FP0. So if the register we were supposed to copy to is XMM1, copy to FP1 in the recovery instead. This seems to fix the assertion/crash in PR44413.
1 parent 4a6413c commit e898ba2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2993,11 +2993,17 @@ SDValue X86TargetLowering::LowerCallResult(
29932993
if ((CopyVT == MVT::f32 || CopyVT == MVT::f64 || CopyVT == MVT::f128) &&
29942994
((Is64Bit || Ins[InsIndex].Flags.isInReg()) && !Subtarget.hasSSE1())) {
29952995
errorUnsupported(DAG, dl, "SSE register return with SSE disabled");
2996-
VA.convertToReg(X86::FP0); // Set reg to FP0, avoid hitting asserts.
2996+
if (VA.getLocReg() == X86::XMM1)
2997+
VA.convertToReg(X86::FP1); // Set reg to FP1, avoid hitting asserts.
2998+
else
2999+
VA.convertToReg(X86::FP0); // Set reg to FP0, avoid hitting asserts.
29973000
} else if (CopyVT == MVT::f64 &&
29983001
(Is64Bit && !Subtarget.hasSSE2())) {
29993002
errorUnsupported(DAG, dl, "SSE2 register return with SSE2 disabled");
3000-
VA.convertToReg(X86::FP0); // Set reg to FP0, avoid hitting asserts.
3003+
if (VA.getLocReg() == X86::XMM1)
3004+
VA.convertToReg(X86::FP1); // Set reg to FP1, avoid hitting asserts.
3005+
else
3006+
VA.convertToReg(X86::FP0); // Set reg to FP0, avoid hitting asserts.
30013007
}
30023008

30033009
// If we prefer to use the value in xmm registers, copy it out as f80 and

0 commit comments

Comments
 (0)