Index: src/IceTargetLoweringX8632.cpp |
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
index e8a86d87e0fd32c0b4fc34a756833fb5515926c5..e8bd77184d619a5429ca80731e3cb9f9e8abf2a0 100644 |
--- a/src/IceTargetLoweringX8632.cpp |
+++ b/src/IceTargetLoweringX8632.cpp |
@@ -497,6 +497,18 @@ void TargetX8632::addProlog(CfgNode *Node) { |
uint32_t GlobalsAndSubsequentPaddingSize = |
GlobalsSize + LocalsSlotsPaddingBytes; |
+ // Functions returning scalar floating point types may need to convert values |
+ // from an in-register xmm value to the top of the x87 floating point stack. |
+ // This is done by a movp[sd] and an fld[sd]. Ensure there is enough scratch |
+ // space on the stack for this. |
+ const Type ReturnType = Func->getReturnType(); |
+ if (isScalarFloatingType(ReturnType)) { |
+ // Avoid misaligned double-precicion load/store. |
+ NeedsStackAlignment = true; |
+ SpillAreaSizeBytes = |
+ std::max(typeWidthInBytesOnStack(ReturnType), SpillAreaSizeBytes); |
+ } |
+ |
// Align esp if necessary. |
if (NeedsStackAlignment) { |
uint32_t StackOffset = |