Index: lib/CodeGen/CodeGenTypes.h
===================================================================
--- lib/CodeGen/CodeGenTypes.h	(revision 167608)
+++ lib/CodeGen/CodeGenTypes.h	(working copy)
@@ -251,6 +251,9 @@
   bool isRecordBeingLaidOut(const Type *Ty) const {
     return RecordsBeingLaidOut.count(Ty);
   }
+  bool noFunctionsBeingProcessed() const {
+    return FunctionsBeingProcessed.empty();
+  }
                             
 };
 
Index: lib/CodeGen/CodeGenTypes.cpp
===================================================================
--- lib/CodeGen/CodeGenTypes.cpp	(revision 167608)
+++ lib/CodeGen/CodeGenTypes.cpp	(working copy)
@@ -178,6 +178,9 @@
 /// decl to IR and lay it out, false if doing so would cause us to get into a
 /// recursive compilation mess.
 static bool isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT) {
+  // If functions are being processed, this struct is deferred.
+  if (!CGT.noFunctionsBeingProcessed()) return false;
+
   // If no structs are being laid out, we can certainly do this one.
   if (CGT.noRecordsBeingLaidOut()) return true;
   
