summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp20
-rw-r--r--llvm/lib/IR/DIBuilder.cpp4
-rw-r--r--llvm/lib/IR/DebugInfo.cpp4
3 files changed, 24 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index c38ada6b66b..7f0c33bb05c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -588,6 +588,9 @@ static bool isTypeSigned(DIType Ty, int *SizeInBits) {
/// addConstantValue - Add constant value entry in variable DIE.
bool CompileUnit::addConstantValue(DIE *Die, const MachineOperand &MO,
DIType Ty) {
+ // FIXME: This is a bit conservative/simple - it emits negative values at
+ // their maximum bit width which is a bit unfortunate (& doesn't prefer
+ // udata/sdata over dataN as suggested by the DWARF spec)
assert(MO.isImm() && "Invalid machine operand!");
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
int SizeInBits = -1;
@@ -1095,8 +1098,21 @@ CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TPV){
addType(ParamDIE, TPV.getType());
if (!TPV.getName().empty())
addString(ParamDIE, dwarf::DW_AT_name, TPV.getName());
- addUInt(ParamDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata,
- TPV.getValue());
+ if (Value *Val = TPV.getValue()) {
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(Val))
+ addConstantValue(ParamDIE, CI, TPV.getType().isUnsignedDIType());
+ else if (GlobalValue *GV = dyn_cast<GlobalValue>(Val)) {
+ // For declaration non-type template parameters (such as global values and
+ // functions)
+ DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
+ addOpAddress(Block, Asm->Mang->getSymbol(GV));
+ // Emit DW_OP_stack_value to use the address as the immediate value of the
+ // parameter, rather than a pointer to it.
+ addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
+ addBlock(ParamDIE, dwarf::DW_AT_location, 0, Block);
+ }
+ }
+
return ParamDIE;
}
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index eb220b2349c..4bb87c9afb7 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -502,7 +502,7 @@ DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
/// value parameter.
DITemplateValueParameter
DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
- DIType Ty, uint64_t Val,
+ DIType Ty, Value *Val,
MDNode *File, unsigned LineNo,
unsigned ColumnNo) {
Value *Elts[] = {
@@ -510,7 +510,7 @@ DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
Ty,
- ConstantInt::get(Type::getInt64Ty(VMContext), Val),
+ Val,
File,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 38fc90f865e..8a0fb8d5b10 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -695,6 +695,10 @@ DIArray DISubprogram::getVariables() const {
return DIArray();
}
+Value *DITemplateValueParameter::getValue() const {
+ return getField(DbgNode, 4);
+}
+
void DIScope::setFilename(StringRef Name, LLVMContext &Context) {
if (!DbgNode)
return;
OpenPOWER on IntegriCloud