mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Do not drop constant values when a variable's content is described using .debug_loc entries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132427 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ec880283b3
commit
c432907eca
@ -1410,16 +1410,6 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
|
||||
HI = History.begin(), HE = History.end(); HI != HE; ++HI) {
|
||||
const MachineInstr *Begin = *HI;
|
||||
assert(Begin->isDebugValue() && "Invalid History entry");
|
||||
MachineLocation MLoc;
|
||||
if (Begin->getNumOperands() == 3) {
|
||||
if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm())
|
||||
MLoc.set(Begin->getOperand(0).getReg(), Begin->getOperand(1).getImm());
|
||||
} else
|
||||
MLoc = Asm->getDebugValueLocation(Begin);
|
||||
|
||||
// FIXME: emitDebugLoc only understands registers.
|
||||
if (!MLoc.getReg())
|
||||
continue;
|
||||
|
||||
// Compute the range for a register location.
|
||||
const MCSymbol *FLabel = getLabelBeforeInsn(Begin);
|
||||
@ -1442,7 +1432,25 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
|
||||
}
|
||||
|
||||
// The value is valid until the next DBG_VALUE or clobber.
|
||||
DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc, Var));
|
||||
MachineLocation MLoc;
|
||||
if (Begin->getNumOperands() == 3) {
|
||||
if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm()) {
|
||||
MLoc.set(Begin->getOperand(0).getReg(),
|
||||
Begin->getOperand(1).getImm());
|
||||
DotDebugLocEntries.
|
||||
push_back(DotDebugLocEntry(FLabel, SLabel, MLoc, Var));
|
||||
}
|
||||
// FIXME: Handle isFPImm also.
|
||||
else if (Begin->getOperand(0).isImm()) {
|
||||
DotDebugLocEntries.
|
||||
push_back(DotDebugLocEntry(FLabel, SLabel,
|
||||
Begin->getOperand(0).getImm()));
|
||||
}
|
||||
} else {
|
||||
MLoc = Asm->getDebugValueLocation(Begin);
|
||||
DotDebugLocEntries.
|
||||
push_back(DotDebugLocEntry(FLabel, SLabel, MLoc, Var));
|
||||
}
|
||||
}
|
||||
DotDebugLocEntries.push_back(DotDebugLocEntry());
|
||||
}
|
||||
@ -2586,7 +2594,20 @@ void DwarfDebug::emitDebugLoc() {
|
||||
MCSymbol *end = Asm->OutStreamer.getContext().CreateTempSymbol();
|
||||
Asm->EmitLabelDifference(end, begin, 2);
|
||||
Asm->OutStreamer.EmitLabel(begin);
|
||||
if (DV.hasComplexAddress()) {
|
||||
if (Entry.isConstant()) {
|
||||
DIBasicType BTy(DV.getType());
|
||||
if (BTy.Verify() &&
|
||||
(BTy.getEncoding() == dwarf::DW_ATE_signed
|
||||
|| BTy.getEncoding() == dwarf::DW_ATE_signed_char)) {
|
||||
Asm->OutStreamer.AddComment("DW_OP_consts");
|
||||
Asm->EmitInt8(dwarf::DW_OP_consts);
|
||||
Asm->EmitSLEB128(Entry.getConstant());
|
||||
} else {
|
||||
Asm->OutStreamer.AddComment("DW_OP_constu");
|
||||
Asm->EmitInt8(dwarf::DW_OP_constu);
|
||||
Asm->EmitULEB128(Entry.getConstant());
|
||||
}
|
||||
} else if (DV.hasComplexAddress()) {
|
||||
unsigned N = DV.getNumAddrElements();
|
||||
unsigned i = 0;
|
||||
if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
|
||||
@ -2620,6 +2641,7 @@ void DwarfDebug::emitDebugLoc() {
|
||||
else llvm_unreachable("unknown Opcode found in complex address");
|
||||
}
|
||||
} else {
|
||||
// Regular entry.
|
||||
Asm->EmitDwarfRegOp(Entry.Loc);
|
||||
}
|
||||
Asm->OutStreamer.EmitLabel(end);
|
||||
|
@ -68,10 +68,19 @@ typedef struct DotDebugLocEntry {
|
||||
MachineLocation Loc;
|
||||
const MDNode *Variable;
|
||||
bool Merged;
|
||||
DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {}
|
||||
bool Constant;
|
||||
int64_t iConstant;
|
||||
DotDebugLocEntry()
|
||||
: Begin(0), End(0), Variable(0), Merged(false),
|
||||
Constant(false), iConstant(0) {}
|
||||
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
|
||||
const MDNode *V)
|
||||
: Begin(B), End(E), Loc(L), Variable(V), Merged(false) {}
|
||||
: Begin(B), End(E), Loc(L), Variable(V), Merged(false),
|
||||
Constant(false), iConstant(0) {}
|
||||
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
|
||||
: Begin(B), End(E), Variable(0), Merged(false),
|
||||
Constant(true), iConstant(i) {}
|
||||
|
||||
/// Empty entries are also used as a trigger to emit temp label. Such
|
||||
/// labels are referenced is used to find debug_loc offset for a given DIE.
|
||||
bool isEmpty() { return Begin == 0 && End == 0; }
|
||||
@ -82,6 +91,8 @@ typedef struct DotDebugLocEntry {
|
||||
Next->Begin = Begin;
|
||||
Merged = true;
|
||||
}
|
||||
bool isConstant() { return Constant; }
|
||||
int64_t getConstant() { return iConstant; }
|
||||
} DotDebugLocEntry;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
34
test/CodeGen/X86/dbg-const.ll
Normal file
34
test/CodeGen/X86/dbg-const.ll
Normal file
@ -0,0 +1,34 @@
|
||||
; RUN: llc < %s - | FileCheck %s
|
||||
target triple = "x86_64-apple-darwin10.0.0"
|
||||
|
||||
;CHECK: ## DW_OP_constu
|
||||
;CHECK-NEXT: .byte 42
|
||||
define i32 @foobar() nounwind readonly noinline ssp {
|
||||
entry:
|
||||
%call = tail call i32 @bar(), !dbg !11
|
||||
tail call void @llvm.dbg.value(metadata !8, i64 0, metadata !6), !dbg !9
|
||||
%call2 = tail call i32 @bar(), !dbg !11
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %call}, i64 0, metadata !6), !dbg !11
|
||||
%add = add nsw i32 %call2, %call, !dbg !12
|
||||
ret i32 %add, !dbg !10
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
||||
declare i32 @bar() nounwind readnone
|
||||
|
||||
!llvm.dbg.sp = !{!0}
|
||||
!llvm.dbg.lv.foobar = !{!6}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foobar", metadata !"foobar", metadata !"foobar", metadata !1, i32 12, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true, i32 ()* @foobar}
|
||||
!1 = metadata !{i32 524329, metadata !"mu.c", metadata !"/private/tmp", metadata !2}
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"mu.c", metadata !"/private/tmp", metadata !"clang version 2.9 (trunk 114183)", i1 true, i1 true, metadata !"", i32 0}
|
||||
!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}
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}
|
||||
!6 = metadata !{i32 524544, metadata !7, metadata !"j", metadata !1, i32 15, metadata !5}
|
||||
!7 = metadata !{i32 524299, metadata !0, i32 12, i32 52, metadata !1, i32 0}
|
||||
!8 = metadata !{i32 42}
|
||||
!9 = metadata !{i32 15, i32 12, metadata !7, null}
|
||||
!10 = metadata !{i32 23, i32 3, metadata !7, null}
|
||||
!11 = metadata !{i32 17, i32 3, metadata !7, null}
|
||||
!12 = metadata !{i32 18, i32 3, metadata !7, null}
|
Loading…
x
Reference in New Issue
Block a user