Temporarily revert r176116 for compile-time performance regression.

This reverts commit ea95e4587fd13606fbf63b10a07a7d02026aa39c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176151 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index d1bf9a9..d539e00 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -1093,51 +1093,38 @@
 /// all_declared_ivar_begin - return first ivar declared in this class,
 /// its extensions and its implementation. Lazily build the list on first
 /// access.
-///
-/// Caveat: The list returned by this method reflects the current
-/// state of the parser. The cache will be updated for every ivar
-/// added by an extension or the implementation when they are
-/// encountered.
-/// See also ObjCIvarDecl::Create().
 ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
   // FIXME: Should make sure no callers ever do this.
   if (!hasDefinition())
     return 0;
   
+  if (data().IvarList)
+    return data().IvarList;
+  
   ObjCIvarDecl *curIvar = 0;
-  if (!data().IvarList) {
-    if (!ivar_empty()) {
-      ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
-      data().IvarList = *I; ++I;
-      for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
-        curIvar->setNextIvar(*I);
-    }
-
-    for (ObjCInterfaceDecl::known_extensions_iterator
-           Ext = known_extensions_begin(),
-           ExtEnd = known_extensions_end();
-         Ext != ExtEnd; ++Ext) {
-      if (!Ext->ivar_empty()) {
-        ObjCCategoryDecl::ivar_iterator
-          I = Ext->ivar_begin(),
-          E = Ext->ivar_end();
-        if (!data().IvarList) {
-          data().IvarList = *I; ++I;
-          curIvar = data().IvarList;
-        }
-        for ( ;I != E; curIvar = *I, ++I)
-          curIvar->setNextIvar(*I);
-      }
-    }
-    data().IvarListMissingImplementation = true;
+  if (!ivar_empty()) {
+    ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
+    data().IvarList = *I; ++I;
+    for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
+      curIvar->setNextIvar(*I);
   }
 
-  // cached and complete!
-  if (!data().IvarListMissingImplementation)
-      return data().IvarList;
+  for (ObjCInterfaceDecl::known_extensions_iterator
+         Ext = known_extensions_begin(),
+         ExtEnd = known_extensions_end();
+       Ext != ExtEnd; ++Ext) {
+    if (!Ext->ivar_empty()) {
+      ObjCCategoryDecl::ivar_iterator I = Ext->ivar_begin(),E = Ext->ivar_end();
+      if (!data().IvarList) {
+        data().IvarList = *I; ++I;
+        curIvar = data().IvarList;
+      }
+      for ( ;I != E; curIvar = *I, ++I)
+        curIvar->setNextIvar(*I);
+    }
+  }
   
   if (ObjCImplementationDecl *ImplDecl = getImplementation()) {
-    data().IvarListMissingImplementation = false;
     if (!ImplDecl->ivar_empty()) {
       SmallVector<SynthesizeIvarChunk, 16> layout;
       for (ObjCImplementationDecl::ivar_iterator I = ImplDecl->ivar_begin(),
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 2d0d2b8..970ba50 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1343,7 +1343,7 @@
   LexicalBlockStack.push_back(FwdDeclNode);
   RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);
 
-  // Add this to the completed-type cache while we're completing it recursively.
+  // Add this to the completed types cache since we're completing it.
   CompletedTypeCache[QualType(Ty, 0).getAsOpaquePtr()] = FwdDecl;
 
   // Convert all the elements.
@@ -1436,8 +1436,7 @@
 
   // Otherwise, insert it into the CompletedTypeCache so that recursive uses
   // will find it and we're emitting the complete type.
-  QualType QualTy = QualType(Ty, 0);
-  CompletedTypeCache[QualTy.getAsOpaquePtr()] = RealDecl;
+  CompletedTypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
   // Push the struct on region stack.
   llvm::TrackingVH<llvm::MDNode> FwdDeclNode(RealDecl);
 
@@ -1562,12 +1561,6 @@
 
   llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
   FwdDeclNode->replaceOperandWith(10, Elements);
-
-  // If the implementation is not yet set, we do not want to mark it
-  // as complete. An implementation may declare additional
-  // private ivars that we would miss otherwise.
-  if (ID->getImplementation() == 0)
-    CompletedTypeCache.erase(QualTy.getAsOpaquePtr());
   
   LexicalBlockStack.pop_back();
   return llvm::DIType(FwdDeclNode);
@@ -1831,10 +1824,6 @@
     ReplaceMap.push_back(std::make_pair(Ty.getAsOpaquePtr(),
                                         static_cast<llvm::Value*>(TC)));
   
-  // Do not cache the type if it may be incomplete.
-  if (maybeIncompleteInterface(Ty))
-    return Res;
-
   // And update the type cache.
   TypeCache[Ty.getAsOpaquePtr()] = Res;
 
@@ -1844,21 +1833,6 @@
   return Res;
 }
 
-/// clang::ParseAST handles each TopLevelDecl immediately after it was parsed.
-/// A subsequent implementation may add more ivars to an interface, which is
-/// why we cannot cache it yet.
-bool CGDebugInfo::maybeIncompleteInterface(QualType Ty) {
-  switch (Ty->getTypeClass()) {
-  case Type::ObjCObjectPointer:
-    return maybeIncompleteInterface(cast<ObjCObjectPointerType>(Ty)->getPointeeType());
-  case Type::ObjCInterface:
-    if (ObjCInterfaceDecl *Decl = cast<ObjCInterfaceType>(Ty)->getDecl())
-      return (Decl->getImplementation() == 0);
-  default:
-    return false;
-  }
-}
-
 /// CreateTypeNode - Create a new debug type node.
 llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) {
   // Handle qualifiers, which recursively handles what they refer to.
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index 81b5c71..fbbee0b 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -299,10 +299,6 @@
   /// CreateTypeNode - Create type metadata for a source language type.
   llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile F);
 
-  /// maybeIncompleteInterface - Determine if Ty may contain an
-  /// interface without an implementation
-  bool maybeIncompleteInterface(QualType Ty);
-
   /// CreateLimitedTypeNode - Create type metadata for a source language
   /// type, but only partial types for records.
   llvm::DIType CreateLimitedTypeNode(QualType Ty, llvm::DIFile F);