mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Handle TAG_constant for integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110656 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c9aed19747
commit
2936807564
@ -186,7 +186,8 @@ bool DIDescriptor::isSubprogram() const {
|
||||
/// isGlobalVariable - Return true if the specified tag is legal for
|
||||
/// DIGlobalVariable.
|
||||
bool DIDescriptor::isGlobalVariable() const {
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_variable;
|
||||
return DbgNode && (getTag() == dwarf::DW_TAG_variable ||
|
||||
getTag() == dwarf::DW_TAG_constant);
|
||||
}
|
||||
|
||||
/// isGlobal - Return true if the specified tag is legal for DIGlobal.
|
||||
@ -1078,7 +1079,7 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name,
|
||||
unsigned LineNo, DIType Ty,bool isLocalToUnit,
|
||||
bool isDefinition, llvm::Constant *Val) {
|
||||
Value *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_variable),
|
||||
GetTagConstant(dwarf::DW_TAG_constant),
|
||||
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
||||
Context,
|
||||
MDString::get(VMContext, Name),
|
||||
|
@ -1876,13 +1876,15 @@ void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
|
||||
return;
|
||||
|
||||
DIType GTy = GV.getType();
|
||||
DIE *VariableDIE = new DIE(dwarf::DW_TAG_variable);
|
||||
DIE *VariableDIE = new DIE(GV.getTag());
|
||||
|
||||
bool isGlobalVariable = GV.getGlobal() != NULL;
|
||||
|
||||
// Add name.
|
||||
addString(VariableDIE, dwarf::DW_AT_name, dwarf::DW_FORM_string,
|
||||
GV.getDisplayName());
|
||||
StringRef LinkageName = GV.getLinkageName();
|
||||
if (!LinkageName.empty())
|
||||
if (!LinkageName.empty() && isGlobalVariable)
|
||||
addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
|
||||
getRealLinkageName(LinkageName));
|
||||
// Add type.
|
||||
@ -1907,25 +1909,40 @@ void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
|
||||
DIDescriptor GVContext = GV.getContext();
|
||||
addToContextOwner(VariableDIE, GVContext);
|
||||
// Add location.
|
||||
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
|
||||
addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
|
||||
addLabel(Block, 0, dwarf::DW_FORM_udata,
|
||||
Asm->Mang->getSymbol(GV.getGlobal()));
|
||||
// Do not create specification DIE if context is either compile unit
|
||||
// or a subprogram.
|
||||
if (GV.isDefinition() && !GVContext.isCompileUnit() &&
|
||||
!GVContext.isFile() && !isSubprogramContext(GVContext)) {
|
||||
// Create specification DIE.
|
||||
DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable);
|
||||
addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification,
|
||||
dwarf::DW_FORM_ref4, VariableDIE);
|
||||
addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block);
|
||||
addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
|
||||
TheCU->addDie(VariableSpecDIE);
|
||||
} else {
|
||||
addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block);
|
||||
if (isGlobalVariable) {
|
||||
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
|
||||
addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
|
||||
addLabel(Block, 0, dwarf::DW_FORM_udata,
|
||||
Asm->Mang->getSymbol(GV.getGlobal()));
|
||||
// Do not create specification DIE if context is either compile unit
|
||||
// or a subprogram.
|
||||
if (GV.isDefinition() && !GVContext.isCompileUnit() &&
|
||||
!GVContext.isFile() && !isSubprogramContext(GVContext)) {
|
||||
// Create specification DIE.
|
||||
DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable);
|
||||
addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification,
|
||||
dwarf::DW_FORM_ref4, VariableDIE);
|
||||
addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block);
|
||||
addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
|
||||
TheCU->addDie(VariableSpecDIE);
|
||||
} else {
|
||||
addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block);
|
||||
}
|
||||
} else if (Constant *C = GV.getConstant()) {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
|
||||
DIBasicType BTy(GTy);
|
||||
if (BTy.Verify()) {
|
||||
unsigned Encoding = BTy.getEncoding();
|
||||
if (Encoding == dwarf::DW_ATE_unsigned ||
|
||||
Encoding == dwarf::DW_ATE_unsigned_char)
|
||||
addUInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata,
|
||||
CI->getZExtValue());
|
||||
else
|
||||
addSInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata,
|
||||
CI->getSExtValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
25
test/CodeGen/X86/2010-08-10-DbgConstant.ll
Normal file
25
test/CodeGen/X86/2010-08-10-DbgConstant.ll
Normal file
@ -0,0 +1,25 @@
|
||||
; RUN: llc -O0 < %s | FileCheck %s
|
||||
; CHECK: DW_TAG_constant
|
||||
; CHECK-NEXT: ascii "ro" ## DW_AT_name
|
||||
|
||||
define void @foo() nounwind ssp {
|
||||
entry:
|
||||
call void @bar(i32 201), !dbg !8
|
||||
ret void, !dbg !8
|
||||
}
|
||||
|
||||
declare void @bar(i32)
|
||||
|
||||
!llvm.dbg.sp = !{!0}
|
||||
!llvm.dbg.gv = !{!5}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"/tmp/l.c", metadata !"/Volumes/Lalgate/clean/D", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"/tmp/l.c", metadata !"/Volumes/Lalgate/clean/D", metadata !"clang 2.8", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{null}
|
||||
!5 = metadata !{i32 524327, i32 0, metadata !1, metadata !"ro", metadata !"ro", metadata !"ro", metadata !1, i32 1, metadata !6, i1 true, i1 true, i32 201} ; [ DW_TAG_constant ]
|
||||
!6 = metadata !{i32 524326, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !7} ; [ DW_TAG_const_type ]
|
||||
!7 = metadata !{i32 524324, metadata !1, metadata !"unsigned int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ]
|
||||
!8 = metadata !{i32 3, i32 14, metadata !9, null}
|
||||
!9 = metadata !{i32 524299, metadata !0, i32 3, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
Loading…
Reference in New Issue
Block a user