aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-03 14:17:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-03 14:17:18 +0000
commit25d583ec27cc2fe4d0dccaa5d41b6c3b645beda0 (patch)
treed6e586e09898a02d2a8a69a8d3791974fe639235 /lib/CodeGen/CGObjCMac.cpp
parentd58edcb49140b4e82f8b1e2f2e6ab35b9d401c99 (diff)
Lift common subexpression, remove dead "base" variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 13864d7265..35fb54fae4 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -2956,21 +2956,22 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
FieldDecl *MaxSkippedField = 0;
FieldDecl *LastFieldBitfield = 0;
- unsigned base = 0;
if (RecFields.empty())
return;
- if (IsUnion)
- base = BytePos + GetFieldBaseOffset(OI, Layout, RecFields[0]);
unsigned WordSizeInBits = CGM.getContext().Target.getPointerWidth(0);
unsigned ByteSizeInBits = CGM.getContext().Target.getCharWidth();
for (unsigned i = 0, e = RecFields.size(); i != e; ++i) {
FieldDecl *Field = RecFields[i];
+
// Skip over unnamed or bitfields
if (!Field->getIdentifier() || Field->isBitField()) {
LastFieldBitfield = Field;
continue;
}
+
+ unsigned FieldOffset = GetFieldBaseOffset(OI, Layout, Field);
+
LastFieldBitfield = 0;
QualType FQT = Field->getType();
if (FQT->isRecordType() || FQT->isUnionType()) {
@@ -2978,7 +2979,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
HasUnion = true;
BuildAggrIvarRecordLayout(FQT->getAsRecordType(),
- BytePos + GetFieldBaseOffset(OI, Layout, Field),
+ BytePos + FieldOffset,
ForStrongLayout, HasUnion);
continue;
}
@@ -3003,9 +3004,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
int OldSkIndex = SkipIvars.size() -1;
const RecordType *RT = FQT->getAsRecordType();
- BuildAggrIvarRecordLayout(RT,
- BytePos + GetFieldBaseOffset(OI, Layout,
- Field),
+ BuildAggrIvarRecordLayout(RT, BytePos + FieldOffset,
ForStrongLayout, HasUnion);
// Replicate layout information for each array element. Note that
@@ -3038,8 +3037,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
MaxField = Field;
}
} else {
- IvarsInfo.push_back(GC_IVAR(BytePos + GetFieldBaseOffset(OI, Layout,
- Field),
+ IvarsInfo.push_back(GC_IVAR(BytePos + FieldOffset,
FieldSize / WordSizeInBits));
}
} else if ((ForStrongLayout &&
@@ -3055,8 +3053,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
}
} else {
// FIXME: Why the asymmetry, we divide by byte size in bits here?
- SkipIvars.push_back(GC_IVAR(BytePos + GetFieldBaseOffset(OI, Layout,
- Field),
+ SkipIvars.push_back(GC_IVAR(BytePos + FieldOffset,
FieldSize / ByteSizeInBits));
}
}