diff options
author | Ken Dyck <ken.dyck@onsemi.com> | 2010-01-26 19:13:33 +0000 |
---|---|---|
committer | Ken Dyck <ken.dyck@onsemi.com> | 2010-01-26 19:13:33 +0000 |
commit | 5262b11962024627b704447b6ae27adeddef6019 (patch) | |
tree | c1a7aa668f32abaeb778bb317e0f8474e03c2fb8 /clang | |
parent | 8703c412f43e59c4d01174d913c3b778f152e9ec (diff) | |
download | bcm5719-llvm-5262b11962024627b704447b6ae27adeddef6019.tar.gz bcm5719-llvm-5262b11962024627b704447b6ae27adeddef6019.zip |
Use CharUnits for alignments in character units.
llvm-svn: 94571
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 24 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.h | 5 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 2 |
3 files changed, 17 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 15347a488fa..2c32c42ce23 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -176,7 +176,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { // block literal. // __invoke CharUnits subBlockSize; - uint64_t subBlockAlign; + CharUnits subBlockAlign; llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls; bool subBlockHasCopyDispose = false; llvm::Function *Fn @@ -249,7 +249,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { llvm::StructType *Ty = llvm::StructType::get(VMContext, Types, true); llvm::AllocaInst *A = CreateTempAlloca(Ty); - A->setAlignment(subBlockAlign); + A->setAlignment(subBlockAlign.getQuantity()); V = A; std::vector<HelperInfo> NoteForHelper(subBlockDeclRefDecls.size()); @@ -615,7 +615,7 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) { CodeGenFunction::BlockInfo Info(0, n); CharUnits subBlockSize; - uint64_t subBlockAlign; + CharUnits subBlockAlign; llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls; bool subBlockHasCopyDispose = false; llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap; @@ -678,7 +678,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, const Decl *OuterFuncDecl, llvm::DenseMap<const Decl*, llvm::Value*> ldm, CharUnits &Size, - uint64_t &Align, + CharUnits &Align, llvm::SmallVector<const Expr *, 8> &subBlockDeclRefDecls, bool &subBlockHasCopyDispose) { @@ -700,7 +700,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, BlockOffset = CGM.GetTargetTypeStoreSize(CGM.getGenericBlockLiteralType()); - BlockAlign = getContext().getTypeAlign(getContext().VoidPtrTy) / 8; + BlockAlign = getContext().getTypeAlignInChars(getContext().VoidPtrTy); const FunctionType *BlockFunctionType = BExpr->getFunctionType(); QualType ResultType; @@ -796,9 +796,10 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, FinishFunction(cast<CompoundStmt>(BExpr->getBody())->getRBracLoc()); // The runtime needs a minimum alignment of a void *. - uint64_t MinAlign = getContext().getTypeAlign(getContext().VoidPtrTy) / 8; + CharUnits MinAlign = getContext().getTypeAlignInChars(getContext().VoidPtrTy); BlockOffset = CharUnits::fromQuantity( - llvm::RoundUpToAlignment(BlockOffset.getQuantity(), MinAlign)); + llvm::RoundUpToAlignment(BlockOffset.getQuantity(), + MinAlign.getQuantity())); Size = BlockOffset; Align = BlockAlign; @@ -811,20 +812,21 @@ CharUnits BlockFunction::getBlockOffset(const BlockDeclRefExpr *BDRE) { const ValueDecl *D = dyn_cast<ValueDecl>(BDRE->getDecl()); CharUnits Size = getContext().getTypeSizeInChars(D->getType()); - uint64_t Align = getContext().getDeclAlignInBytes(D); + CharUnits Align = + CharUnits::fromQuantity(getContext().getDeclAlignInBytes(D)); if (BDRE->isByRef()) { Size = getContext().getTypeSizeInChars(getContext().VoidPtrTy); - Align = getContext().getTypeAlign(getContext().VoidPtrTy) / 8; + Align = getContext().getTypeAlignInChars(getContext().VoidPtrTy); } - assert ((Align > 0) && "alignment must be 1 byte or more"); + assert ((Align.isPositive()) && "alignment must be 1 byte or more"); CharUnits OldOffset = BlockOffset; // Ensure proper alignment, even if it means we have to have a gap BlockOffset = CharUnits::fromQuantity( - llvm::RoundUpToAlignment(BlockOffset.getQuantity(), Align)); + llvm::RoundUpToAlignment(BlockOffset.getQuantity(), Align.getQuantity())); BlockAlign = std::max(Align, BlockAlign); CharUnits Pad = BlockOffset - OldOffset; diff --git a/clang/lib/CodeGen/CGBlocks.h b/clang/lib/CodeGen/CGBlocks.h index f42244c52e0..a9f5ae05c10 100644 --- a/clang/lib/CodeGen/CGBlocks.h +++ b/clang/lib/CodeGen/CGBlocks.h @@ -177,8 +177,9 @@ public: /// BlockOffset - The offset in bytes for the next allocation of an /// imported block variable. CharUnits BlockOffset; - /// BlockAlign - Maximal alignment needed for the Block expressed in bytes. - uint64_t BlockAlign; + /// BlockAlign - Maximal alignment needed for the Block expressed in + /// characters. + CharUnits BlockAlign; /// getBlockOffset - Allocate an offset for the ValueDecl from a /// BlockDeclRefExpr in a block literal (BlockExpr). diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 684d1ce2859..f1b213dc447 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -475,7 +475,7 @@ public: const BlockInfo& Info, const Decl *OuterFuncDecl, llvm::DenseMap<const Decl*, llvm::Value*> ldm, - CharUnits &Size, uint64_t &Align, + CharUnits &Size, CharUnits &Align, llvm::SmallVector<const Expr *, 8> &subBlockDeclRefDecls, bool &subBlockHasCopyDispose); |