\o/ awesome! (I added that "indirect" hack ages ago, unfortunately - one consolation is that it was worse before: Clang would describe the parameter's type as "T&" in the DWARF, instead of as "T"... )
On Mon, Apr 17, 2017 at 6:34 PM Adrian Prantl via cfe-commits < [email protected]> wrote: > Author: adrian > Date: Mon Apr 17 20:22:01 2017 > New Revision: 300523 > > URL: http://llvm.org/viewvc/llvm-project?rev=300523&view=rev > Log: > Debug Info: Remove special-casing of indirect function argument handling. > > LLVM has changed the semantics of dbg.declare for describing function > arguments. After this patch a dbg.declare always takes the *address* > of a variable as the first argument, even if the argument is not an > alloca. > > https://bugs.llvm.org/show_bug.cgi?id=32382 > rdar://problem/31205000 > > Modified: > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > cfe/trunk/test/CodeGen/debug-info-vla.c > cfe/trunk/test/CodeGenCXX/debug-info.cpp > cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl > > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=300523&r1=300522&r2=300523&view=diff > > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 17 20:22:01 2017 > @@ -3466,17 +3466,17 @@ void CGDebugInfo::EmitDeclare(const VarD > // functions there won't be an implicit param at arg1 and > // otherwise it is 'self' or 'this'. > if (isa<ImplicitParamDecl>(VD) && ArgNo && *ArgNo == 1) > - Flags |= llvm::DINode::FlagObjectPointer; > - if (auto *Arg = dyn_cast<llvm::Argument>(Storage)) > - if (Arg->getType()->isPointerTy() && !Arg->hasByValAttr() && > - !VD->getType()->isPointerType()) > - Expr.push_back(llvm::dwarf::DW_OP_deref); > + Flags |= llvm::DINode::FlagObjectPointer; > > + // Note: Older versions of clang used to emit byval references with an > extra > + // DW_OP_deref, because they referenced the IR arg directly instead of > + // referencing an alloca. Newer versions of LLVM don't treat allocas > + // differently from other function arguments when used in a dbg.declare. > auto *Scope = cast<llvm::DIScope>(LexicalBlockStack.back()); > - > StringRef Name = VD->getName(); > if (!Name.empty()) { > if (VD->hasAttr<BlocksAttr>()) { > + // Here, we need an offset *into* the alloca. > CharUnits offset = CharUnits::fromQuantity(32); > Expr.push_back(llvm::dwarf::DW_OP_plus); > // offset of __forwarding field > @@ -3488,22 +3488,7 @@ void CGDebugInfo::EmitDeclare(const VarD > // offset of x field > offset = CGM.getContext().toCharUnitsFromBits(XOffset); > Expr.push_back(offset.getQuantity()); > - > - // Create the descriptor for the variable. > - auto *D = ArgNo > - ? DBuilder.createParameterVariable(Scope, > VD->getName(), > - *ArgNo, Unit, > Line, Ty) > - : DBuilder.createAutoVariable(Scope, VD->getName(), > Unit, > - Line, Ty, Align); > - > - // Insert an llvm.dbg.declare into the current block. > - DBuilder.insertDeclare( > - Storage, D, DBuilder.createExpression(Expr), > - llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt), > - Builder.GetInsertBlock()); > - return; > - } else if (isa<VariableArrayType>(VD->getType())) > - Expr.push_back(llvm::dwarf::DW_OP_deref); > + } > } else if (const auto *RT = dyn_cast<RecordType>(VD->getType())) { > // If VD is an anonymous union then Storage represents value for > // all union fields. > @@ -3606,8 +3591,7 @@ void CGDebugInfo::EmitDeclareOfBlockDecl > ->getElementOffset(blockInfo.getCapture(VD).getIndex())); > > SmallVector<int64_t, 9> addr; > - if (isa<llvm::AllocaInst>(Storage)) > - addr.push_back(llvm::dwarf::DW_OP_deref); > + addr.push_back(llvm::dwarf::DW_OP_deref); > addr.push_back(llvm::dwarf::DW_OP_plus); > addr.push_back(offset.getQuantity()); > if (isByRef) { > @@ -3633,12 +3617,11 @@ void CGDebugInfo::EmitDeclareOfBlockDecl > // Insert an llvm.dbg.declare into the current block. > auto DL = > llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back(), > CurInlinedAt); > + auto *Expr = DBuilder.createExpression(addr); > if (InsertPoint) > - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), > DL, > - InsertPoint); > + DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint); > else > - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), > DL, > - Builder.GetInsertBlock()); > + DBuilder.insertDeclare(Storage, D, Expr, DL, > Builder.GetInsertBlock()); > } > > void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value > *AI, > > Modified: cfe/trunk/test/CodeGen/debug-info-vla.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-vla.c?rev=300523&r1=300522&r2=300523&view=diff > > ============================================================================== > --- cfe/trunk/test/CodeGen/debug-info-vla.c (original) > +++ cfe/trunk/test/CodeGen/debug-info-vla.c Mon Apr 17 20:22:01 2017 > @@ -4,8 +4,8 @@ void testVLAwithSize(int s) > { > // CHECK: dbg.declare > // CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata ![[EXPR:.*]]) > -// CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+2]] > -// CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref) > +// CHECK: ![[EXPR]] = !DIExpression() > +// CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+1]] > int vla[s]; > int i; > for (i = 0; i < s; i++) { > > Modified: cfe/trunk/test/CodeGenCXX/debug-info.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info.cpp?rev=300523&r1=300522&r2=300523&view=diff > > ============================================================================== > --- cfe/trunk/test/CodeGenCXX/debug-info.cpp (original) > +++ cfe/trunk/test/CodeGenCXX/debug-info.cpp Mon Apr 17 20:22:01 2017 > @@ -21,6 +21,7 @@ > > // CHECK: ![[INCTYPE]] = !DICompositeType(tag: DW_TAG_structure_type, > name: "incomplete" > // CHECK-SAME: DIFlagFwdDecl > +// CHECK: ![[EXPR]] = !DIExpression() > > template<typename T> struct Identity { > typedef T Type; > @@ -117,7 +118,6 @@ struct foo { > // For some reason function arguments ended up down here > // CHECK: ![[F]] = !DILocalVariable(name: "f", arg: 1, scope: ![[FUNC]] > // CHECK-SAME: type: ![[FOO]] > -// CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref) > foo func(foo f) { > return f; // reference 'f' for now because otherwise we hit another bug > } > > Modified: cfe/trunk/test/CodeGenOpenCL/ > amdgpu-debug-info-variable-expression.cl > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl?rev=300523&r1=300522&r2=300523&view=diff > > ============================================================================== > --- cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl > (original) > +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl > Mon Apr 17 20:22:01 2017 > @@ -1,6 +1,5 @@ > // RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target > amdgcn-amd-amdhsa -mcpu=fiji -o - %s | FileCheck %s > > -// CHECK-DAG: ![[NONE:[0-9]+]] = !DIExpression() > // CHECK-DAG: ![[LOCAL:[0-9]+]] = !DIExpression(DW_OP_constu, 2, > DW_OP_swap, DW_OP_xderef) > // CHECK-DAG: ![[PRIVATE:[0-9]+]] = !DIExpression(DW_OP_constu, 1, > DW_OP_swap, DW_OP_xderef) > > @@ -82,7 +81,7 @@ kernel void kernel1( > int *FuncVar4 = Tmp1; > > // CHECK-DAG: ![[FUNCVAR5:[0-9]+]] = !DILocalVariable(name: "FuncVar5", > scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) > - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** > {{.*}}, metadata ![[FUNCVAR5]], metadata ![[NONE]]), !dbg !{{[0-9]+}} > + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** > {{.*}}, metadata ![[FUNCVAR5]], metadata ![[NONE:[0-9]+]]), !dbg !{{[0-9]+}} > global int *constant FuncVar5 = KernelArg0; > // CHECK-DAG: ![[FUNCVAR6:[0-9]+]] = !DILocalVariable(name: "FuncVar6", > scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) > // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** > {{.*}}, metadata ![[FUNCVAR6]], metadata ![[NONE]]), !dbg !{{[0-9]+}} > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
