[pkg-d-commits] [ldc] 73/211: Adapt emission of debuginfos for parameters
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:36:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.1.0
in repository ldc.
commit 8be1e3e719c3c58efb42cb6892a3822d6c535c19
Author: Martin <noone at nowhere.com>
Date: Sat Oct 8 23:40:23 2016 +0200
Adapt emission of debuginfos for parameters
Emit all parameters (except for captured ones) as DI parameters.
---
gen/dibuilder.cpp | 15 ++++++++-------
gen/dibuilder.h | 10 +++++-----
gen/functions.cpp | 7 ++-----
gen/nested.cpp | 3 ++-
tests/debuginfo/args_cdb.d | 32 ++++++++++++++------------------
tests/debuginfo/nested_llvm306.d | 2 +-
tests/debuginfo/nested_llvm307.d | 2 +-
tests/debuginfo/strings_cdb.d | 5 +++--
8 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp
index c07ed1f..1f872e4 100644
--- a/gen/dibuilder.cpp
+++ b/gen/dibuilder.cpp
@@ -994,7 +994,7 @@ void ldc::DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd) {
void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
Type *type, bool isThisPtr,
- bool rewrittenToLocal,
+ bool forceAsLocal,
#if LDC_LLVM_VER >= 306
llvm::ArrayRef<int64_t> addr
#else
@@ -1013,17 +1013,18 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
return; // ensure that the debug variable is created only once
// get type description
- ldc::DIType TD = CreateTypeDescription(type ? type : vd->type, true);
+ if (!type)
+ type = vd->type;
+ ldc::DIType TD = CreateTypeDescription(type, true);
if (static_cast<llvm::MDNode *>(TD) == nullptr)
return; // unsupported
if (vd->storage_class & (STCref | STCout)) {
#if LDC_LLVM_VER >= 308
- auto vt = type ? type : vd->type;
- auto T = DtoType(vt);
+ auto T = DtoType(type);
TD = DBuilder.createReferenceType(llvm::dwarf::DW_TAG_reference_type, TD,
getTypeAllocSize(T) * 8, // size (bits)
- DtoAlignment(vt) * 8); // align (bits)
+ DtoAlignment(type) * 8); // align (bits)
#else
TD = DBuilder.createReferenceType(llvm::dwarf::DW_TAG_reference_type, TD);
#endif
@@ -1034,7 +1035,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
#if LDC_LLVM_VER < 308
unsigned tag;
- if (!rewrittenToLocal && vd->isParameter()) {
+ if (!forceAsLocal && vd->isParameter()) {
tag = llvm::dwarf::DW_TAG_arg_variable;
} else {
tag = llvm::dwarf::DW_TAG_auto_variable;
@@ -1077,7 +1078,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
Flags // flags
);
#else
- if (!rewrittenToLocal && vd->isParameter()) {
+ if (!forceAsLocal && vd->isParameter()) {
FuncDeclaration *fd = vd->parent->isFuncDeclaration();
assert(fd);
size_t argNo = 0;
diff --git a/gen/dibuilder.h b/gen/dibuilder.h
index 467372a..6bc4200 100644
--- a/gen/dibuilder.h
+++ b/gen/dibuilder.h
@@ -136,15 +136,15 @@ public:
/// \brief Emits all things necessary for making debug info for a local
/// variable vd.
- /// \param ll LLVM Value of the variable.
+ /// \param ll LL lvalue of the variable.
/// \param vd Variable declaration to emit debug info for.
- /// \param type Type of parameter if different from vd->type
- /// \param isThisPtr Parameter is hidden this pointer
- /// \param bool rewrittenToLocal Parameter is copied to local stack frame/closure
+ /// \param type Type of variable if different from vd->type
+ /// \param isThisPtr Variable is hidden this pointer
+ /// \param forceAsLocal Emit as local even if the variable is a parameter
/// \param addr An array of complex address operations.
void
EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd, Type *type = nullptr,
- bool isThisPtr = false, bool rewrittenToLocal = false,
+ bool isThisPtr = false, bool forceAsLocal = false,
#if LDC_LLVM_VER >= 306
llvm::ArrayRef<int64_t> addr = llvm::ArrayRef<int64_t>()
#else
diff --git a/gen/functions.cpp b/gen/functions.cpp
index 2a8db89..8565725 100644
--- a/gen/functions.cpp
+++ b/gen/functions.cpp
@@ -705,7 +705,6 @@ void defineParameters(IrFuncTy &irFty, VarDeclarations ¶meters) {
// E.g., for a lazy parameter of type T, vd->type is T (with lazy storage
// class) while irparam->arg->type is the delegate type.
Type *const paramType = (irparam ? irparam->arg->type : vd->type);
- bool rewrittenToLocal = false;
if (!irparam) {
// This is a parameter that is not passed on the LLVM level.
@@ -722,10 +721,8 @@ void defineParameters(IrFuncTy &irFty, VarDeclarations ¶meters) {
assert(irparam->value->getType() == DtoPtrToType(paramType));
} else {
// Let the ABI transform the parameter back to an lvalue.
- auto Lvalue =
+ irparam->value =
irFty.getParamLVal(paramType, llArgIdx, irparam->value);
- rewrittenToLocal = Lvalue != irparam->value;
- irparam->value = Lvalue;
}
irparam->value->setName(vd->ident->toChars());
@@ -734,7 +731,7 @@ void defineParameters(IrFuncTy &irFty, VarDeclarations ¶meters) {
}
if (global.params.symdebug)
- gIR->DBuilder.EmitLocalVariable(irparam->value, vd, paramType, false, rewrittenToLocal);
+ gIR->DBuilder.EmitLocalVariable(irparam->value, vd, paramType);
}
}
diff --git a/gen/nested.cpp b/gen/nested.cpp
index ab798a6..8d66844 100644
--- a/gen/nested.cpp
+++ b/gen/nested.cpp
@@ -155,7 +155,8 @@ DValue *DtoNestedVariable(Loc &loc, Type *astype, VarDeclaration *vd,
}
if (dwarfValue && global.params.symdebug) {
- gIR->DBuilder.EmitLocalVariable(dwarfValue, vd, nullptr, false, /*fromNested=*/ true, dwarfAddr);
+ gIR->DBuilder.EmitLocalVariable(dwarfValue, vd, nullptr, false, true,
+ dwarfAddr);
}
return makeVarDValue(astype, vd, val);
diff --git a/tests/debuginfo/args_cdb.d b/tests/debuginfo/args_cdb.d
index f01adb0..55cdffc 100644
--- a/tests/debuginfo/args_cdb.d
+++ b/tests/debuginfo/args_cdb.d
@@ -28,16 +28,6 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// CHECK: !args_cdb.byValue
// CDB: dv /t
-// arguments not converted to locals come first:
-// x64: cdouble * c
-// x64: int delegate() * dg
-// "Internal implementation error for fa" with cdb on x64, ok in VS
-// x64: Interface * ifc
-
-// x86: unsigned char [16] fa
-// x86: Interface ifc
-
-// locals:
// CHECK: unsigned char ub = 0x01
// CHECK: unsigned short us = 2
// CHECK: unsigned int ui = 3
@@ -45,15 +35,22 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// CHECK: float f = 5
// CHECK: double d = 6
// CHECK: double r = 7
+// x64: cdouble * c =
// x86: cdouble c =
+// x64: int delegate() * dg =
// x86: int delegate() dg =
// CHECK: <function> * fun = {{0x[0-9a-f`]*}}
-// CHECK: struct int[] slice =
+// x64: struct int[] * slice =
+// x86: struct int[] slice =
// CHECK: unsigned char * aa = {{0x[0-9a-f`]*}}
+// "Internal implementation error for fa" with cdb on x64, ok in VS
+// x86: unsigned char [16] fa
// CHECK: float [4] f4 = float [4]
// CHECK: double [4] d4 = double [4]
+// x64: Interface * ifc
+// x86: Interface ifc
// CHECK: struct TypeInfo_Class * ti = {{0x[0-9a-f`]*}}
-// noCHECK: <CLR type> np = <unknown base type 80000013>
+// CHECK: void * np = {{0x[0`]*}}
// check arguments with indirections
// CDB: ?? c
@@ -68,7 +65,7 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// CHECK-SAME: args_cdb.main.__lambda
// CDB: ?? fa[1]
-// "Internal implementation error for fa" on x64
+// "Internal implementation error for fa" with cdb on x64, ok in VS
// no-x86: unsigned char 0x0e (displays 0xf6)
// CDB: ?? ifc
@@ -90,7 +87,7 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
float4* f4, double4* d4,
Interface* ifc, TypeInfo_Class* ti, typeof(null)* np)
{
-// CDB: bp `args_cdb.d:94`
+// CDB: bp `args_cdb.d:91`
// CDB: g
return 3;
// CHECK: !args_cdb.byPtr
@@ -141,7 +138,7 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
// CHECK-NEXT: m_init : byte[]
// shows bad member values
// CDB: ?? *np
-// noCHECK: <CLR type> np = <unknown base type 80000013>
+// CHECK: void * {{0x[0`]*}}
}
int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
@@ -151,7 +148,7 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
ref float4 f4, ref double4 d4,
ref Interface ifc, ref TypeInfo_Class ti, ref typeof(null) np)
{
-// CDB: bp `args_cdb.d:206`
+// CDB: bp `args_cdb.d:203`
// CDB: g
// CHECK: !args_cdb.byRef
@@ -201,7 +198,7 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
// CHECK: struct TypeInfo_Class * {{0x[0-9a-f`]*}}
// CHECK-NEXT: m_init : byte[]
// CDB: ?? *np
-// noCHECK: <CLR type> <unknown base type 80000013>
+// CHECK: void * {{0x[0`]*}}
// needs access to references to actually generate debug info
ub++;
@@ -254,4 +251,3 @@ int main()
}
// CDB: q
// CHECK: quit
-
diff --git a/tests/debuginfo/nested_llvm306.d b/tests/debuginfo/nested_llvm306.d
index 2effe0e..f98ff9e 100644
--- a/tests/debuginfo/nested_llvm306.d
+++ b/tests/debuginfo/nested_llvm306.d
@@ -18,5 +18,5 @@ void encloser(int arg0, int arg1)
// CHECK: @_D{{.*}}8encloserFiiZv{{.*}}DW_TAG_subprogram
// CHECK: @_D{{.*}}8encloserFiiZ6nestedMFiZv{{.*}}DW_TAG_subprogram
-// CHECK: nes_i{{.*}}DW_TAG_auto_variable
+// CHECK: nes_i{{.*}}DW_TAG_arg_variable
// CHECK: arg1{{.*}}DW_TAG_auto_variable
diff --git a/tests/debuginfo/nested_llvm307.d b/tests/debuginfo/nested_llvm307.d
index e35c2e1..5c39898 100644
--- a/tests/debuginfo/nested_llvm307.d
+++ b/tests/debuginfo/nested_llvm307.d
@@ -19,5 +19,5 @@ void encloser(int arg0, int arg1)
// CHECK: !DISubprogram(name:{{.*}}"{{.*}}.encloser"
// CHECK-SAME: function: void {{.*}} @_D{{.*}}8encloserFiiZv
// CHECK-LABEL: !DISubprogram(name:{{.*}}"{{.*}}.encloser.nested"
-// CHECK: !DILocalVariable{{.*}}DW_TAG_auto_variable{{.*}}nes_i
+// CHECK: !DILocalVariable{{.*}}DW_TAG_arg_variable{{.*}}nes_i
// CHECK: !DILocalVariable{{.*}}DW_TAG_auto_variable{{.*}}arg1
diff --git a/tests/debuginfo/strings_cdb.d b/tests/debuginfo/strings_cdb.d
index 1c9c2a1..9558a88 100644
--- a/tests/debuginfo/strings_cdb.d
+++ b/tests/debuginfo/strings_cdb.d
@@ -43,7 +43,8 @@ int main(string[] args)
// CHECK: +[[OFF]] ptr {{ *}}: [[PTR]]
// CDB: dv /t
-// CHECK: string[] args
+// x64: string[] * args
+// x86: string[] args
// CHECK: string[] nargs
// CHECK: string ns
// CHECK: string ws
@@ -52,7 +53,7 @@ int main(string[] args)
// CDB: ?? ns
// CHECK: +0x000 length {{ *}}: 1
// CHECK: +[[OFF]] ptr {{ *}}: 0x{{[0-9a-f`]* *}} "a"
-// CDB: ?? args.ptr[0]
+// CDB: ?? nargs.ptr[0]
// CHECK: +0x000 length
// CHECK: +[[OFF]] ptr {{ *}}: 0x{{[0-9a-f`]* *".*exe.*"}}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list