From 57eb23f34ed2586069273c66f1a9994fe2b42967 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 10 Jul 2011 05:39:13 +0000 Subject: keep track of whether being in a RS_StructPointer state caused us to skip layout out a function accurately. If so, flush the type cache for both the function and struct case to ensure that any pointers to the functions get recomputed. This is overconservative, but with this patch clang can build itself again. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134863 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CodeGenTypes.cpp') 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 -- cgit v1.2.3