aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTypes.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-15 05:16:14 +0000
committerChris Lattner <sabre@nondot.org>2011-07-15 05:16:14 +0000
commit71305cc81bd379ddb8aa0d49e268267383202ca9 (patch)
treeb912e39d2731c71463cc506f52742562630c9c6b /lib/CodeGen/CodeGenTypes.h
parent91a5755ad73c5dc1dfb167e448fdd74e75a6df56 (diff)
Enhance the IR type lowering code to be much smarter about recursively lowering
types. Fore xample, we used to lower: struct bar { int a; }; struct foo { void (*FP)(struct bar); } G; to: %struct.foo = type { {}* } since the function pointer would cause recursive translation of bar and we didn't know if that would get us into trouble. We are now smart enough to know that it is fine, so we get this type instead: %struct.foo = type { void (i32)* } Codegen still needs to be prepared for uncooperative types at any place, which is why I let the maximally uncooperative code sit around for awhile to help shake out the bugs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.h')
-rw-r--r--lib/CodeGen/CodeGenTypes.h41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h
index 4229c59b83..7c0fb81643 100644
--- a/lib/CodeGen/CodeGenTypes.h
+++ b/lib/CodeGen/CodeGenTypes.h
@@ -81,32 +81,20 @@ class CodeGenTypes {
/// FunctionInfos - Hold memoized CGFunctionInfo results.
llvm::FoldingSet<CGFunctionInfo> FunctionInfos;
- enum RecursionStateTy {
- RS_Normal, // Normal type conversion.
- 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.
+ /// RecordsBeingLaidOut - This set keeps track of records that we're currently
+ /// converting to an IR type. For example, when converting:
+ /// struct A { struct B { int x; } } when processing 'x', the 'A' and 'B'
+ /// types will be in this set.
+ llvm::SmallPtrSet<const Type*, 4> RecordsBeingLaidOut;
+
+ llvm::SmallPtrSet<const CGFunctionInfo*, 4> FunctionsBeingProcessed;
+
+ /// SkippedLayout - True if we didn't layout a function due to a being inside
+ /// a recursive struct conversion, set this to true.
bool SkippedLayout;
llvm::SmallVector<const RecordDecl *, 8> DeferredRecords;
- struct RecursionStatePointerRAII {
- RecursionStateTy &Val;
- RecursionStateTy Saved;
-
- RecursionStatePointerRAII(RecursionStateTy &V) : Val(V), Saved(V) {
- if (Val == RS_Struct)
- Val = RS_StructPointer;
- }
-
- ~RecursionStatePointerRAII() {
- Val = Saved;
- }
- };
-
private:
/// TypeCache - This map keeps cache of llvm::Types
/// and maps llvm::Types to corresponding clang::Type.
@@ -232,6 +220,15 @@ public: // These are internal details of CGT that shouldn't be used externally.
/// IsZeroInitializable - Return whether a record type can be
/// zero-initialized (in the C++ sense) with an LLVM zeroinitializer.
bool isZeroInitializable(const CXXRecordDecl *RD);
+
+ bool isRecordLayoutComplete(const Type *Ty) const;
+ bool noRecordsBeingLaidOut() const {
+ return RecordsBeingLaidOut.empty();
+ }
+ bool isRecordBeingLaidOut(const Type *Ty) const {
+ return RecordsBeingLaidOut.count(Ty);
+ }
+
};
} // end namespace CodeGen