Index: lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- lib/AST/RecordLayoutBuilder.cpp	(revision 141950)
+++ lib/AST/RecordLayoutBuilder.cpp	(working copy)
@@ -793,6 +793,8 @@
   // indirect bases, and record all their primary virtual base classes.
   RD->getIndirectPrimaryBases(IndirectPrimaryBases);
 
+  bool HasNonVirtBases = false;
+
   // If the record has a dynamic base class, attempt to choose a primary base
   // class. It is the first (in direct base class order) non-virtual dynamic
   // base class, if one exists.
@@ -804,6 +806,7 @@
 
     const CXXRecordDecl *Base =
       cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
+    HasNonVirtBases = true;
 
     if (Base->isDynamicClass()) {
       // We found it.
@@ -813,6 +816,20 @@
     }
   }
 
+  // r4start
+  // MSVC doesn't have primary virtual base.
+  if (Context.getTargetInfo().getCXXABI() == CXXABI_Microsoft) {
+    if (HasNewVirtualFunction(RD)) {
+      AddVPointer();
+
+      if (!HasNonVirtBases) {
+        setSize(getSize().RoundUpToAlignment(Alignment));
+        setDataSize(getSize());
+      }
+    }
+    return;
+  }
+
   // Otherwise, it is the first nearly empty virtual base that is not an
   // indirect primary virtual base class, if one exists.
   if (RD->getNumVBases() != 0) {
@@ -1066,11 +1083,6 @@
     Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
   setSize(getSize() + PtrWidth);
   setDataSize(getSize());
-
-  if (Alignment > PtrWidth) {
-    setSize(getSize() + (Alignment - PtrWidth));
-    setDataSize(getSize());
-  }
 }
 
 bool 
Index: test/Sema/ms_class_layout.cpp
===================================================================
--- test/Sema/ms_class_layout.cpp	(revision 141950)
+++ test/Sema/ms_class_layout.cpp	(working copy)
@@ -58,6 +58,18 @@
     double b;
 };
 
+struct H
+{
+  int h_field;
+};
+
+struct I : public H, 
+          public virtual D
+{
+  char i_field1;
+  int i_field2;
+};
+
 #pragma pack(pop)
 
 // This needs only for building layouts. 
@@ -69,6 +81,7 @@
   DerivedStruct* v;
   G* g;
   BaseStruct* u;
+  I* h;
   return 0;
 }
 
@@ -171,6 +184,24 @@
 // CHECK-NEXT: sizeof=80, dsize=80, align=8
 // CHECK-NEXT: nvsize=80, nvalign=8
 
-// CHECK: 96 |   int x
+// CHECK:      96 |   int x
 // CHECK-NEXT: sizeof=104, dsize=104, align=8
 // CHECK-NEXT: nvsize=104, nvalign=8
+
+// CHECK:       0 | struct H
+// CHECK-NEXT:  0 |   int h_field
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+  
+// CHECK:       0 | struct I
+// CHECK-NEXT:  0 |   (I vtable pointer)
+// CHECK-NEXT:  4 |   (I vbtable pointer)
+// CHECK-NEXT:  0 |   struct H (base)
+// CHECK-NEXT:  0 |     int h_field
+// CHECK-NEXT:  8 |   char i_field1
+// CHECK-NEXT: 12 |   int i_field2
+// CHECK-NEXT: 16 |   class D (virtual base)
+// CHECK-NEXT: 16 |     (D vtable pointer)
+// CHECK-NEXT: 24 |     double a
+// CHECK-NEXT: sizeof=32, dsize=32, align=8
+// CHECK-NEXT: nvsize=32, nvalign=8
