Restore additional GEP deref for llvm.dbg.declare for LLVM < 5

This commit is contained in:
Martin 2017-09-08 00:02:12 +02:00
parent 8cc5ff6e79
commit e4e7eaa0da
3 changed files with 16 additions and 5 deletions

View file

@ -146,6 +146,11 @@ DValue *DtoNestedVariable(Loc &loc, Type *astype, VarDeclaration *vd,
} }
if (!skipDIDeclaration && global.params.symdebug) { if (!skipDIDeclaration && global.params.symdebug) {
#if LDC_LLVM_VER < 500
// Because we are passing a GEP instead of an alloca to
// llvm.dbg.declare, we have to make the address dereference explicit.
gIR->DBuilder.OpDeref(dwarfAddrOps);
#endif
gIR->DBuilder.EmitLocalVariable(gep, vd, nullptr, false, gIR->DBuilder.EmitLocalVariable(gep, vd, nullptr, false,
/*forceAsLocal=*/true, false, dwarfAddrOps); /*forceAsLocal=*/true, false, dwarfAddrOps);
} }
@ -499,6 +504,11 @@ void DtoCreateNestedContext(FuncGenState &funcGen) {
} }
if (global.params.symdebug) { if (global.params.symdebug) {
#if LDC_LLVM_VER < 500
// Because we are passing a GEP instead of an alloca to
// llvm.dbg.declare, we have to make the address dereference explicit.
gIR->DBuilder.OpDeref(dwarfAddrOps);
#endif
gIR->DBuilder.EmitLocalVariable(gep, vd, nullptr, false, false, false, gIR->DBuilder.EmitLocalVariable(gep, vd, nullptr, false, false, false,
dwarfAddrOps); dwarfAddrOps);
} }

View file

@ -1,3 +1,4 @@
// REQUIRES: atleast_llvm500
// REQUIRES: Windows // REQUIRES: Windows
// REQUIRES: cdb // REQUIRES: cdb
// RUN: %ldc -g -of=%t.exe %s // RUN: %ldc -g -of=%t.exe %s
@ -12,7 +13,7 @@
void encloser(int arg0, ref int arg1) void encloser(int arg0, ref int arg1)
{ {
int enc_n = 123; int enc_n = 123;
// CDB: bp `nested_cdb.d:15` // CDB: bp `nested_cdb.d:16`
// CDB: g // CDB: g
// CDB: dv /t // CDB: dv /t
// CHECK: int arg0 = 0n1 // CHECK: int arg0 = 0n1
@ -26,7 +27,7 @@ void encloser(int arg0, ref int arg1)
void nested(int nes_i) void nested(int nes_i)
{ {
int blub = arg0 + arg1 + enc_n; int blub = arg0 + arg1 + enc_n;
// CDB: bp `nested_cdb.d:29` // CDB: bp `nested_cdb.d:30`
// CDB: g // CDB: g
// CDB: dv /t // CDB: dv /t
// CHECK: int arg0 = 0n1 // CHECK: int arg0 = 0n1
@ -35,7 +36,7 @@ void encloser(int arg0, ref int arg1)
// CDB: ?? *arg1 // CDB: ?? *arg1
// CHECK: int 0n2 // CHECK: int 0n2
arg0 = arg1 = enc_n = nes_i; arg0 = arg1 = enc_n = nes_i;
// CDB: bp `nested_cdb.d:38` // CDB: bp `nested_cdb.d:39`
// CDB: g // CDB: g
// CDB: dv /t // CDB: dv /t
// CHECK: int arg0 = 0n456 // CHECK: int arg0 = 0n456
@ -46,7 +47,7 @@ void encloser(int arg0, ref int arg1)
} }
nested(456); nested(456);
// CDB: bp `nested_cdb.d:49` // CDB: bp `nested_cdb.d:50`
// CDB: g // CDB: g
// CDB: dv /t // CDB: dv /t
// CHECK: int arg0 = 0n456 // CHECK: int arg0 = 0n456

View file

@ -43,7 +43,7 @@ void encloser(int arg0, ref int arg1)
// GDB: b 43 // GDB: b 43
// GDB: c // GDB: c
// GDB: p arg0 // GDB: p arg0
// CHECK: $10 = 456 // no-CHECK: $10 = 456 (`<optimized out>` for LLVM < 5.0)
// GDB: p arg1 // GDB: p arg1
// CHECK: $11 = (int &) @{{0x[0-9a-f]*}}: 456 // CHECK: $11 = (int &) @{{0x[0-9a-f]*}}: 456
// GDB: p enc_n // GDB: p enc_n