[cfe-commits] r129998 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Ken Dyck
kd at kendyck.com
Fri Apr 22 10:34:18 PDT 2011
Author: kjdyck
Date: Fri Apr 22 12:34:18 2011
New Revision: 129998
URL: http://llvm.org/viewvc/llvm-project?rev=129998&view=rev
Log:
Use CharUnits to eliminate some literal 8s in
EmitTypeForVarWithBlocksAttr(). No change in functionality intended.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=129998&r1=129997&r2=129998&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 22 12:34:18 2011
@@ -1797,15 +1797,17 @@
}
CharUnits Align = CGM.getContext().getDeclAlign(VD);
- if (Align > CharUnits::fromQuantity(
- CGM.getContext().Target.getPointerAlign(0) / 8)) {
- unsigned AlignedOffsetInBytes
- = llvm::RoundUpToAlignment(FieldOffset/8, Align.getQuantity());
- unsigned NumPaddingBytes
- = AlignedOffsetInBytes - FieldOffset/8;
+ if (Align > CGM.getContext().toCharUnitsFromBits(
+ CGM.getContext().Target.getPointerAlign(0))) {
+ CharUnits FieldOffsetInBytes
+ = CGM.getContext().toCharUnitsFromBits(FieldOffset);
+ CharUnits AlignedOffsetInBytes
+ = FieldOffsetInBytes.RoundUpToAlignment(Align);
+ CharUnits NumPaddingBytes
+ = AlignedOffsetInBytes - FieldOffsetInBytes;
- if (NumPaddingBytes > 0) {
- llvm::APInt pad(32, NumPaddingBytes);
+ if (NumPaddingBytes.isPositive()) {
+ llvm::APInt pad(32, NumPaddingBytes.getQuantity());
FType = CGM.getContext().getConstantArrayType(CGM.getContext().CharTy,
pad, ArrayType::Normal, 0);
EltTys.push_back(CreateMemberType(Unit, FType, "", &FieldOffset));
@@ -1815,7 +1817,7 @@
FType = Type;
llvm::DIType FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
FieldSize = CGM.getContext().getTypeSize(FType);
- FieldAlign = Align.getQuantity()*8;
+ FieldAlign = CGM.getContext().toBits(Align);
*XOffset = FieldOffset;
FieldTy = DBuilder.createMemberType(VD->getName(), Unit,
More information about the cfe-commits
mailing list