Index: clang/lib/CodeGen/CodeGenTypes.h =================================================================== --- clang/lib/CodeGen/CodeGenTypes.h +++ clang/lib/CodeGen/CodeGenTypes.h @@ -80,10 +80,6 @@ llvm::SmallPtrSet FunctionsBeingProcessed; - /// True if we didn't layout a function due to a being inside - /// a recursive struct conversion, set this to true. - bool SkippedLayout; - /// This map keeps cache of llvm::Types and maps clang::Type to /// corresponding llvm::Type. llvm::DenseMap TypeCache; Index: clang/lib/CodeGen/CodeGenTypes.cpp =================================================================== --- clang/lib/CodeGen/CodeGenTypes.cpp +++ clang/lib/CodeGen/CodeGenTypes.cpp @@ -33,7 +33,6 @@ : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()), Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()), TheABIInfo(cgm.getTargetCodeGenInfo().getABIInfo()) { - SkippedLayout = false; } CodeGenTypes::~CodeGenTypes() { @@ -251,8 +250,6 @@ if (const RecordType *RT = FPT->getParamType(i)->getAs()) ConvertRecordDeclType(RT->getDecl()); - SkippedLayout = true; - // Return a placeholder type. return llvm::StructType::get(getLLVMContext()); } @@ -275,7 +272,6 @@ if (FunctionsBeingProcessed.count(FI)) { ResultType = llvm::StructType::get(getLLVMContext()); - SkippedLayout = true; } else { // Otherwise, we're good to go, go ahead and convert it. @@ -580,10 +576,8 @@ // int X[] -> [0 x int], unless the element type is not sized. If it is // unsized (e.g. an incomplete struct) just use [0 x i8]. ResultType = ConvertTypeForMem(A->getElementType()); - if (!ResultType->isSized()) { - SkippedLayout = true; + if (!ResultType->isSized()) ResultType = llvm::Type::getInt8Ty(getLLVMContext()); - } ResultType = llvm::ArrayType::get(ResultType, 0); break; } @@ -593,10 +587,8 @@ // Lower arrays of undefined struct type to arrays of i8 just to have a // concrete type. - if (!EltTy->isSized()) { - SkippedLayout = true; + if (!EltTy->isSized()) EltTy = llvm::Type::getInt8Ty(getLLVMContext()); - } ResultType = llvm::ArrayType::get(EltTy, A->getSize().getZExtValue()); break; @@ -757,12 +749,6 @@ std::unique_ptr Layout = ComputeRecordLayout(RD, Ty); CGRecordLayouts[Key] = std::move(Layout); - // If this struct blocked a FunctionType conversion, then recompute whatever - // was derived from that. - // FIXME: This is hugely overconservative. - if (SkippedLayout) - TypeCache.clear(); - return Ty; }