diff options
author | Mike Stump <mrs@apple.com> | 2009-02-22 13:27:11 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-22 13:27:11 +0000 |
commit | 20733cd4fd5c9755cdfab583db862223c93732c8 (patch) | |
tree | 0f348797e578bd16dd2b0f861b9c01595bec63a7 /lib/CodeGen/CodeGenFunction.h | |
parent | 2217c87bdc5ab357046a5453bdb06f469c41024e (diff) |
Cleanp code with some recent suggestions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 2de696d664..cffa7fa5ec 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -286,15 +286,20 @@ public: assert (((Align & 7) == 0) && "alignment must be on at least byte boundaries"); // Ensure proper alignment, even if it means we have to have a gap - if (BlockOffset % (Align >> 3)) { - BlockOffset += (Align >> 3) - (BlockOffset % (Align >> 3)); - assert ((BlockOffset % (Align >> 3)) == 0 - && "alignment calculation is wrong"); - } + BlockOffset = llvm::RoundUpToAlignment(BlockOffset, Align/8); BlockOffset += Size; return BlockOffset-Size; } + uint64_t getBlockOffset(ValueDecl *D) { + uint64_t Size = getContext().getTypeSize(D->getType()) / 8; + + unsigned Align = getContext().getTypeAlign(D->getType()); + if (const AlignedAttr* AA = D->getAttr<AlignedAttr>()) + Align = std::max(Align, AA->getAlignment()); + + return getBlockOffset(Size, Align); + } std::map<Decl*, uint64_t> BlockDecls; void GenerateCode(const FunctionDecl *FD, |