[cfe-commits] r46743 - in /cfe/trunk/CodeGen: CGExprConstant.cpp CodeGenFunction.cpp CodeGenTypes.cpp CodeGenTypes.h
Chris Lattner
sabre at nondot.org
Mon Feb 4 22:55:31 PST 2008
Author: lattner
Date: Tue Feb 5 00:55:31 2008
New Revision: 46743
URL: http://llvm.org/viewvc/llvm-project?rev=46743&view=rev
Log:
Change the key of CGRecordLayouts from being an llvm type* to being a decl*. LLVM
Type*'s can change as types are refined, so we can't use them as a stable key in
the map. Decls don't change, so use them instead.
This patch was written by Anders, but he's too shy to commit it himself :)
Modified:
cfe/trunk/CodeGen/CGExprConstant.cpp
cfe/trunk/CodeGen/CodeGenFunction.cpp
cfe/trunk/CodeGen/CodeGenTypes.cpp
cfe/trunk/CodeGen/CodeGenTypes.h
Modified: cfe/trunk/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprConstant.cpp?rev=46743&r1=46742&r2=46743&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/CodeGen/CGExprConstant.cpp Tue Feb 5 00:55:31 2008
@@ -104,8 +104,9 @@
llvm::Constant *EmitStructInitialization(InitListExpr *ILE,
const llvm::StructType *SType) {
+ TagDecl *TD = ILE->getType()->getAsRecordType()->getDecl();
std::vector<llvm::Constant*> Elts;
- const CGRecordLayout *CGR = CGM.getTypes().getCGRecordLayout(SType);
+ const CGRecordLayout *CGR = CGM.getTypes().getCGRecordLayout(TD);
unsigned NumInitElements = ILE->getNumInits();
unsigned NumElements = SType->getNumElements();
Modified: cfe/trunk/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.cpp?rev=46743&r1=46742&r2=46743&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.cpp Tue Feb 5 00:55:31 2008
@@ -139,14 +139,11 @@
/// getCGRecordLayout - Return record layout info.
const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
- QualType RTy) {
- assert (isa<RecordType>(RTy)
- && "Unexpected type. RecordType expected here.");
+ QualType Ty) {
+ const RecordType *RTy = Ty->getAsRecordType();
+ assert (RTy && "Unexpected type. RecordType expected here.");
- const llvm::Type *Ty = ConvertType(RTy);
- assert (Ty && "Unable to find llvm::Type");
-
- return CGT.getCGRecordLayout(Ty);
+ return CGT.getCGRecordLayout(RTy->getDecl());
}
/// WarnUnsupported - Print out a warning that codegen doesn't support the
Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=46743&r1=46742&r2=46743&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Tue Feb 5 00:55:31 2008
@@ -84,7 +84,7 @@
}
CodeGenTypes::~CodeGenTypes() {
- for(llvm::DenseMap<const llvm::Type *, CGRecordLayout *>::iterator
+ for(llvm::DenseMap<const TagDecl *, CGRecordLayout *>::iterator
I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
I != E; ++I)
delete I->second;
@@ -332,7 +332,7 @@
CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType(),
RO.getPaddingFields());
ResultType = TagDeclTypes[TD] = RLI->getLLVMType();
- CGRecordLayouts[ResultType] = RLI;
+ CGRecordLayouts[TD] = RLI;
// Refine any OpaqueType associated with this RecordDecl.
OpaqueTy->refineAbstractTypeTo(ResultType);
@@ -356,7 +356,7 @@
CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType(),
RO.getPaddingFields());
ResultType = TagDeclTypes[TD] = RLI->getLLVMType();
- CGRecordLayouts[ResultType] = RLI;
+ CGRecordLayouts[TD] = RLI;
} else {
std::vector<const llvm::Type*> Fields;
ResultType = TagDeclTypes[TD] = llvm::StructType::get(Fields);
@@ -436,9 +436,9 @@
/// getCGRecordLayout - Return record layout info for the given llvm::Type.
const CGRecordLayout *
-CodeGenTypes::getCGRecordLayout(const llvm::Type* Ty) const {
- llvm::DenseMap<const llvm::Type*, CGRecordLayout *>::iterator I
- = CGRecordLayouts.find(Ty);
+CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
+ llvm::DenseMap<const TagDecl*, CGRecordLayout *>::iterator I
+ = CGRecordLayouts.find(TD);
assert (I != CGRecordLayouts.end()
&& "Unable to find record layout information for type");
return I->second;
Modified: cfe/trunk/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.h?rev=46743&r1=46742&r2=46743&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.h Tue Feb 5 00:55:31 2008
@@ -81,7 +81,7 @@
/// record layout info.
/// FIXME : If CGRecordLayout is less than 16 bytes then use
/// inline it in the map.
- llvm::DenseMap<const llvm::Type*, CGRecordLayout *> CGRecordLayouts;
+ llvm::DenseMap<const TagDecl*, CGRecordLayout *> CGRecordLayouts;
/// FieldInfo - This maps struct field with corresponding llvm struct type
/// field no. This info is populated by record organizer.
@@ -136,7 +136,7 @@
const llvm::Type *ConvertTypeForMem(QualType T);
- const CGRecordLayout *getCGRecordLayout(const llvm::Type*) const;
+ const CGRecordLayout *getCGRecordLayout(const TagDecl*) const;
/// getLLVMFieldNo - Return llvm::StructType element number
/// that corresponds to the field FD.
More information about the cfe-commits
mailing list