mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 09:31:03 +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
|
#if IN_LLVM
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#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
|
#endif
|
||||||
|
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
|
@ -350,10 +343,6 @@ public:
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
/// This var is used by a naked function.
|
/// This var is used by a naked function.
|
||||||
bool nakedUse;
|
bool nakedUse;
|
||||||
|
|
||||||
// debug description
|
|
||||||
llvm::DIVariable debugVariable;
|
|
||||||
llvm::DISubprogram debugFunc;
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -720,10 +720,11 @@ void ldc::DIBuilder::EmitStopPoint(unsigned ln)
|
||||||
|
|
||||||
void ldc::DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd)
|
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;
|
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());
|
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");
|
Logger::println("D to dwarf local variable");
|
||||||
LOG_SCOPE;
|
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;
|
return;
|
||||||
|
|
||||||
// get type description
|
// get type description
|
||||||
|
@ -754,7 +756,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
tag = llvm::dwarf::DW_TAG_auto_variable;
|
tag = llvm::dwarf::DW_TAG_auto_variable;
|
||||||
|
|
||||||
if (addr.empty()) {
|
if (addr.empty()) {
|
||||||
vd->debugVariable = DBuilder.createLocalVariable(
|
irVar->debugVariable = DBuilder.createLocalVariable(
|
||||||
tag, // tag
|
tag, // tag
|
||||||
GetCurrentScope(), // scope
|
GetCurrentScope(), // scope
|
||||||
vd->toChars(), // name
|
vd->toChars(), // name
|
||||||
|
@ -764,7 +766,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
true // preserve
|
true // preserve
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
vd->debugVariable = DBuilder.createComplexVariable(
|
irVar->debugVariable = DBuilder.createComplexVariable(
|
||||||
tag, // tag
|
tag, // tag
|
||||||
GetCurrentScope(), // scope
|
GetCurrentScope(), // scope
|
||||||
vd->toChars(), // name
|
vd->toChars(), // name
|
||||||
|
@ -774,10 +776,10 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
addr
|
addr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
vd->debugFunc = IR->func()->diSubprogram;
|
irVar->debugFunc = IR->func()->diSubprogram;
|
||||||
|
|
||||||
// declare
|
// declare
|
||||||
Declare(ll, vd->debugVariable);
|
Declare(ll, irVar->debugVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd)
|
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());
|
addr = DtoAlloca(var->type, var->toChars());
|
||||||
// add debug info
|
// add debug info
|
||||||
|
if (!irLocal)
|
||||||
|
irLocal = getIrLocal(var, true);
|
||||||
gIR->DBuilder.EmitLocalVariable(addr, var);
|
gIR->DBuilder.EmitLocalVariable(addr, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1224,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if this already has storage, it must've been handled already
|
// if this already has storage, it must've been handled already
|
||||||
if (irLocal && irLocal->value) {
|
if (irLocal->value) {
|
||||||
if (addr && addr != irLocal->value) {
|
if (addr && addr != irLocal->value) {
|
||||||
// This can happen, for example, in scope(exit) blocks which
|
// This can happen, for example, in scope(exit) blocks which
|
||||||
// are translated to IR multiple times.
|
// are translated to IR multiple times.
|
||||||
|
@ -1240,8 +1242,6 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(addr);
|
assert(addr);
|
||||||
if (!irLocal)
|
|
||||||
irLocal = getIrLocal(var, true);
|
|
||||||
irLocal->value = addr;
|
irLocal->value = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
ir/irvar.h
12
ir/irvar.h
|
@ -21,6 +21,14 @@
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#endif
|
#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;
|
struct IrFuncTyArg;
|
||||||
class VarDeclaration;
|
class VarDeclaration;
|
||||||
|
|
||||||
|
@ -33,6 +41,10 @@ struct IrVar
|
||||||
|
|
||||||
VarDeclaration* V;
|
VarDeclaration* V;
|
||||||
llvm::Value* value;
|
llvm::Value* value;
|
||||||
|
|
||||||
|
// debug description
|
||||||
|
llvm::DIVariable debugVariable;
|
||||||
|
llvm::DISubprogram debugFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// represents a global variable
|
// represents a global variable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue