Debugging info: include parameter number for function params.

This commit is contained in:
Matt Pharr
2012-04-25 05:55:47 -10:00
parent 8547101c4b
commit 7167442d6e
3 changed files with 13 additions and 6 deletions

13
ctx.cpp
View File

@@ -1482,19 +1482,26 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
void void
FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) { FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
if (m->diBuilder == NULL) if (m->diBuilder == NULL)
return; return;
llvm::DIScope scope = diFunction; llvm::DIScope scope = diFunction;
llvm::DIType diType = sym->type->GetDIType(scope);
Assert(diType.Verify());
int flags = 0;
llvm::DIVariable var = llvm::DIVariable var =
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable, m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
scope, scope,
sym->name, sym->name,
sym->pos.GetDIFile(), sym->pos.GetDIFile(),
sym->pos.first_line, sym->pos.first_line,
sym->type->GetDIType(scope), diType,
true /* preserve through opts */); true /* preserve through opts */,
flags,
argNum+1);
Assert(var.Verify());
llvm::Instruction *declareInst = llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock); m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
AddDebugPos(declareInst, &sym->pos, &scope); AddDebugPos(declareInst, &sym->pos, &scope);

2
ctx.h
View File

@@ -342,7 +342,7 @@ public:
/** Emits debugging information for the function parameter represented /** Emits debugging information for the function parameter represented
by sym. */ by sym. */
void EmitFunctionParameterDebugInfo(Symbol *sym); void EmitFunctionParameterDebugInfo(Symbol *sym, int parameterNum);
/** @} */ /** @} */
/** @name IR instruction emission /** @name IR instruction emission

View File

@@ -182,7 +182,7 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const
// memory // memory
llvm::Value *ptrval = ctx->LoadInst(ptr, sym->name.c_str()); llvm::Value *ptrval = ctx->LoadInst(ptr, sym->name.c_str());
ctx->StoreInst(ptrval, sym->storagePtr); 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. // to store the its value there.
sym->storagePtr = ctx->AllocaInst(argIter->getType(), sym->name.c_str()); sym->storagePtr = ctx->AllocaInst(argIter->getType(), sym->name.c_str());
ctx->StoreInst(argIter, sym->storagePtr); ctx->StoreInst(argIter, sym->storagePtr);
ctx->EmitFunctionParameterDebugInfo(sym); ctx->EmitFunctionParameterDebugInfo(sym, i);
} }
// If the number of actual function arguments is equal to the // If the number of actual function arguments is equal to the