[cfe-commits] r145741 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CGException.cpp CGExpr.cpp CGExprCXX.cpp CGStmt.cpp CGValue.h CodeGenFunction.h
Eli Friedman
eli.friedman at gmail.com
Fri Dec 2 18:13:41 PST 2011
Author: efriedma
Date: Fri Dec 2 20:13:40 2011
New Revision: 145741
URL: http://llvm.org/viewvc/llvm-project?rev=145741&view=rev
Log:
Switch the Alignment argument on AggValueSlot over to CharUnits, per John's review comment.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Dec 2 20:13:40 2011
@@ -397,8 +397,7 @@
CGF.GetAddressOfDirectBaseInCompleteClass(ThisPtr, ClassDecl,
BaseClassDecl,
isBaseVirtual);
- unsigned Alignment =
- CGF.getContext().getTypeAlignInChars(BaseType).getQuantity();
+ CharUnits Alignment = CGF.getContext().getTypeAlignInChars(BaseType);
AggValueSlot AggSlot =
AggValueSlot::forAddr(V, Alignment, Qualifiers(),
AggValueSlot::IsDestructed,
@@ -1345,7 +1344,7 @@
llvm::Value *ThisPtr = LoadCXXThis();
QualType Ty = getContext().getTagDeclType(Ctor->getParent());
- unsigned Alignment = getContext().getTypeAlignInChars(Ty).getQuantity();
+ CharUnits Alignment = getContext().getTypeAlignInChars(Ty);
AggValueSlot AggSlot =
AggValueSlot::forAddr(ThisPtr, Alignment, Qualifiers(),
AggValueSlot::IsDestructed,
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Dec 2 20:13:40 2011
@@ -1039,7 +1039,7 @@
CGF.EHStack.pushTerminate();
// Perform the copy construction.
- unsigned Alignment = CGF.getContext().getDeclAlign(&CatchParam).getQuantity();
+ CharUnits Alignment = CGF.getContext().getDeclAlign(&CatchParam);
CGF.EmitAggExpr(copyExpr,
AggValueSlot::forAddr(ParamAddr, Alignment, Qualifiers(),
AggValueSlot::IsNotDestructed,
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Dec 2 20:13:40 2011
@@ -139,8 +139,7 @@
if (E->getType()->isAnyComplexType()) {
EmitComplexExprIntoAddr(E, Location, Quals.hasVolatile());
} else if (hasAggregateLLVMType(E->getType())) {
- unsigned Alignment =
- getContext().getTypeAlignInChars(E->getType()).getQuantity();
+ CharUnits Alignment = getContext().getTypeAlignInChars(E->getType());
EmitAggExpr(E, AggValueSlot::forAddr(Location, Alignment, Quals,
AggValueSlot::IsDestructed_t(IsInit),
AggValueSlot::DoesNotNeedGCBarriers,
@@ -361,8 +360,7 @@
!E->getType()->isAnyComplexType()) {
ReferenceTemporary = CreateReferenceTemporary(CGF, E->getType(),
InitializedDecl);
- unsigned Alignment =
- CGF.getContext().getTypeAlignInChars(E->getType()).getQuantity();
+ CharUnits Alignment = CGF.getContext().getTypeAlignInChars(E->getType());
AggValueSlot::IsDestructed_t isDestructed
= AggValueSlot::IsDestructed_t(InitializedDecl != 0);
AggSlot = AggValueSlot::forAddr(ReferenceTemporary, Alignment,
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Dec 2 20:13:40 2011
@@ -750,10 +750,10 @@
const Expr *Init = E->getConstructorArg(0);
QualType AllocType = E->getAllocatedType();
- unsigned Alignment =
- CGF.getContext().getTypeAlignInChars(AllocType).getQuantity();
+ CharUnits Alignment = CGF.getContext().getTypeAlignInChars(AllocType);
if (!CGF.hasAggregateLLVMType(AllocType))
- CGF.EmitScalarInit(Init, 0, CGF.MakeAddrLValue(NewPtr, AllocType, Alignment),
+ CGF.EmitScalarInit(Init, 0, CGF.MakeAddrLValue(NewPtr, AllocType,
+ Alignment.getQuantity()),
false);
else if (AllocType->isAnyComplexType())
CGF.EmitComplexExprIntoAddr(Init, NewPtr,
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Dec 2 20:13:40 2011
@@ -772,8 +772,7 @@
} else if (RV->getType()->isAnyComplexType()) {
EmitComplexExprIntoAddr(RV, ReturnValue, false);
} else {
- unsigned Alignment =
- getContext().getTypeAlignInChars(RV->getType()).getQuantity();
+ CharUnits Alignment = getContext().getTypeAlignInChars(RV->getType());
EmitAggExpr(RV, AggValueSlot::forAddr(ReturnValue, Alignment, Qualifiers(),
AggValueSlot::IsDestructed,
AggValueSlot::DoesNotNeedGCBarriers,
Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Fri Dec 2 20:13:40 2011
@@ -16,6 +16,7 @@
#define CLANG_CODEGEN_CGVALUE_H
#include "clang/AST/ASTContext.h"
+#include "clang/AST/CharUnits.h"
#include "clang/AST/Type.h"
namespace llvm {
@@ -366,7 +367,7 @@
/// for calling destructors on this object
/// \param needsGC - true if the slot is potentially located
/// somewhere that ObjC GC calls should be emitted for
- static AggValueSlot forAddr(llvm::Value *addr, unsigned align,
+ static AggValueSlot forAddr(llvm::Value *addr, CharUnits align,
Qualifiers quals,
IsDestructed_t isDestructed,
NeedsGCBarriers_t needsGC,
@@ -374,7 +375,7 @@
IsZeroed_t isZeroed = IsNotZeroed) {
AggValueSlot AV;
AV.Addr = addr;
- AV.Alignment = align;
+ AV.Alignment = align.getQuantity();
AV.Quals = quals;
AV.DestructedFlag = isDestructed;
AV.ObjCGCFlag = needsGC;
@@ -387,8 +388,8 @@
NeedsGCBarriers_t needsGC,
IsAliased_t isAliased,
IsZeroed_t isZeroed = IsNotZeroed) {
- return forAddr(LV.getAddress(), LV.getAlignment(), LV.getQuals(),
- isDestructed, needsGC, isAliased, isZeroed);
+ return forAddr(LV.getAddress(), CharUnits::fromQuantity(LV.getAlignment()),
+ LV.getQuals(), isDestructed, needsGC, isAliased, isZeroed);
}
IsDestructed_t isExternallyDestructed() const {
@@ -420,8 +421,8 @@
return Addr == 0;
}
- unsigned getAlignment() const {
- return Alignment;
+ CharUnits getAlignment() const {
+ return CharUnits::fromQuantity(Alignment);
}
IsAliased_t isPotentiallyAliased() const {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=145741&r1=145740&r2=145741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Dec 2 20:13:40 2011
@@ -1574,7 +1574,7 @@
/// CreateAggTemp - Create a temporary memory object for the given
/// aggregate type.
AggValueSlot CreateAggTemp(QualType T, const Twine &Name = "tmp") {
- unsigned Alignment = getContext().getTypeAlignInChars(T).getQuantity();
+ CharUnits Alignment = getContext().getTypeAlignInChars(T);
return AggValueSlot::forAddr(CreateMemTemp(T, Name), Alignment,
T.getQualifiers(),
AggValueSlot::IsNotDestructed,
More information about the cfe-commits
mailing list