From 7167442d6e4f46c56007a671590ac6f999603412 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 25 Apr 2012 05:55:47 -1000 Subject: [PATCH] Debugging info: include parameter number for function params. --- ctx.cpp | 13 ++++++++++--- ctx.h | 2 +- func.cpp | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ctx.cpp b/ctx.cpp index 464b8831..95ef805d 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -1482,19 +1482,26 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) { void -FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) { +FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) { if (m->diBuilder == NULL) return; llvm::DIScope scope = diFunction; + llvm::DIType diType = sym->type->GetDIType(scope); + Assert(diType.Verify()); + int flags = 0; + llvm::DIVariable var = m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable, scope, sym->name, sym->pos.GetDIFile(), sym->pos.first_line, - sym->type->GetDIType(scope), - true /* preserve through opts */); + diType, + true /* preserve through opts */, + flags, + argNum+1); + Assert(var.Verify()); llvm::Instruction *declareInst = m->diBuilder->insertDeclare(sym->storagePtr, var, bblock); AddDebugPos(declareInst, &sym->pos, &scope); diff --git a/ctx.h b/ctx.h index bdb21ddc..e161e366 100644 --- a/ctx.h +++ b/ctx.h @@ -342,7 +342,7 @@ public: /** Emits debugging information for the function parameter represented by sym. */ - void EmitFunctionParameterDebugInfo(Symbol *sym); + void EmitFunctionParameterDebugInfo(Symbol *sym, int parameterNum); /** @} */ /** @name IR instruction emission diff --git a/func.cpp b/func.cpp index 29dd9ecf..9fd31c7d 100644 --- a/func.cpp +++ b/func.cpp @@ -182,7 +182,7 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const // memory llvm::Value *ptrval = ctx->LoadInst(ptr, sym->name.c_str()); ctx->StoreInst(ptrval, sym->storagePtr); - ctx->EmitFunctionParameterDebugInfo(sym); + ctx->EmitFunctionParameterDebugInfo(sym, i); } @@ -262,7 +262,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, // to store the its value there. sym->storagePtr = ctx->AllocaInst(argIter->getType(), sym->name.c_str()); ctx->StoreInst(argIter, sym->storagePtr); - ctx->EmitFunctionParameterDebugInfo(sym); + ctx->EmitFunctionParameterDebugInfo(sym, i); } // If the number of actual function arguments is equal to the