aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorKen Dyck <kd@kendyck.com>2011-03-18 00:55:06 +0000
committerKen Dyck <kd@kendyck.com>2011-03-18 00:55:06 +0000
commit4a5c87ec3b92026523a6459f5b4547c4a9b5ab24 (patch)
tree06578aeac0b54a1d2b2d4fd67c138672c91dfdcf /lib/CodeGen/CGExprConstant.cpp
parentd47ea693706f7b0ffa68e879b73a71609a337786 (diff)
Convert variables to CharUnits in ConvertStructToPacked(). No change in
functionality intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127844 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--lib/CodeGen/CGExprConstant.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 9034cdee59..59480a0323 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -297,36 +297,36 @@ void ConstStructBuilder::AppendTailPadding(CharUnits RecordSize) {
void ConstStructBuilder::ConvertStructToPacked() {
std::vector<llvm::Constant *> PackedElements;
- uint64_t ElementOffsetInBytes = 0;
+ CharUnits ElementOffsetInChars = CharUnits::Zero();
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
llvm::Constant *C = Elements[i];
unsigned ElementAlign =
CGM.getTargetData().getABITypeAlignment(C->getType());
- uint64_t AlignedElementOffsetInBytes =
- llvm::RoundUpToAlignment(ElementOffsetInBytes, ElementAlign);
+ CharUnits AlignedElementOffsetInChars =
+ ElementOffsetInChars.RoundUpToAlignment(
+ CharUnits::fromQuantity(ElementAlign));
- if (AlignedElementOffsetInBytes > ElementOffsetInBytes) {
+ if (AlignedElementOffsetInChars > ElementOffsetInChars) {
// We need some padding.
- uint64_t NumBytes =
- AlignedElementOffsetInBytes - ElementOffsetInBytes;
+ CharUnits NumChars =
+ AlignedElementOffsetInChars - ElementOffsetInChars;
const llvm::Type *Ty = llvm::Type::getInt8Ty(CGM.getLLVMContext());
- if (NumBytes > 1)
- Ty = llvm::ArrayType::get(Ty, NumBytes);
+ if (NumChars > CharUnits::One())
+ Ty = llvm::ArrayType::get(Ty, NumChars.getQuantity());
llvm::Constant *Padding = llvm::UndefValue::get(Ty);
PackedElements.push_back(Padding);
- ElementOffsetInBytes += getSizeInBytes(Padding);
+ ElementOffsetInChars += CharUnits::fromQuantity(getSizeInBytes(Padding));
}
PackedElements.push_back(C);
- ElementOffsetInBytes += getSizeInBytes(C);
+ ElementOffsetInChars += CharUnits::fromQuantity(getSizeInBytes(C));
}
- assert(CharUnits::fromQuantity(ElementOffsetInBytes) ==
- NextFieldOffsetInChars &&
+ assert(ElementOffsetInChars == NextFieldOffsetInChars &&
"Packing the struct changed its size!");
Elements = PackedElements;