aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp9
-rw-r--r--lib/CodeGen/CodeGenTypes.h6
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 59c632f0d7..16946b64b3 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -32,6 +32,7 @@ CodeGenTypes::CodeGenTypes(ASTContext &Ctx, llvm::Module& M,
: Context(Ctx), Target(Ctx.Target), TheModule(M), TheTargetData(TD),
TheABIInfo(Info), TheCXXABI(CXXABI), CodeGenOpts(CGO) {
RecursionState = RS_Normal;
+ SkippedLayout = false;
}
CodeGenTypes::~CodeGenTypes() {
@@ -345,6 +346,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
// This function's type depends on an incomplete tag type.
// Return a placeholder type.
ResultType = llvm::StructType::get(getLLVMContext());
+
+ SkippedLayout |= RecursionState == RS_StructPointer;
break;
}
@@ -373,6 +376,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
// Restore our recursion state.
RecursionState = SavedRecursionState;
+
+ if (SkippedLayout)
+ TypeCache.clear();
if (RecursionState == RS_Normal)
while (!DeferredRecords.empty())
@@ -487,7 +493,8 @@ llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) {
// If this struct blocked a FunctionType conversion, then recompute whatever
// was derived from that.
// FIXME: This is hugely overconservative.
- TypeCache.clear();
+ if (SkippedLayout)
+ TypeCache.clear();
// Restore our recursion state. If we're done converting the outer-most
diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h
index 98786007d7..4229c59b83 100644
--- a/lib/CodeGen/CodeGenTypes.h
+++ b/lib/CodeGen/CodeGenTypes.h
@@ -86,7 +86,11 @@ class CodeGenTypes {
RS_Struct, // Recursively inside a struct conversion.
RS_StructPointer // Recursively inside a pointer in a struct.
} RecursionState;
-
+
+ /// SkippedLayout - True if we didn't layout a function bit due to a
+ /// RS_StructPointer RecursionState.
+ bool SkippedLayout;
+
llvm::SmallVector<const RecordDecl *, 8> DeferredRecords;
struct RecursionStatePointerRAII {