Index: lib/Target/X86/X86CallingConv.td
===================================================================
--- lib/Target/X86/X86CallingConv.td	(revision 150629)
+++ lib/Target/X86/X86CallingConv.td	(working copy)
@@ -331,8 +331,8 @@
   // Promote i8/i16 arguments to i32.
   CCIfType<[i8, i16], CCPromoteToType<i32>>,
 
-  // The 'nest' parameter, if any, is passed in EAX.
-  CCIfNest<CCAssignToReg<[EAX]>>,
+  // Pass sret arguments indirectly through EAX
+  CCIfSRet<CCAssignToReg<[EAX]>>,
 
   // The first integer argument is passed in ECX
   CCIfType<[i32], CCAssignToReg<[ECX]>>,
Index: test/CodeGen/X86/thiscall-struct-return.ll
===================================================================
--- test/CodeGen/X86/thiscall-struct-return.ll	(revision 0)
+++ test/CodeGen/X86/thiscall-struct-return.ll	(working copy)
@@ -0,0 +1,30 @@
+; RUN: llc < %s -mtriple=i386-PC-Win32 | FileCheck %s
+
+%class.C = type { i8 }
+%struct.S = type { i32 }
+%struct.M = type { i32, i32 }
+
+declare void @_ZN1CC1Ev(%class.C* %this) unnamed_addr nounwind align 2
+declare x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* noalias sret %agg.result, %class.C* %this) nounwind align 2
+declare x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* noalias sret %agg.result, %class.C* %this) nounwind align 2
+
+define void @testv() nounwind {
+; CHECK: testv:
+; CHECK: leal
+; CHECK: movl
+; CHECK: calll
+; CHECK: leal 16(%esp), %eax
+; CHECK: calll
+; CHECK: leal 8(%esp), %eax
+; CHECK: calll
+entry:
+  %c = alloca %class.C, align 1
+  %tmp = alloca %struct.S, align 4
+  %tmp1 = alloca %struct.M, align 4
+  call void @_ZN1CC1Ev(%class.C* %c)
+  ; These two calls should end up moving the hidden structure
+  ; pointers into EAX instead of getting them from EAX/EDX
+  call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %tmp, %class.C* %c)
+  call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %tmp1, %class.C* %c)
+  ret void
+}
