aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-09 02:51:03 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-09 02:51:03 +0000
commit9ad5513b0f9d3999705659fb1aeb0e6c53455f43 (patch)
tree99f07d766725dcb18a205560930b8b274d3c81f5 /lib/CodeGen/CGDecl.cpp
parent3dab34a7cb5e2ad9c2311fc44b3d3b7ebb540992 (diff)
Make BuildByRefType take a ValueDecl instead of a QualType and an alignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81315 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 05823cf03f..2b8348eece 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -213,8 +213,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
/// } x
///
/// Align is the alignment needed in bytes for x.
-const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty,
- uint64_t Align) {
+const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) {
+ QualType Ty = D->getType();
+ uint64_t Align = getContext().getDeclAlignInBytes(D);
+
const llvm::Type *LTy = ConvertType(Ty);
bool needsCopyDispose = BlockRequiresCopying(Ty);
std::vector<const llvm::Type *> Types(needsCopyDispose*2+5);
@@ -251,7 +253,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
const llvm::Type *LTy = ConvertTypeForMem(Ty);
Align = getContext().getDeclAlignInBytes(&D);
if (isByRef)
- LTy = BuildByRefType(Ty, Align);
+ LTy = BuildByRefType(&D);
llvm::AllocaInst *Alloc = CreateTempAlloca(LTy);
Alloc->setName(D.getNameAsString().c_str());
@@ -326,6 +328,12 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
if (Target.useGlobalsForAutomaticVariables()) {
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(DeclPtr), &D);
} else if (isByRef) {
+ // FIXME: This code is broken and will not emit debug info for the
+ // variable. The right way to do this would be to tell LLVM that this is a
+ // byref pointer, and what the offset is. Unfortunately, right now it's
+ // not possible unless we create a DIType that corresponds to the byref
+ // struct.
+ /*
llvm::Value *Loc;
bool needsCopyDispose = BlockRequiresCopying(Ty);
Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding");
@@ -333,6 +341,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
Loc = Builder.CreateBitCast(Loc, DeclPtr->getType());
Loc = Builder.CreateStructGEP(Loc, needsCopyDispose*2+4, "x");
DI->EmitDeclareOfAutoVariable(&D, Loc, Builder);
+ */
} else
DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder);
}