Skip to content

Commit

Permalink
Don't declare params passed via LLVM byval attribute as DI refs
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Sep 3, 2017
1 parent a89782c commit aa1562e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion gen/dibuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,9 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
// llvm.dbg.declare only works properly with local allocas.
// Represent variables with non-alloca LL storage as DI references, like `ref`
// and `out` parameters.
const bool storedInAlloca = llvm::dyn_cast<llvm::AllocaInst>(ll);
const bool storedInAlloca =
llvm::dyn_cast<llvm::AllocaInst>(ll) ||
(isaArgument(ll) && isaArgument(ll)->hasByValAttr());
bool useDbgValueIntrinsic = false;
if (!storedInAlloca || vd->isRef() || vd->isOut()) {
// With the exception of special-ref loop variables, the reference/pointer
Expand Down
15 changes: 8 additions & 7 deletions tests/debuginfo/args_cdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// CHECK: <function> * fun = {{0x[0-9a-f`]*}}
// x86: struct int[] slice =
// CHECK: unsigned char * aa = {{0x[0-9a-f`]*}}
// CHECK: unsigned char (*)[16] fa
// x64: unsigned char (*)[16] fa
// x86: unsigned char [16] fa
// x86: float [4] f4 = float [4]
// x86: double [4] d4 = double [4]
// x64: Small small
// x86: Small * small
// CHECK: Large * large
// CHECK: Small small
// x64: Large * large
// x86: Large large
// CHECK: struct TypeInfo_Class * ti = {{0x[0-9a-f`]*}}
// CHECK: void * np = {{0x[0`]*}}

Expand Down Expand Up @@ -80,7 +81,7 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,

// CDB: ?? (*fa)[1]
// x64: unsigned char 0x0e
// no-x86: unsigned char 0x0e (displays garbage)
// no-x86: would be fa[1], but displays garbage anyway

// CDB: ?? f4[1]
// CHECK: float 16
Expand Down Expand Up @@ -111,7 +112,7 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
Small* small, Large* large,
TypeInfo_Class* ti, typeof(null)* np)
{
// CDB: bp `args_cdb.d:114`
// CDB: bp `args_cdb.d:115`
// CDB: g
return 3;
// CHECK: !args_cdb.byPtr
Expand Down Expand Up @@ -176,7 +177,7 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
ref Small small, ref Large large,
ref TypeInfo_Class ti, ref typeof(null) np)
{
// CDB: bp `args_cdb.d:179`
// CDB: bp `args_cdb.d:180`
// CDB: g
// CHECK: !args_cdb.byRef

Expand Down

0 comments on commit aa1562e

Please sign in to comment.