summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/CallingConvLower.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-01-12 23:28:23 +0000
committerReid Kleckner <reid@kleckner.net>2015-01-12 23:28:23 +0000
commitbba20f06de1c11f8332387788914c70bef5607df (patch)
tree9ba13ac3d54b7cd261ede31b73664fa8b6a28a24 /llvm/lib/CodeGen/CallingConvLower.cpp
parent64dae8354b11f1ee8e0f894195d648f659b4b515 (diff)
downloadbcm5719-llvm-bba20f06de1c11f8332387788914c70bef5607df.tar.gz
bcm5719-llvm-bba20f06de1c11f8332387788914c70bef5607df.zip
musttail: Only set the inreg flag for fastcall and vectorcall
Otherwise we'll attempt to forward ECX, EDX, and EAX for cdecl and stdcall thunks, leaving us with no scratch registers for indirect call targets. Fixes PR22052. llvm-svn: 225729
Diffstat (limited to 'llvm/lib/CodeGen/CallingConvLower.cpp')
-rw-r--r--llvm/lib/CodeGen/CallingConvLower.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp
index fbe8b7c10e6..034ffb34b9c 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -181,15 +181,28 @@ void CCState::AnalyzeCallResult(MVT VT, CCAssignFn Fn) {
}
}
+static bool isValueTypeInRegForCC(CallingConv::ID CC, MVT VT) {
+ if (VT.isVector())
+ return true; // Assume -msse-regparm might be in effect.
+ if (!VT.isInteger())
+ return false;
+ if (CC == CallingConv::X86_VectorCall || CC == CallingConv::X86_FastCall)
+ return true;
+ return false;
+}
+
void CCState::getRemainingRegParmsForType(SmallVectorImpl<MCPhysReg> &Regs,
MVT VT, CCAssignFn Fn) {
unsigned SavedStackOffset = StackOffset;
unsigned NumLocs = Locs.size();
- // Allocate something of this value type repeatedly with just the inreg flag
- // set until we get assigned a location in memory.
+ // Set the 'inreg' flag if it is used for this calling convention.
ISD::ArgFlagsTy Flags;
- Flags.setInReg();
+ if (isValueTypeInRegForCC(CallingConv, VT))
+ Flags.setInReg();
+
+ // Allocate something of this value type repeatedly until we get assigned a
+ // location in memory.
bool HaveRegParm = true;
while (HaveRegParm) {
if (Fn(0, VT, VT, CCValAssign::Full, Flags, *this)) {
OpenPOWER on IntegriCloud