From 53dedd765bfb12a771ca6b367cf1445fd8de62f9 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Thu, 12 Jun 2008 18:04:28 +0200 Subject: [PATCH] [svn r271] Fixed debug info for implicit 'this' param. Fixed debug info for arguments passed byval (ref and out params still missing). --- gen/functions.cpp | 21 ++++++++++++++++++++- llvmdc.kdevelop.filelist | 2 ++ tangotests/debug10.d | 21 +++++++++++++++++++++ tangotests/debug9.d | 18 ++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tangotests/debug10.d create mode 100644 tangotests/debug9.d diff --git a/gen/functions.cpp b/gen/functions.cpp index 442a5645..8a957546 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -587,6 +587,17 @@ void DtoDefineFunc(FuncDeclaration* fd) fd->vresult->ir.irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint); } + // give 'this' argument debug info (and storage) + if (f->llvmUsesThis && global.params.symdebug) + { + LLValue** thisvar = &fd->ir.irFunc->thisVar; + assert(*thisvar); + LLValue* thismem = new llvm::AllocaInst((*thisvar)->getType(), "newthis", allocaPoint); + DtoDwarfLocalVariable(thismem, fd->vthis); + gIR->ir->CreateStore(*thisvar, thismem); + *thisvar = thismem; + } + // give arguments storage if (fd->parameters) { @@ -597,8 +608,16 @@ void DtoDefineFunc(FuncDeclaration* fd) VarDeclaration* vd = argsym->isVarDeclaration(); assert(vd); - if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)) + // FIXME: llvm seems to want an alloca for debug info + if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut()) continue; + // debug info for normal aggr params seem to work fine + else if (DtoIsPassedByRef(vd->type)) + { + if (global.params.symdebug) + DtoDwarfLocalVariable(vd->ir.getIrValue(), vd); + continue; + } LLValue* a = vd->ir.irLocal->value; assert(a); diff --git a/llvmdc.kdevelop.filelist b/llvmdc.kdevelop.filelist index f8fab537..f4a273aa 100644 --- a/llvmdc.kdevelop.filelist +++ b/llvmdc.kdevelop.filelist @@ -765,6 +765,7 @@ tangotests/c.d tangotests/classes1.d tangotests/constructors.d tangotests/debug1.d +tangotests/debug10.d tangotests/debug2.d tangotests/debug3.d tangotests/debug4.d @@ -772,6 +773,7 @@ tangotests/debug5.d tangotests/debug6.d tangotests/debug7.d tangotests/debug8.d +tangotests/debug9.d tangotests/e.d tangotests/f.d tangotests/files1.d diff --git a/tangotests/debug10.d b/tangotests/debug10.d new file mode 100644 index 00000000..01778206 --- /dev/null +++ b/tangotests/debug10.d @@ -0,0 +1,21 @@ +module tangotests.debug10; + +struct Vec2 +{ + float x,y; +} + +void main() +{ + Vec2 v2; + char[] str = "hello"; + int i = void; + float f = 3.14; + func(v2, v2, str, i, f); +} + +void func(Vec2 v2, ref Vec2 rv2, char[] str, out int i, ref float f) +{ + int* fail; + *fail = 0; +} diff --git a/tangotests/debug9.d b/tangotests/debug9.d new file mode 100644 index 00000000..dfe9b526 --- /dev/null +++ b/tangotests/debug9.d @@ -0,0 +1,18 @@ +module tangotests.debug9; + +struct Foo +{ + int a,b,c; + + void func() + { + int* fail; + *fail = 0; + } +} + +void main() +{ + Foo foo = Foo(1,10,73); + foo.func(); +}