forked from OSchip/llvm-project
Cleanp code with some recent suggestions.
llvm-svn: 65285
This commit is contained in:
parent
c2b5017a72
commit
624497c29a
|
@ -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 =
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -28,13 +28,13 @@ _Complex double g1x = 1.0f;
|
|||
_Complex double g1y = 1.0fi;
|
||||
// RUN: grep '@g1 = global { i8, i8 } { i8 1, i8 10 }' %t &&
|
||||
_Complex char g1 = (char) 1 + (char) 10 * 1i;
|
||||
// RUN: grep '@g2 = global { i32, i32 } { i32 1, i32 10 }' %t &&
|
||||
// RUN: grep '@g2 = global .struct.__block_descriptor { i32 1, i32 10 }' %t &&
|
||||
_Complex int g2 = 1 + 10i;
|
||||
// RUN: grep '@g3 = global { float, float } { float 1.000000e+00, float 1.000000e+01 }' %t &&
|
||||
_Complex float g3 = 1.0 + 10.0i;
|
||||
// RUN: grep '@g4 = global { double, double } { double 1.000000e+00, double 1.000000e+01 }' %t &&
|
||||
_Complex double g4 = 1.0 + 10.0i;
|
||||
// RUN: grep '@g5 = global { i32, i32 } zeroinitializer' %t &&
|
||||
// RUN: grep '@g5 = global .struct.__block_descriptor zeroinitializer' %t &&
|
||||
_Complex int g5 = (2 + 3i) == (5 + 7i);
|
||||
// RUN: grep '@g6 = global { double, double } { double -1.100000e+01, double 2.900000e+01 }' %t &&
|
||||
_Complex double g6 = (2.0 + 3.0i) * (5.0 + 7.0i);
|
||||
|
|
Loading…
Reference in New Issue