summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-02-22 13:27:11 +0000
committerMike Stump <mrs@apple.com>2009-02-22 13:27:11 +0000
commit624497c29a4c2a81f31aac386f276cf14febfb13 (patch)
treed24d9a4e788723ee68b0a72095c98cacdf88ce61 /clang/lib
parentc2b5017a724994dca530afb5c2dc04e6dd76631d (diff)
downloadbcm5719-llvm-624497c29a4c2a81f31aac386f276cf14febfb13.tar.gz
bcm5719-llvm-624497c29a4c2a81f31aac386f276cf14febfb13.zip
Cleanp code with some recent suggestions.
llvm-svn: 65285
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp10
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h15
3 files changed, 12 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 60bf73f0b41..d368d20bcec 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -193,13 +193,8 @@ const llvm::Type *CodeGenModule::getBlockDescriptorType() {
UnsignedLongTy,
NULL);
- // FIXME: This breaks an unrelated testcase in the testsuite, we
- // _want_ llvm to not use structural equality, sometimes. What
- // should we do, modify the testcase and do this anyway, or...
-#if 0
getModule().addTypeName("struct.__block_descriptor",
BlockDescriptorType);
-#endif
return BlockDescriptorType;
}
@@ -232,7 +227,6 @@ CodeGenModule::getGenericBlockLiteralType() {
BlockDescPtrTy,
NULL);
- // FIXME: See struct.__block_descriptor
getModule().addTypeName("struct.__block_literal_generic",
GenericBlockLiteralType);
@@ -271,7 +265,6 @@ CodeGenModule::getGenericExtendedBlockLiteralType() {
Int8PtrTy,
NULL);
- // FIXME: See struct.__block_descriptor
getModule().addTypeName("struct.__block_literal_extended_generic",
GenericExtendedBlockLiteralType);
@@ -312,8 +305,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
// Get the function pointer from the literal.
llvm::Value *FuncPtr = Builder.CreateStructGEP(BlockLiteral, 3, "tmp");
- // FIXME: second argument should be false?
- llvm::Value *Func = Builder.CreateLoad(FuncPtr, FuncPtr, "tmp");
+ llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp");
// Cast the function pointer to the right type.
const llvm::Type *BlockFTy =
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 63aa4e0a20a..a271e76bf1a 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -616,14 +616,8 @@ Value *ScalarExprEmitter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
// See if we have already allocated an offset for this variable.
if (offset == 0) {
- int Size = CGF.CGM.getTargetData().getTypeStoreSizeInBits(Ty) / 8;
-
- unsigned Align = CGF.CGM.getContext().getTypeAlign(E->getDecl()->getType());
- if (const AlignedAttr* AA = E->getDecl()->getAttr<AlignedAttr>())
- Align = std::max(Align, AA->getAlignment());
-
// if not, allocate one now.
- offset = CGF.getBlockOffset(Size, Align);
+ offset = CGF.getBlockOffset(E->getDecl());
}
llvm::Value *BlockLiteral = CGF.LoadBlockStruct();
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 2de696d6647..cffa7fa5ec1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/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,
OpenPOWER on IntegriCloud