[cfe-commits] r135032 - /cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Chris Lattner
sabre at nondot.org
Tue Jul 12 22:31:19 PDT 2011
Author: lattner
Date: Wed Jul 13 00:31:19 2011
New Revision: 135032
URL: http://llvm.org/viewvc/llvm-project?rev=135032&view=rev
Log:
per john's advice, speculatively lower uses of forward-declared enums to
i32. They almost always end up this way in the end anyway, and if we get
lucky, this avoids generating some bitcasts.
Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=135032&r1=135031&r2=135032&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Wed Jul 13 00:31:19 2011
@@ -154,8 +154,13 @@
// from the enum to be recomputed.
if (const EnumDecl *ED = dyn_cast<EnumDecl>(TD)) {
// Only flush the cache if we've actually already converted this type.
- if (TypeCache.count(ED->getTypeForDecl()))
- TypeCache.clear();
+ if (TypeCache.count(ED->getTypeForDecl())) {
+ // Okay, we formed some types based on this. We speculated that the enum
+ // would be lowered to i32, so we only need to flush the cache if this
+ // didn't happen.
+ if (!ConvertType(ED->getIntegerType())->isIntegerTy(32))
+ TypeCache.clear();
+ }
return;
}
@@ -416,12 +421,14 @@
break;
}
- case Type::Enum: {
+ case Type::Enum: {
const EnumDecl *ED = cast<EnumType>(Ty)->getDecl();
if (ED->isDefinition() || ED->isFixed())
return ConvertType(ED->getIntegerType());
- // Return a placeholder '{}' type.
- ResultType = llvm::StructType::get(getLLVMContext());
+ // Return a placeholder 'i32' type. This can be changed later when the
+ // type is defined (see UpdateCompletedType), but is likely to be the
+ // "right" answer.
+ ResultType = llvm::Type::getInt32Ty(getLLVMContext());
break;
}
More information about the cfe-commits
mailing list