mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 02:45:25 +03:00
Move debugVariable and debugFunc from VarDeclaration to IrVar
This commit is contained in:
parent
caa2f15c8a
commit
9ead7f7996
4 changed files with 24 additions and 21 deletions
|
@ -19,13 +19,6 @@
|
|||
#if IN_LLVM
|
||||
#include <set>
|
||||
#include <string>
|
||||
#if LDC_LLVM_VER >= 305
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#elif LDC_LLVM_VER >= 302
|
||||
#include "llvm/DebugInfo.h"
|
||||
#else
|
||||
#include "llvm/Analysis/DebugInfo.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "dsymbol.h"
|
||||
|
@ -350,10 +343,6 @@ public:
|
|||
#if IN_LLVM
|
||||
/// This var is used by a naked function.
|
||||
bool nakedUse;
|
||||
|
||||
// debug description
|
||||
llvm::DIVariable debugVariable;
|
||||
llvm::DISubprogram debugFunc;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -720,10 +720,11 @@ void ldc::DIBuilder::EmitStopPoint(unsigned ln)
|
|||
|
||||
void ldc::DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd)
|
||||
{
|
||||
if (!global.params.symdebug || !vd->debugVariable)
|
||||
llvm::DIVariable debugVariable = getIrVar(vd)->debugVariable;
|
||||
if (!global.params.symdebug || !debugVariable)
|
||||
return;
|
||||
|
||||
llvm::Instruction *instr = DBuilder.insertDbgValueIntrinsic(val, 0, vd->debugVariable, IR->scopebb());
|
||||
llvm::Instruction *instr = DBuilder.insertDbgValueIntrinsic(val, 0, debugVariable, IR->scopebb());
|
||||
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
||||
}
|
||||
|
||||
|
@ -736,7 +737,8 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
Logger::println("D to dwarf local variable");
|
||||
LOG_SCOPE;
|
||||
|
||||
if (IR->func()->diSubprogram == vd->debugFunc) // ensure that the debug variable is created only once
|
||||
IrVar *irVar = getIrVar(vd);
|
||||
if (IR->func()->diSubprogram == irVar->debugFunc) // ensure that the debug variable is created only once
|
||||
return;
|
||||
|
||||
// get type description
|
||||
|
@ -754,7 +756,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
tag = llvm::dwarf::DW_TAG_auto_variable;
|
||||
|
||||
if (addr.empty()) {
|
||||
vd->debugVariable = DBuilder.createLocalVariable(
|
||||
irVar->debugVariable = DBuilder.createLocalVariable(
|
||||
tag, // tag
|
||||
GetCurrentScope(), // scope
|
||||
vd->toChars(), // name
|
||||
|
@ -764,7 +766,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
true // preserve
|
||||
);
|
||||
} else {
|
||||
vd->debugVariable = DBuilder.createComplexVariable(
|
||||
irVar->debugVariable = DBuilder.createComplexVariable(
|
||||
tag, // tag
|
||||
GetCurrentScope(), // scope
|
||||
vd->toChars(), // name
|
||||
|
@ -774,10 +776,10 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
addr
|
||||
);
|
||||
}
|
||||
vd->debugFunc = IR->func()->diSubprogram;
|
||||
irVar->debugFunc = IR->func()->diSubprogram;
|
||||
|
||||
// declare
|
||||
Declare(ll, vd->debugVariable);
|
||||
Declare(ll, irVar->debugVariable);
|
||||
}
|
||||
|
||||
llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd)
|
||||
|
|
|
@ -1202,6 +1202,8 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
|||
{
|
||||
addr = DtoAlloca(var->type, var->toChars());
|
||||
// add debug info
|
||||
if (!irLocal)
|
||||
irLocal = getIrLocal(var, true);
|
||||
gIR->DBuilder.EmitLocalVariable(addr, var);
|
||||
}
|
||||
|
||||
|
@ -1222,7 +1224,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
|||
else
|
||||
{
|
||||
// if this already has storage, it must've been handled already
|
||||
if (irLocal && irLocal->value) {
|
||||
if (irLocal->value) {
|
||||
if (addr && addr != irLocal->value) {
|
||||
// This can happen, for example, in scope(exit) blocks which
|
||||
// are translated to IR multiple times.
|
||||
|
@ -1240,8 +1242,6 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
|||
}
|
||||
|
||||
assert(addr);
|
||||
if (!irLocal)
|
||||
irLocal = getIrLocal(var, true);
|
||||
irLocal->value = addr;
|
||||
}
|
||||
|
||||
|
|
12
ir/irvar.h
12
ir/irvar.h
|
@ -21,6 +21,14 @@
|
|||
#include "llvm/Type.h"
|
||||
#endif
|
||||
|
||||
#if LDC_LLVM_VER >= 305
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#elif LDC_LLVM_VER >= 302
|
||||
#include "llvm/DebugInfo.h"
|
||||
#else
|
||||
#include "llvm/Analysis/DebugInfo.h"
|
||||
#endif
|
||||
|
||||
struct IrFuncTyArg;
|
||||
class VarDeclaration;
|
||||
|
||||
|
@ -33,6 +41,10 @@ struct IrVar
|
|||
|
||||
VarDeclaration* V;
|
||||
llvm::Value* value;
|
||||
|
||||
// debug description
|
||||
llvm::DIVariable debugVariable;
|
||||
llvm::DISubprogram debugFunc;
|
||||
};
|
||||
|
||||
// represents a global variable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue