Created attachment 7867 [details] File to produce assertion, --enable-assertion=YES is required This assertion in CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) bothers Peren test. It makes it failed. This assertion tried to compute the size of BaseTy of a layout's non virtual size. However, the real code has modified the BaseTy before assertion. So I added a recompution of the real BaseTy in assert test segment ... // If we're in C++, compute the base subobject type. llvm::StructType *BaseTy = 0; if (isa<CXXRecordDecl>(D)) { BaseTy = Builder.BaseSubobjectType; if (!BaseTy) BaseTy = Ty; <--- is not BaseTy anymore if BaseTy is NULL } ... #ifndef NDEBUG // Verify that the computed LLVM struct size matches the AST layout size. const ASTRecordLayout &Layout = getContext().getASTRecordLayout(D); ... if (BaseTy) { <-- this requires the true BaseTy CharUnits NonVirtualSize = Layout.getNonVirtualSize(); CharUnits NonVirtualAlign = Layout.getNonVirtualAlign(); CharUnits AlignedNonVirtualTypeSize = NonVirtualSize.RoundUpToAlignment(NonVirtualAlign); uint64_t AlignedNonVirtualTypeSizeInBits = getContext().toBits(AlignedNonVirtualTypeSize); assert(AlignedNonVirtualTypeSizeInBits == getTargetData().getTypeAllocSizeInBits(BaseTy) && "Type size mismatch!"); }
I have a potential fix already, please see clang.diff attached
Created attachment 7868 [details] The patch I proprosed
Created attachment 7869 [details] Validation File 1
Created attachment 7870 [details] Validation File 2
I recompute the BaseTy in the assertion segment to deal with this problem. I have run both cross and simple cross test validation with this change. No new failure is introduced. Please give a review, Thanks.
Created attachment 7872 [details] This is the real t.c to produce the assertion. --enable-assertion is required
r148093.