mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +03:00
Fix generation of DWARF debug information in LLVM 3.6.
The creation of complex expressions (e.g. address calculations) was extended in LLVM 3.6.
This commit is contained in:
parent
cb320d9a3f
commit
b3e239a527
3 changed files with 60 additions and 8 deletions
|
@ -64,9 +64,17 @@ llvm::DIDescriptor ldc::DIBuilder::GetCurrentScope()
|
|||
return fn->diLexicalBlocks.top();
|
||||
}
|
||||
|
||||
void ldc::DIBuilder::Declare(llvm::Value *var, llvm::DIVariable divar)
|
||||
void ldc::DIBuilder::Declare(llvm::Value *var, llvm::DIVariable divar
|
||||
#if LDC_LLVM_VER >= 306
|
||||
, llvm::DIExpression diexpr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
llvm::Instruction *instr = DBuilder.insertDeclare(var, divar, IR->scopebb());
|
||||
llvm::Instruction *instr = DBuilder.insertDeclare(var, divar,
|
||||
#if LDC_LLVM_VER >= 306
|
||||
diexpr,
|
||||
#endif
|
||||
IR->scopebb());
|
||||
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
||||
}
|
||||
|
||||
|
@ -724,12 +732,21 @@ void ldc::DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd)
|
|||
if (!global.params.symdebug || !debugVariable)
|
||||
return;
|
||||
|
||||
llvm::Instruction *instr = DBuilder.insertDbgValueIntrinsic(val, 0, debugVariable, IR->scopebb());
|
||||
llvm::Instruction *instr = DBuilder.insertDbgValueIntrinsic(val, 0, debugVariable,
|
||||
#if LDC_LLVM_VER >= 306
|
||||
DBuilder.createExpression(),
|
||||
#endif
|
||||
IR->scopebb());
|
||||
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
||||
}
|
||||
|
||||
void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||
llvm::ArrayRef<llvm::Value *> addr)
|
||||
#if LDC_LLVM_VER >= 306
|
||||
llvm::ArrayRef<int64_t> addr
|
||||
#else
|
||||
llvm::ArrayRef<llvm::Value *> addr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (!global.params.symdebug)
|
||||
return;
|
||||
|
@ -755,7 +772,9 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
else
|
||||
tag = llvm::dwarf::DW_TAG_auto_variable;
|
||||
|
||||
#if LDC_LLVM_VER < 306
|
||||
if (addr.empty()) {
|
||||
#endif
|
||||
irVar->debugVariable = DBuilder.createLocalVariable(
|
||||
tag, // tag
|
||||
GetCurrentScope(), // scope
|
||||
|
@ -765,7 +784,9 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
TD, // type
|
||||
true // preserve
|
||||
);
|
||||
} else {
|
||||
#if LDC_LLVM_VER < 306
|
||||
}
|
||||
else {
|
||||
irVar->debugVariable = DBuilder.createComplexVariable(
|
||||
tag, // tag
|
||||
GetCurrentScope(), // scope
|
||||
|
@ -777,9 +798,14 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
|||
);
|
||||
}
|
||||
irVar->debugFunc = IR->func()->diSubprogram;
|
||||
#endif
|
||||
|
||||
// declare
|
||||
#if LDC_LLVM_VER >= 306
|
||||
Declare(ll, irVar->debugVariable, addr.empty() ? DBuilder.createExpression() : DBuilder.createExpression(addr));
|
||||
#else
|
||||
Declare(ll, irVar->debugVariable);
|
||||
#endif
|
||||
}
|
||||
|
||||
llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *ll, VarDeclaration *vd)
|
||||
|
@ -794,7 +820,7 @@ llvm::DIGlobalVariable ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *
|
|||
|
||||
return DBuilder.createGlobalVariable(
|
||||
#if LDC_LLVM_VER >= 306
|
||||
GetCurrentScope(), // context
|
||||
llvm::DICompileUnit(GetCU()), // context
|
||||
#endif
|
||||
vd->toChars(), // name
|
||||
#if LDC_LLVM_VER >= 303
|
||||
|
|
|
@ -127,7 +127,12 @@ public:
|
|||
/// \param vd Variable declaration to emit debug info for.
|
||||
/// \param addr An array of complex address operations.
|
||||
void EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
|
||||
llvm::ArrayRef<llvm::Value *> addr = llvm::ArrayRef<llvm::Value *>());
|
||||
#if LDC_LLVM_VER >= 306
|
||||
llvm::ArrayRef<int64_t> addr = llvm::ArrayRef<int64_t>()
|
||||
#else
|
||||
llvm::ArrayRef<llvm::Value *> addr = llvm::ArrayRef<llvm::Value *>()
|
||||
#endif
|
||||
);
|
||||
|
||||
/// \brief Emits all things necessary for making debug info for a global variable vd.
|
||||
/// \param ll LLVM global variable
|
||||
|
@ -140,7 +145,11 @@ private:
|
|||
llvm::LLVMContext &getContext();
|
||||
Module *getDefinedModule(Dsymbol *s);
|
||||
llvm::DIDescriptor GetCurrentScope();
|
||||
void Declare(llvm::Value *var, llvm::DIVariable divar);
|
||||
void Declare(llvm::Value *var, llvm::DIVariable divar
|
||||
#if LDC_LLVM_VER >= 306
|
||||
, llvm::DIExpression diexpr
|
||||
#endif
|
||||
);
|
||||
void AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
||||
std::vector<llvm::Value*> &elems);
|
||||
llvm::DIFile CreateFile(Loc& loc);
|
||||
|
@ -165,9 +174,14 @@ public:
|
|||
return;
|
||||
|
||||
uint64_t offset = gDataLayout->getStructLayout(type)->getElementOffset(index);
|
||||
#if LDC_LLVM_VER >= 306
|
||||
addr.push_back(llvm::dwarf::DW_OP_plus);
|
||||
addr.push_back(offset);
|
||||
#else
|
||||
llvm::Type *int64Ty = llvm::Type::getInt64Ty(getContext());
|
||||
addr.push_back(llvm::ConstantInt::get(int64Ty, llvm::DIBuilder::OpPlus));
|
||||
addr.push_back(llvm::ConstantInt::get(int64Ty, offset));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -187,8 +201,12 @@ public:
|
|||
if (!global.params.symdebug)
|
||||
return;
|
||||
|
||||
#if LDC_LLVM_VER >= 306
|
||||
addr.push_back(llvm::dwarf::DW_OP_deref);
|
||||
#else
|
||||
llvm::Type *int64Ty = llvm::Type::getInt64Ty(getContext());
|
||||
addr.push_back(llvm::ConstantInt::get(int64Ty, llvm::DIBuilder::OpDeref));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,11 @@ DValue* DtoNestedVariable(Loc& loc, Type* astype, VarDeclaration* vd, bool byref
|
|||
}
|
||||
|
||||
LLValue *dwarfValue = 0;
|
||||
#if LDC_LLVM_VER >= 306
|
||||
std::vector<int64_t> dwarfAddr;
|
||||
#else
|
||||
std::vector<LLValue*> dwarfAddr;
|
||||
#endif
|
||||
|
||||
// get the nested context
|
||||
LLValue* ctx = 0;
|
||||
|
@ -497,7 +501,11 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
|||
}
|
||||
|
||||
if (global.params.symdebug) {
|
||||
#if LDC_LLVM_VER >= 306
|
||||
LLSmallVector<int64_t, 2> addr;
|
||||
#else
|
||||
LLSmallVector<LLValue*, 2> addr;
|
||||
#endif
|
||||
gIR->DBuilder.OpOffset(addr, frameType, irLocal->nestedIndex);
|
||||
gIR->DBuilder.EmitLocalVariable(frame, vd, addr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue