mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-10 04:45:56 +03:00
Merge branch 'master' into merge-2.067
Conflicts: gen/dibuilder.cpp gen/dibuilder.h
This commit is contained in:
commit
f029c9b9af
8 changed files with 188 additions and 169 deletions
|
@ -159,7 +159,7 @@ namespace
|
||||||
{
|
{
|
||||||
os << debugLoc.getLine() << ":" << debugLoc.getCol();
|
os << debugLoc.getLine() << ":" << debugLoc.getCol();
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
if (MDLocation *IDL = debugLoc.getInlinedAt())
|
if (DILocation *IDL = debugLoc.getInlinedAt())
|
||||||
{
|
{
|
||||||
os << "@";
|
os << "@";
|
||||||
printDebugLoc(IDL, os);
|
printDebugLoc(IDL, os);
|
||||||
|
@ -181,13 +181,13 @@ namespace
|
||||||
{
|
{
|
||||||
// Find the MDNode which corresponds to the DISubprogram data that described F.
|
// Find the MDNode which corresponds to the DISubprogram data that described F.
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
static MDSubprogram* FindSubprogram(const Function *F, DebugInfoFinder &Finder)
|
static DISubprogram* FindSubprogram(const Function *F, DebugInfoFinder &Finder)
|
||||||
#else
|
#else
|
||||||
static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder)
|
static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
for (MDSubprogram* Subprogram : Finder.subprograms())
|
for (DISubprogram* Subprogram : Finder.subprograms())
|
||||||
if (Subprogram->describes(F)) return Subprogram;
|
if (Subprogram->describes(F)) return Subprogram;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#elif LDC_LLVM_VER >= 305
|
#elif LDC_LLVM_VER >= 305
|
||||||
|
@ -214,7 +214,7 @@ namespace
|
||||||
Finder.processModule(const_cast<llvm::Module&>(*F->getParent()));
|
Finder.processModule(const_cast<llvm::Module&>(*F->getParent()));
|
||||||
#endif
|
#endif
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
if (MDSubprogram* N = FindSubprogram(F, Finder))
|
if (DISubprogram* N = FindSubprogram(F, Finder))
|
||||||
#else
|
#else
|
||||||
if (MDNode* N = FindSubprogram(F, Finder))
|
if (MDNode* N = FindSubprogram(F, Finder))
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,7 +275,11 @@ namespace
|
||||||
}
|
}
|
||||||
if (const DbgDeclareInst* DDI = dyn_cast<DbgDeclareInst>(instr))
|
if (const DbgDeclareInst* DDI = dyn_cast<DbgDeclareInst>(instr))
|
||||||
{
|
{
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
DILocalVariable* Var(DDI->getVariable());
|
||||||
|
#else
|
||||||
DIVariable Var(DDI->getVariable());
|
DIVariable Var(DDI->getVariable());
|
||||||
|
#endif
|
||||||
if (!padding)
|
if (!padding)
|
||||||
{
|
{
|
||||||
os.PadToColumn(50);
|
os.PadToColumn(50);
|
||||||
|
@ -289,7 +293,11 @@ namespace
|
||||||
}
|
}
|
||||||
else if (const DbgValueInst* DVI = dyn_cast<DbgValueInst>(instr))
|
else if (const DbgValueInst* DVI = dyn_cast<DbgValueInst>(instr))
|
||||||
{
|
{
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
DILocalVariable* Var(DVI->getVariable());
|
||||||
|
#else
|
||||||
DIVariable Var(DVI->getVariable());
|
DIVariable Var(DVI->getVariable());
|
||||||
|
#endif
|
||||||
if (!padding)
|
if (!padding)
|
||||||
{
|
{
|
||||||
os.PadToColumn(50);
|
os.PadToColumn(50);
|
||||||
|
|
|
@ -29,7 +29,7 @@ void emitCoverageLinecountInc(Loc &loc) {
|
||||||
LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(line) };
|
LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(line) };
|
||||||
LLValue* ptr = llvm::ConstantExpr::getGetElementPtr(
|
LLValue* ptr = llvm::ConstantExpr::getGetElementPtr(
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
LLType::getInt32Ty(gIR->context()),
|
LLArrayType::get(LLType::getInt32Ty(gIR->context()), gIR->dmodule->numlines),
|
||||||
#endif
|
#endif
|
||||||
gIR->dmodule->d_cover_data, idxs, true);
|
gIR->dmodule->d_cover_data, idxs, true);
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
#include "enum.h"
|
#include "enum.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
typedef llvm::DebugNode Access;
|
typedef llvm::DINode Access;
|
||||||
#else
|
#else
|
||||||
typedef llvm::DIDescriptor Access;
|
typedef llvm::DIDescriptor Access;
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,11 +61,7 @@ llvm::LLVMContext &ldc::DIBuilder::getContext()
|
||||||
return IR->context();
|
return IR->context();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
ldc::DIScope ldc::DIBuilder::GetCurrentScope()
|
||||||
llvm::MDScope* ldc::DIBuilder::GetCurrentScope()
|
|
||||||
#else
|
|
||||||
llvm::DIDescriptor ldc::DIBuilder::GetCurrentScope()
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
IrFunction *fn = IR->func();
|
IrFunction *fn = IR->func();
|
||||||
if (fn->diLexicalBlocks.empty())
|
if (fn->diLexicalBlocks.empty())
|
||||||
|
@ -77,9 +72,9 @@ llvm::DIDescriptor ldc::DIBuilder::GetCurrentScope()
|
||||||
return fn->diLexicalBlocks.top();
|
return fn->diLexicalBlocks.top();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ldc::DIBuilder::Declare(llvm::Value *var, llvm::DIVariable divar
|
void ldc::DIBuilder::Declare(llvm::Value *var, ldc::DILocalVariable divar
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
, llvm::DIExpression diexpr
|
, ldc::DIExpression diexpr
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +89,7 @@ void ldc::DIBuilder::Declare(llvm::Value *var, llvm::DIVariable divar
|
||||||
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIFile ldc::DIBuilder::CreateFile(Loc& loc)
|
ldc::DIFile ldc::DIBuilder::CreateFile(Loc& loc)
|
||||||
{
|
{
|
||||||
llvm::SmallString<128> path(loc.filename ? loc.filename : "");
|
llvm::SmallString<128> path(loc.filename ? loc.filename : "");
|
||||||
llvm::sys::fs::make_absolute(path);
|
llvm::sys::fs::make_absolute(path);
|
||||||
|
@ -105,7 +100,7 @@ llvm::DIFile ldc::DIBuilder::CreateFile(Loc& loc)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateBasicType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateBasicType(Type *type)
|
||||||
{
|
{
|
||||||
using namespace llvm::dwarf;
|
using namespace llvm::dwarf;
|
||||||
|
|
||||||
|
@ -166,7 +161,7 @@ llvm::DIType ldc::DIBuilder::CreateBasicType(Type *type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateEnumType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateEnumType(Type *type)
|
||||||
{
|
{
|
||||||
llvm::Type *T = DtoType(type);
|
llvm::Type *T = DtoType(type);
|
||||||
|
|
||||||
|
@ -194,10 +189,10 @@ llvm::DIType ldc::DIBuilder::CreateEnumType(Type *type)
|
||||||
|
|
||||||
llvm::StringRef Name = te->toChars();
|
llvm::StringRef Name = te->toChars();
|
||||||
unsigned LineNumber = te->sym->loc.linnum;
|
unsigned LineNumber = te->sym->loc.linnum;
|
||||||
llvm::DIFile File = CreateFile(te->sym->loc);
|
ldc::DIFile File(CreateFile(te->sym->loc));
|
||||||
|
|
||||||
return DBuilder.createEnumerationType(
|
return DBuilder.createEnumerationType(
|
||||||
llvm::DICompileUnit(GetCU()),
|
GetCU(),
|
||||||
Name,
|
Name,
|
||||||
File,
|
File,
|
||||||
LineNumber,
|
LineNumber,
|
||||||
|
@ -210,7 +205,7 @@ llvm::DIType ldc::DIBuilder::CreateEnumType(Type *type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreatePointerType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreatePointerType(Type *type)
|
||||||
{
|
{
|
||||||
llvm::Type *T = DtoType(type);
|
llvm::Type *T = DtoType(type);
|
||||||
Type *t = type->toBasetype();
|
Type *t = type->toBasetype();
|
||||||
|
@ -219,7 +214,7 @@ llvm::DIType ldc::DIBuilder::CreatePointerType(Type *type)
|
||||||
|
|
||||||
// find base type
|
// find base type
|
||||||
Type *nt = t->nextOf();
|
Type *nt = t->nextOf();
|
||||||
llvm::DIType basetype = CreateTypeDescription(nt, false);
|
ldc::DIType basetype(CreateTypeDescription(nt, false));
|
||||||
|
|
||||||
return DBuilder.createPointerType(
|
return DBuilder.createPointerType(
|
||||||
basetype,
|
basetype,
|
||||||
|
@ -229,7 +224,7 @@ llvm::DIType ldc::DIBuilder::CreatePointerType(Type *type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateVectorType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateVectorType(Type *type)
|
||||||
{
|
{
|
||||||
LLType* T = DtoType(type);
|
LLType* T = DtoType(type);
|
||||||
Type* t = type->toBasetype();
|
Type* t = type->toBasetype();
|
||||||
|
@ -246,7 +241,7 @@ llvm::DIType ldc::DIBuilder::CreateVectorType(Type *type)
|
||||||
{
|
{
|
||||||
DBuilder.getOrCreateSubrange(0, Dim)
|
DBuilder.getOrCreateSubrange(0, Dim)
|
||||||
};
|
};
|
||||||
llvm::DIType basetype = CreateTypeDescription(te, false);
|
ldc::DIType basetype(CreateTypeDescription(te, false));
|
||||||
|
|
||||||
return DBuilder.createVectorType(
|
return DBuilder.createVectorType(
|
||||||
getTypeBitSize(T), // size (bits)
|
getTypeBitSize(T), // size (bits)
|
||||||
|
@ -256,17 +251,17 @@ llvm::DIType ldc::DIBuilder::CreateVectorType(Type *type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
|
ldc::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
|
||||||
llvm::DIFile file,
|
ldc::DIFile file,
|
||||||
const char* c_name,
|
const char* c_name,
|
||||||
unsigned offset,
|
unsigned offset,
|
||||||
PROTKIND prot)
|
PROTKIND prot)
|
||||||
{
|
{
|
||||||
llvm::Type *T = DtoType(type);
|
llvm::Type *T = DtoType(type);
|
||||||
Type *t = type->toBasetype();
|
Type *t = type->toBasetype();
|
||||||
|
|
||||||
// find base type
|
// find base type
|
||||||
llvm::DIType basetype = CreateTypeDescription(t, true);
|
ldc::DIType basetype(CreateTypeDescription(t, true));
|
||||||
|
|
||||||
unsigned Flags = 0;
|
unsigned Flags = 0;
|
||||||
switch (prot) {
|
switch (prot) {
|
||||||
|
@ -286,7 +281,7 @@ llvm::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
|
||||||
}
|
}
|
||||||
|
|
||||||
return DBuilder.createMemberType(
|
return DBuilder.createMemberType(
|
||||||
llvm::DICompileUnit(GetCU()),
|
GetCU(),
|
||||||
c_name, // name
|
c_name, // name
|
||||||
file, // file
|
file, // file
|
||||||
linnum, // line number
|
linnum, // line number
|
||||||
|
@ -298,7 +293,7 @@ llvm::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ldc::DIBuilder::AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
void ldc::DIBuilder::AddBaseFields(ClassDeclaration *sd, ldc::DIFile file,
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
std::vector<llvm::Metadata*> &elems
|
std::vector<llvm::Metadata*> &elems
|
||||||
#else
|
#else
|
||||||
|
@ -322,7 +317,7 @@ void ldc::DIBuilder::AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
{
|
{
|
||||||
Type* t = type->toBasetype();
|
Type* t = type->toBasetype();
|
||||||
assert((t->ty == Tstruct || t->ty == Tclass) &&
|
assert((t->ty == Tstruct || t->ty == Tclass) &&
|
||||||
|
@ -368,10 +363,14 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
// defaults
|
// defaults
|
||||||
llvm::StringRef name = sd->toChars();
|
llvm::StringRef name = sd->toChars();
|
||||||
unsigned linnum = sd->loc.linnum;
|
unsigned linnum = sd->loc.linnum;
|
||||||
llvm::DICompileUnit CU(GetCU());
|
ldc::DICompileUnit CU(GetCU());
|
||||||
assert(CU && "Compilation unit missing or corrupted");
|
assert(CU && "Compilation unit missing or corrupted");
|
||||||
llvm::DIFile file = CreateFile(sd->loc);
|
ldc::DIFile file(CreateFile(sd->loc));
|
||||||
llvm::DIType derivedFrom;
|
#if LDC_LLVM_VER >= 307
|
||||||
|
ldc::DIType derivedFrom = nullptr;
|
||||||
|
#else
|
||||||
|
ldc::DIType derivedFrom;
|
||||||
|
#endif
|
||||||
|
|
||||||
// set diCompositeType to handle recursive types properly
|
// set diCompositeType to handle recursive types properly
|
||||||
unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type
|
unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type
|
||||||
|
@ -399,7 +398,11 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
{
|
{
|
||||||
VarDeclaration* vd = *I;
|
VarDeclaration* vd = *I;
|
||||||
|
<<<<<<< HEAD
|
||||||
llvm::DIType dt = CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(), vd->offset, vd->prot().kind);
|
llvm::DIType dt = CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(), vd->offset, vd->prot().kind);
|
||||||
|
=======
|
||||||
|
ldc::DIType dt = CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(), vd->offset, vd->prot());
|
||||||
|
>>>>>>> master
|
||||||
elems.push_back(dt);
|
elems.push_back(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,12 +416,12 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::DebugNodeArray elemsArray = DBuilder.getOrCreateArray(elems);
|
llvm::DINodeArray elemsArray = DBuilder.getOrCreateArray(elems);
|
||||||
#else
|
#else
|
||||||
llvm::DIArray elemsArray = DBuilder.getOrCreateArray(elems);
|
llvm::DIArray elemsArray = DBuilder.getOrCreateArray(elems);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
llvm::DIType ret;
|
ldc::DIType ret;
|
||||||
if (t->ty == Tclass) {
|
if (t->ty == Tclass) {
|
||||||
ret = DBuilder.createClassType(
|
ret = DBuilder.createClassType(
|
||||||
CU, // compile unit where defined
|
CU, // compile unit where defined
|
||||||
|
@ -449,7 +452,7 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
ir->diCompositeType = DBuilder.replaceTemporary(llvm::TempMDType(ir->diCompositeType), static_cast<llvm::MDType*>(ret));
|
ir->diCompositeType = DBuilder.replaceTemporary(llvm::TempDINode(ir->diCompositeType), static_cast<llvm::DIType*>(ret));
|
||||||
#else
|
#else
|
||||||
ir->diCompositeType.replaceAllUsesWith(ret);
|
ir->diCompositeType.replaceAllUsesWith(ret);
|
||||||
#endif
|
#endif
|
||||||
|
@ -458,15 +461,20 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateArrayType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateArrayType(Type *type)
|
||||||
{
|
{
|
||||||
llvm::Type *T = DtoType(type);
|
llvm::Type *T = DtoType(type);
|
||||||
Type *t = type->toBasetype();
|
Type *t = type->toBasetype();
|
||||||
|
|
||||||
assert(t->ty == Tarray && "Only arrays allowed for debug info in DIBuilder::CreateArrayType");
|
assert(t->ty == Tarray && "Only arrays allowed for debug info in DIBuilder::CreateArrayType");
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
||||||
llvm::DIFile file = CreateFile(loc);
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
=======
|
||||||
|
Loc loc(IR->dmodule, 0, 0);
|
||||||
|
ldc::DIFile file(CreateFile(loc));
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
llvm::Metadata *elems[] =
|
llvm::Metadata *elems[] =
|
||||||
|
@ -481,21 +489,23 @@ llvm::DIType ldc::DIBuilder::CreateArrayType(Type *type)
|
||||||
|
|
||||||
return DBuilder.createStructType
|
return DBuilder.createStructType
|
||||||
(
|
(
|
||||||
llvm::DICompileUnit(GetCU()),
|
GetCU(),
|
||||||
llvm::StringRef(), // Name TODO: Really no name for arrays? t->toChars()?
|
llvm::StringRef(), // Name TODO: Really no name for arrays? t->toChars()?
|
||||||
file, // File
|
file, // File
|
||||||
0, // LineNo
|
0, // LineNo
|
||||||
getTypeBitSize(T), // size in bits
|
getTypeBitSize(T), // size in bits
|
||||||
getABITypeAlign(T)*8, // alignment in bits
|
getABITypeAlign(T)*8, // alignment in bits
|
||||||
0, // What here?
|
0, // What here?
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 307
|
||||||
|
nullptr, // DerivedFrom
|
||||||
|
#elif LDC_LLVM_VER >= 303
|
||||||
llvm::DIType(), // DerivedFrom
|
llvm::DIType(), // DerivedFrom
|
||||||
#endif
|
#endif
|
||||||
DBuilder.getOrCreateArray(elems)
|
DBuilder.getOrCreateArray(elems)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateSArrayType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateSArrayType(Type *type)
|
||||||
{
|
{
|
||||||
llvm::Type *T = DtoType(type);
|
llvm::Type *T = DtoType(type);
|
||||||
Type *t = type->toBasetype();
|
Type *t = type->toBasetype();
|
||||||
|
@ -518,7 +528,7 @@ llvm::DIType ldc::DIBuilder::CreateSArrayType(Type *type)
|
||||||
subscripts.push_back(subscript);
|
subscripts.push_back(subscript);
|
||||||
t = t->nextOf();
|
t = t->nextOf();
|
||||||
}
|
}
|
||||||
llvm::DIType basetype = CreateTypeDescription(t, false);
|
ldc::DIType basetype(CreateTypeDescription(t, false));
|
||||||
|
|
||||||
return DBuilder.createArrayType(
|
return DBuilder.createArrayType(
|
||||||
getTypeBitSize(T), // size (bits)
|
getTypeBitSize(T), // size (bits)
|
||||||
|
@ -528,7 +538,7 @@ llvm::DIType ldc::DIBuilder::CreateSArrayType(Type *type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateAArrayType(Type *type)
|
ldc::DIType ldc::DIBuilder::CreateAArrayType(Type *type)
|
||||||
{
|
{
|
||||||
// FIXME: Implement
|
// FIXME: Implement
|
||||||
#if LDC_LLVM_VER >= 304
|
#if LDC_LLVM_VER >= 304
|
||||||
|
@ -540,13 +550,18 @@ llvm::DIType ldc::DIBuilder::CreateAArrayType(Type *type)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ldc::DIFunctionType ldc::DIBuilder::CreateFunctionType(Type *type)
|
ldc::DISubroutineType ldc::DIBuilder::CreateFunctionType(Type *type)
|
||||||
{
|
{
|
||||||
TypeFunction *t = static_cast<TypeFunction*>(type);
|
TypeFunction *t = static_cast<TypeFunction*>(type);
|
||||||
Type *retType = t->next;
|
Type *retType = t->next;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
||||||
llvm::DIFile file = CreateFile(loc);
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
=======
|
||||||
|
Loc loc(IR->dmodule, 0, 0);
|
||||||
|
ldc::DIFile file(CreateFile(loc));
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
|
@ -556,7 +571,7 @@ ldc::DIFunctionType ldc::DIBuilder::CreateFunctionType(Type *type)
|
||||||
#endif
|
#endif
|
||||||
Elts.push_back(CreateTypeDescription(retType, true));
|
Elts.push_back(CreateTypeDescription(retType, true));
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDTypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#elif LDC_LLVM_VER >= 306
|
#elif LDC_LLVM_VER >= 306
|
||||||
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#else
|
#else
|
||||||
|
@ -565,13 +580,18 @@ ldc::DIFunctionType ldc::DIBuilder::CreateFunctionType(Type *type)
|
||||||
return DBuilder.createSubroutineType(file, EltTypeArray);
|
return DBuilder.createSubroutineType(file, EltTypeArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
ldc::DIFunctionType ldc::DIBuilder::CreateDelegateType(Type *type)
|
ldc::DISubroutineType ldc::DIBuilder::CreateDelegateType(Type *type)
|
||||||
{
|
{
|
||||||
// FIXME: Implement
|
// FIXME: Implement
|
||||||
TypeDelegate *t = static_cast<TypeDelegate*>(type);
|
TypeDelegate *t = static_cast<TypeDelegate*>(type);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
||||||
llvm::DIFile file = CreateFile(loc);
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
=======
|
||||||
|
Loc loc(IR->dmodule, 0, 0);
|
||||||
|
ldc::DIFile file(CreateFile(loc));
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
|
@ -587,7 +607,7 @@ ldc::DIFunctionType ldc::DIBuilder::CreateDelegateType(Type *type)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDTypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#elif LDC_LLVM_VER >= 306
|
#elif LDC_LLVM_VER >= 306
|
||||||
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#else
|
#else
|
||||||
|
@ -598,7 +618,7 @@ ldc::DIFunctionType ldc::DIBuilder::CreateDelegateType(Type *type)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
llvm::DIType ldc::DIBuilder::CreateTypeDescription(Type* type,
|
ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type* type,
|
||||||
bool derefclass)
|
bool derefclass)
|
||||||
{
|
{
|
||||||
Type *t = type->toBasetype();
|
Type *t = type->toBasetype();
|
||||||
|
@ -676,21 +696,25 @@ void ldc::DIBuilder::EmitCompileUnit(Module *m)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd)
|
ldc::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd)
|
||||||
{
|
{
|
||||||
if (!global.params.symdebug)
|
if (!global.params.symdebug)
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
return nullptr;
|
||||||
|
#else
|
||||||
return llvm::DISubprogram();
|
return llvm::DISubprogram();
|
||||||
|
#endif
|
||||||
|
|
||||||
Logger::println("D to dwarf subprogram");
|
Logger::println("D to dwarf subprogram");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
llvm::DICompileUnit CU(GetCU());
|
ldc::DICompileUnit CU(GetCU());
|
||||||
assert(CU && "Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
assert(CU && "Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
||||||
|
|
||||||
llvm::DIFile file = CreateFile(fd->loc);
|
ldc::DIFile file(CreateFile(fd->loc));
|
||||||
|
|
||||||
// Create subroutine type
|
// Create subroutine type
|
||||||
ldc::DIFunctionType DIFnType = CreateFunctionType(static_cast<TypeFunction*>(fd->type));
|
ldc::DISubroutineType DIFnType = CreateFunctionType(static_cast<TypeFunction*>(fd->type));
|
||||||
|
|
||||||
// FIXME: duplicates ?
|
// FIXME: duplicates ?
|
||||||
return DBuilder.createFunction(
|
return DBuilder.createFunction(
|
||||||
|
@ -709,20 +733,29 @@ llvm::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DISubprogram ldc::DIBuilder::EmitModuleCTor(llvm::Function* Fn,
|
ldc::DISubprogram ldc::DIBuilder::EmitModuleCTor(llvm::Function* Fn,
|
||||||
llvm::StringRef prettyname)
|
llvm::StringRef prettyname)
|
||||||
{
|
{
|
||||||
if (!global.params.symdebug)
|
if (!global.params.symdebug)
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
return nullptr;
|
||||||
|
#else
|
||||||
return llvm::DISubprogram();
|
return llvm::DISubprogram();
|
||||||
|
#endif
|
||||||
|
|
||||||
Logger::println("D to dwarf subprogram");
|
Logger::println("D to dwarf subprogram");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
llvm::DICompileUnit CU(GetCU());
|
ldc::DICompileUnit CU(GetCU());
|
||||||
assert(CU && "Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
assert(CU && "Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
Loc loc(IR->dmodule->srcfile->toChars(), 0, 0);
|
||||||
llvm::DIFile file(CreateFile(loc));
|
llvm::DIFile file(CreateFile(loc));
|
||||||
|
=======
|
||||||
|
Loc loc(IR->dmodule, 0, 0);
|
||||||
|
ldc::DIFile file(CreateFile(loc));
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
|
@ -732,13 +765,13 @@ llvm::DISubprogram ldc::DIBuilder::EmitModuleCTor(llvm::Function* Fn,
|
||||||
#endif
|
#endif
|
||||||
Elts.push_back(CreateTypeDescription(Type::tvoid, true));
|
Elts.push_back(CreateTypeDescription(Type::tvoid, true));
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDTypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#elif LDC_LLVM_VER >= 306
|
#elif LDC_LLVM_VER >= 306
|
||||||
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
|
||||||
#else
|
#else
|
||||||
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
|
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
|
||||||
#endif
|
#endif
|
||||||
ldc::DIFunctionType DIFnType = DBuilder.createSubroutineType(file, EltTypeArray);
|
ldc::DISubroutineType DIFnType = DBuilder.createSubroutineType(file, EltTypeArray);
|
||||||
|
|
||||||
// FIXME: duplicates ?
|
// FIXME: duplicates ?
|
||||||
return DBuilder.createFunction(
|
return DBuilder.createFunction(
|
||||||
|
@ -787,7 +820,7 @@ void ldc::DIBuilder::EmitBlockStart(Loc& loc)
|
||||||
Logger::println("D to dwarf block start");
|
Logger::println("D to dwarf block start");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
llvm::DILexicalBlock block = DBuilder.createLexicalBlock(
|
ldc::DILexicalBlock block = DBuilder.createLexicalBlock(
|
||||||
GetCurrentScope(), // scope
|
GetCurrentScope(), // scope
|
||||||
CreateFile(loc), // file
|
CreateFile(loc), // file
|
||||||
loc.linnum, // line
|
loc.linnum, // line
|
||||||
|
@ -826,11 +859,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)
|
||||||
{
|
{
|
||||||
IrVar::DebugMap::iterator sub = getIrVar(vd)->debug.find(IR->func()->diSubprogram);
|
IrFunction::VariableMap::iterator sub = IR->func()->variableMap.find(vd);
|
||||||
if (sub == getIrVar(vd)->debug.end())
|
if (sub == IR->func()->variableMap.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
llvm::DIVariable debugVariable = sub->second;
|
ldc::DILocalVariable debugVariable = sub->second;
|
||||||
if (!global.params.symdebug || !debugVariable)
|
if (!global.params.symdebug || !debugVariable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -859,13 +892,13 @@ 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;
|
||||||
|
|
||||||
IrVar *irVar = getIrVar(vd);
|
IrFunction::VariableMap& variableMap = IR->func()->variableMap;
|
||||||
IrVar::DebugMap::iterator sub = irVar->debug.find(IR->func()->diSubprogram);
|
IrFunction::VariableMap::iterator sub = variableMap.find(vd);
|
||||||
if (sub != irVar->debug.end())
|
if (sub != variableMap.end())
|
||||||
return; // ensure that the debug variable is created only once
|
return; // ensure that the debug variable is created only once
|
||||||
|
|
||||||
// get type description
|
// get type description
|
||||||
llvm::DIType TD = CreateTypeDescription(vd->type, true);
|
ldc::DIType TD = CreateTypeDescription(vd->type, true);
|
||||||
if (static_cast<llvm::MDNode *>(TD) == 0)
|
if (static_cast<llvm::MDNode *>(TD) == 0)
|
||||||
return; // unsupported
|
return; // unsupported
|
||||||
|
|
||||||
|
@ -878,11 +911,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
else
|
else
|
||||||
tag = llvm::dwarf::DW_TAG_auto_variable;
|
tag = llvm::dwarf::DW_TAG_auto_variable;
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
ldc::DILocalVariable debugVariable;
|
||||||
llvm::MDLocalVariable* debugVariable;
|
|
||||||
#else
|
|
||||||
llvm::DIVariable debugVariable;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LDC_LLVM_VER < 306
|
#if LDC_LLVM_VER < 306
|
||||||
if (addr.empty()) {
|
if (addr.empty()) {
|
||||||
|
@ -910,7 +939,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
irVar->debug[IR->func()->diSubprogram] = debugVariable;
|
variableMap[vd] = debugVariable;
|
||||||
|
|
||||||
// declare
|
// declare
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
|
@ -920,10 +949,14 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd)
|
ldc::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd)
|
||||||
{
|
{
|
||||||
if (!global.params.symdebug)
|
if (!global.params.symdebug)
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
return nullptr;
|
||||||
|
#else
|
||||||
return llvm::DIGlobalVariable();
|
return llvm::DIGlobalVariable();
|
||||||
|
#endif
|
||||||
|
|
||||||
Logger::println("D to dwarf global_variable");
|
Logger::println("D to dwarf global_variable");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -932,7 +965,7 @@ llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *
|
||||||
|
|
||||||
return DBuilder.createGlobalVariable(
|
return DBuilder.createGlobalVariable(
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
llvm::DICompileUnit(GetCU()), // context
|
GetCU(), // context
|
||||||
#endif
|
#endif
|
||||||
vd->toChars(), // name
|
vd->toChars(), // name
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
|
|
126
gen/dibuilder.h
126
gen/dibuilder.h
|
@ -67,40 +67,43 @@ extern const llvm::DataLayout* gDataLayout;
|
||||||
extern const llvm::TargetData* gDataLayout;
|
extern const llvm::TargetData* gDataLayout;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// LLVM 3.7: no more DIFoo wrappers for MDFoo* pointers
|
|
||||||
// Let's define primitive wrappers for backward compatibility,
|
|
||||||
// primarily for proper initialization with null.
|
|
||||||
#if LDC_LLVM_VER >= 307
|
|
||||||
namespace llvm {
|
|
||||||
template <class T>
|
|
||||||
class DIWrapper
|
|
||||||
{
|
|
||||||
T* ptr;
|
|
||||||
public:
|
|
||||||
DIWrapper(T* ptr = nullptr) : ptr(ptr) {}
|
|
||||||
operator T*() { return ptr; }
|
|
||||||
T* operator ->() { return ptr; }
|
|
||||||
};
|
|
||||||
|
|
||||||
using DICompileUnit = DIWrapper<MDCompileUnit>;
|
|
||||||
using DIExpression = DIWrapper<MDExpression>;
|
|
||||||
using DIFile = DIWrapper<MDFile>;
|
|
||||||
using DIGlobalVariable = DIWrapper<MDGlobalVariable>;
|
|
||||||
using DILexicalBlock = DIWrapper<MDLexicalBlock>;
|
|
||||||
using DISubprogram = DIWrapper<MDSubprogram>;
|
|
||||||
using DIType = DIWrapper<MDType>;
|
|
||||||
using DIVariable = DIWrapper<MDLocalVariable>;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ldc {
|
namespace ldc {
|
||||||
|
|
||||||
|
// Define some basic types
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
typedef llvm::MDSubroutineType* DIFunctionType;
|
typedef llvm::DIType* DIType;
|
||||||
|
typedef llvm::DIFile* DIFile;
|
||||||
|
typedef llvm::DIGlobalVariable* DIGlobalVariable;
|
||||||
|
typedef llvm::DILocalVariable* DILocalVariable;
|
||||||
|
typedef llvm::DIExpression* DIExpression;
|
||||||
|
typedef llvm::DILexicalBlock* DILexicalBlock;
|
||||||
|
typedef llvm::DIScope* DIScope;
|
||||||
|
typedef llvm::DISubroutineType* DISubroutineType;
|
||||||
|
typedef llvm::DISubprogram* DISubprogram;
|
||||||
|
typedef llvm::DICompileUnit* DICompileUnit;
|
||||||
#elif LDC_LLVM_VER >= 304
|
#elif LDC_LLVM_VER >= 304
|
||||||
typedef llvm::DICompositeType DIFunctionType;
|
typedef llvm::DIType DIType;
|
||||||
|
typedef llvm::DIFile DIFile;
|
||||||
|
typedef llvm::DIGlobalVariable DIGlobalVariable;
|
||||||
|
typedef llvm::DIVariable DILocalVariable;
|
||||||
|
typedef llvm::DILexicalBlock DILexicalBlock;
|
||||||
|
typedef llvm::DIDescriptor DIScope;
|
||||||
|
typedef llvm::DICompositeType DISubroutineType;
|
||||||
|
typedef llvm::DISubprogram DISubprogram;
|
||||||
|
typedef llvm::DICompileUnit DICompileUnit;
|
||||||
#else
|
#else
|
||||||
typedef llvm::DIType DIFunctionType;
|
typedef llvm::DIType DIType;
|
||||||
|
typedef llvm::DIFile DIFile;
|
||||||
|
typedef llvm::DIGlobalVariable DIGlobalVariable;
|
||||||
|
typedef llvm::DIVariable DILocalVariable;
|
||||||
|
typedef llvm::DILexicalBlock DILexicalBlock;
|
||||||
|
typedef llvm::DIDescriptor DIScope;
|
||||||
|
typedef llvm::DISubprogram DISubprogram;
|
||||||
|
typedef llvm::DIType DISubroutineType;
|
||||||
|
typedef llvm::DICompileUnit DICompileUnit;
|
||||||
|
#endif
|
||||||
|
#if LDC_LLVM_VER == 306
|
||||||
|
typedef llvm::DIExpression DIExpression;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class DIBuilder
|
class DIBuilder
|
||||||
|
@ -109,21 +112,20 @@ class DIBuilder
|
||||||
llvm::DIBuilder DBuilder;
|
llvm::DIBuilder DBuilder;
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDCompileUnit *CUNode;
|
DICompileUnit CUNode;
|
||||||
|
|
||||||
llvm::MDCompileUnit *GetCU()
|
|
||||||
{
|
|
||||||
return CUNode;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
const llvm::MDNode *CUNode;
|
const llvm::MDNode *CUNode;
|
||||||
|
|
||||||
const llvm::MDNode *GetCU()
|
|
||||||
{
|
|
||||||
return CUNode;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DICompileUnit GetCU()
|
||||||
|
{
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
return CUNode;
|
||||||
|
#else
|
||||||
|
return llvm::DICompileUnit(CUNode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIBuilder(IRState *const IR, llvm::Module &M);
|
DIBuilder(IRState *const IR, llvm::Module &M);
|
||||||
|
|
||||||
|
@ -134,7 +136,7 @@ public:
|
||||||
/// \brief Emit the Dwarf subprogram global for a function declaration fd.
|
/// \brief Emit the Dwarf subprogram global for a function declaration fd.
|
||||||
/// \param fd Function declaration to emit as subprogram.
|
/// \param fd Function declaration to emit as subprogram.
|
||||||
/// \returns the Dwarf subprogram global.
|
/// \returns the Dwarf subprogram global.
|
||||||
llvm::DISubprogram EmitSubProgram(FuncDeclaration *fd); // FIXME
|
DISubprogram EmitSubProgram(FuncDeclaration *fd); // FIXME
|
||||||
|
|
||||||
/// \brief Emit the Dwarf subprogram global for a module ctor.
|
/// \brief Emit the Dwarf subprogram global for a module ctor.
|
||||||
/// This is used for generated functions like moduleinfoctors,
|
/// This is used for generated functions like moduleinfoctors,
|
||||||
|
@ -142,7 +144,7 @@ public:
|
||||||
/// \param Fn llvm::Function pointer.
|
/// \param Fn llvm::Function pointer.
|
||||||
/// \param prettyname The name as seen in the source.
|
/// \param prettyname The name as seen in the source.
|
||||||
/// \returns the Dwarf subprogram global.
|
/// \returns the Dwarf subprogram global.
|
||||||
llvm::DISubprogram EmitModuleCTor(llvm::Function* Fn, llvm::StringRef prettyname); // FIXME
|
DISubprogram EmitModuleCTor(llvm::Function* Fn, llvm::StringRef prettyname); // FIXME
|
||||||
|
|
||||||
/// \brief Emits debug info for function start
|
/// \brief Emits debug info for function start
|
||||||
void EmitFuncStart(FuncDeclaration *fd);
|
void EmitFuncStart(FuncDeclaration *fd);
|
||||||
|
@ -175,43 +177,39 @@ public:
|
||||||
/// \brief Emits all things necessary for making debug info for a global variable vd.
|
/// \brief Emits all things necessary for making debug info for a global variable vd.
|
||||||
/// \param ll LLVM global variable
|
/// \param ll LLVM global variable
|
||||||
/// \param vd Variable declaration to emit debug info for.
|
/// \param vd Variable declaration to emit debug info for.
|
||||||
llvm::DIGlobalVariable EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd); // FIXME
|
DIGlobalVariable EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd); // FIXME
|
||||||
|
|
||||||
void EmitModuleEnd();
|
void EmitModuleEnd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::LLVMContext &getContext();
|
llvm::LLVMContext &getContext();
|
||||||
Module *getDefinedModule(Dsymbol *s);
|
Module *getDefinedModule(Dsymbol *s);
|
||||||
#if LDC_LLVM_VER >= 307
|
DIScope GetCurrentScope();
|
||||||
llvm::MDScope* GetCurrentScope();
|
void Declare(llvm::Value *var, ldc::DILocalVariable divar
|
||||||
#else
|
|
||||||
llvm::DIDescriptor GetCurrentScope();
|
|
||||||
#endif
|
|
||||||
void Declare(llvm::Value *var, llvm::DIVariable divar
|
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
, llvm::DIExpression diexpr
|
, ldc::DIExpression diexpr
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
void AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
void AddBaseFields(ClassDeclaration *sd, ldc::DIFile file,
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
std::vector<llvm::Metadata*> &elems
|
std::vector<llvm::Metadata*> &elems
|
||||||
#else
|
#else
|
||||||
std::vector<llvm::Value*> &elems
|
std::vector<llvm::Value*> &elems
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
llvm::DIFile CreateFile(Loc& loc);
|
DIFile CreateFile(Loc& loc);
|
||||||
llvm::DIType CreateBasicType(Type *type);
|
DIType CreateBasicType(Type *type);
|
||||||
llvm::DIType CreateEnumType(Type *type);
|
DIType CreateEnumType(Type *type);
|
||||||
llvm::DIType CreatePointerType(Type *type);
|
DIType CreatePointerType(Type *type);
|
||||||
llvm::DIType CreateVectorType(Type *type);
|
DIType CreateVectorType(Type *type);
|
||||||
llvm::DIType CreateMemberType(unsigned linnum, Type *type, llvm::DIFile file, const char* c_name, unsigned offset, PROTKIND);
|
DIType CreateMemberType(unsigned linnum, Type *type, DIFile file, const char* c_name, unsigned offset, PROTKIND);
|
||||||
llvm::DIType CreateCompositeType(Type *type);
|
DIType CreateCompositeType(Type *type);
|
||||||
llvm::DIType CreateArrayType(Type *type);
|
DIType CreateArrayType(Type *type);
|
||||||
llvm::DIType CreateSArrayType(Type *type);
|
DIType CreateSArrayType(Type *type);
|
||||||
llvm::DIType CreateAArrayType(Type *type);
|
DIType CreateAArrayType(Type *type);
|
||||||
DIFunctionType CreateFunctionType(Type *type);
|
DISubroutineType CreateFunctionType(Type *type);
|
||||||
DIFunctionType CreateDelegateType(Type *type);
|
DISubroutineType CreateDelegateType(Type *type);
|
||||||
llvm::DIType CreateTypeDescription(Type* type, bool derefclass = false);
|
DIType CreateTypeDescription(Type* type, bool derefclass = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -595,7 +595,7 @@ static void addCoverageAnalysis(Module* m)
|
||||||
d_cover_valid_slice = DtoConstSlice( DtoConstSize_t(type->getArrayNumElements()),
|
d_cover_valid_slice = DtoConstSlice( DtoConstSize_t(type->getArrayNumElements()),
|
||||||
llvm::ConstantExpr::getGetElementPtr(
|
llvm::ConstantExpr::getGetElementPtr(
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
DtoSize_t(),
|
type,
|
||||||
#endif
|
#endif
|
||||||
m->d_cover_valid, idxs, true) );
|
m->d_cover_valid, idxs, true) );
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ static void addCoverageAnalysis(Module* m)
|
||||||
d_cover_data_slice = DtoConstSlice( DtoConstSize_t(type->getArrayNumElements()),
|
d_cover_data_slice = DtoConstSlice( DtoConstSize_t(type->getArrayNumElements()),
|
||||||
llvm::ConstantExpr::getGetElementPtr(
|
llvm::ConstantExpr::getGetElementPtr(
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
LLType::getInt32Ty(gIR->context()),
|
type,
|
||||||
#endif
|
#endif
|
||||||
m->d_cover_data, idxs, true) );
|
m->d_cover_data, idxs, true) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#ifndef LDC_IR_IRFUNCTION_H
|
#ifndef LDC_IR_IRFUNCTION_H
|
||||||
#define LDC_IR_IRFUNCTION_H
|
#define LDC_IR_IRFUNCTION_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/DenseMap.h"
|
||||||
|
#include "llvm/ADT/DenseMapInfo.h"
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
#include "ir/irlandingpad.h"
|
#include "ir/irlandingpad.h"
|
||||||
#include "ir/irfuncty.h"
|
#include "ir/irfuncty.h"
|
||||||
|
@ -123,12 +125,16 @@ struct IrFunction
|
||||||
llvm::Value* _argptr;
|
llvm::Value* _argptr;
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDSubprogram* diSubprogram = nullptr;
|
llvm::DISubprogram* diSubprogram = nullptr;
|
||||||
std::stack<llvm::MDLexicalBlock*> diLexicalBlocks;
|
std::stack<llvm::DILexicalBlock*> diLexicalBlocks;
|
||||||
|
typedef llvm::DenseMap<VarDeclaration*, llvm::DILocalVariable*> VariableMap;
|
||||||
#else
|
#else
|
||||||
llvm::DISubprogram diSubprogram;
|
llvm::DISubprogram diSubprogram;
|
||||||
std::stack<llvm::DILexicalBlock> diLexicalBlocks;
|
std::stack<llvm::DILexicalBlock> diLexicalBlocks;
|
||||||
|
typedef llvm::DenseMap<VarDeclaration*, llvm::DIVariable> VariableMap;
|
||||||
#endif
|
#endif
|
||||||
|
// Debug info for all variables
|
||||||
|
VariableMap variableMap;
|
||||||
|
|
||||||
IrFuncTy irFty;
|
IrFuncTy irFty;
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
/// Composite type debug description. This is not only to cache, but also
|
/// Composite type debug description. This is not only to cache, but also
|
||||||
/// used for resolving forward references.
|
/// used for resolving forward references.
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
llvm::MDType* diCompositeType = nullptr;
|
llvm::DIType* diCompositeType = nullptr;
|
||||||
#else
|
#else
|
||||||
llvm::DIType diCompositeType;
|
llvm::DIType diCompositeType;
|
||||||
#endif
|
#endif
|
||||||
|
|
26
ir/irvar.h
26
ir/irvar.h
|
@ -29,8 +29,6 @@
|
||||||
#include "llvm/Analysis/DebugInfo.h"
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
struct IrFuncTyArg;
|
struct IrFuncTyArg;
|
||||||
class VarDeclaration;
|
class VarDeclaration;
|
||||||
|
|
||||||
|
@ -43,30 +41,6 @@ struct IrVar
|
||||||
|
|
||||||
VarDeclaration* V;
|
VarDeclaration* V;
|
||||||
llvm::Value* value;
|
llvm::Value* value;
|
||||||
|
|
||||||
// Debug description of variable.
|
|
||||||
// A variable can be accessed from nested functions.
|
|
||||||
// Each function has a debug description for the variable but with
|
|
||||||
// different address expression.
|
|
||||||
#if LDC_LLVM_VER >= 307
|
|
||||||
struct MDSubprogramLess : public std::binary_function <const llvm::MDSubprogram*, const llvm::MDSubprogram*, bool > {
|
|
||||||
bool operator()(const llvm::MDSubprogram* a, const llvm::MDSubprogram* b) const
|
|
||||||
{
|
|
||||||
return a->getLinkageName() < b->getLinkageName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<llvm::MDSubprogram*, llvm::MDLocalVariable*, MDSubprogramLess> DebugMap;
|
|
||||||
#else
|
|
||||||
struct DISubprogramLess : public std::binary_function <const llvm::DISubprogram&, const llvm::DISubprogram&, bool > {
|
|
||||||
bool operator()(const llvm::DISubprogram& a, const llvm::DISubprogram& b) const
|
|
||||||
{
|
|
||||||
return a.getLinkageName() < b.getLinkageName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::map<llvm::DISubprogram, llvm::DIVariable, DISubprogramLess> DebugMap;
|
|
||||||
#endif
|
|
||||||
DebugMap debug;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// represents a global variable
|
// represents a global variable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue