From: Mike Stump Date: Fri, 15 May 2009 00:29:54 +0000 (+0000) Subject: Fixup debug information for the location information for __block X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd0e628aa8a1e3932445559cb1d950fee11ea9a9;p=clang Fixup debug information for the location information for __block variables. For this to work, the backend needs to handle more complex forms for locations. A typical utterance would be: %forwarding = getelementptr %0* %use_by_ref, i32 0, i32 1 ; [#uses=1] %0 = load i8** %forwarding ; [#uses=1] %1 = bitcast i8* %0 to %0* ; <%0*> [#uses=1] %x = getelementptr %0* %1, i32 0, i32 4 ; [#uses=1] %2 = bitcast i32* %x to { }* ; <{ }*> [#uses=1] call void @llvm.dbg.declare({ }* %2, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable to { }*)) Presently when selection finds something it doesn't understand, it just avoids generating any information, which is safe, just incomplete. Radar 6867696 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71824 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index b6efcffdfc..9de722e19d 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -315,8 +315,10 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { if (isByRef) { llvm::Value *Loc; bool needsCopyDispose = BlockRequiresCopying(Ty); - // FIXME: I think we need to indirect through the forwarding pointer first - Loc = Builder.CreateStructGEP(DeclPtr, needsCopyDispose*2+4, "x"); + Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding"); + Loc = Builder.CreateLoad(Loc, false); + 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);