aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp13
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.h2
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp6
-rw-r--r--test/CodeGen/X86/dbg-merge-loc-entry.ll18
-rw-r--r--test/DebugInfo/X86/dbg-value-inlined-parameter.ll5
-rw-r--r--test/DebugInfo/X86/parameters.ll71
6 files changed, 79 insertions, 36 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 9e8f9aa..4c46543 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -348,7 +348,8 @@ void CompileUnit::addVariableAddress(DbgVariable *&DV, DIE *Die,
else if (DV->isBlockByrefVariable())
addBlockByrefAddress(DV, Die, dwarf::DW_AT_location, Location);
else
- addAddress(Die, dwarf::DW_AT_location, Location);
+ addAddress(Die, dwarf::DW_AT_location, Location,
+ DV->getVariable().isIndirect());
}
/// addRegisterOp - Add register operand.
@@ -384,13 +385,17 @@ void CompileUnit::addRegisterOffset(DIE *TheDie, unsigned Reg,
/// addAddress - Add an address attribute to a die based on the location
/// provided.
void CompileUnit::addAddress(DIE *Die, unsigned Attribute,
- const MachineLocation &Location) {
+ const MachineLocation &Location, bool Indirect) {
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
- if (Location.isReg())
+ if (Location.isReg() && !Indirect)
addRegisterOp(Block, Location.getReg());
- else
+ else {
addRegisterOffset(Block, Location.getReg(), Location.getOffset());
+ if (Indirect && !Location.isReg()) {
+ addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
+ }
+ }
// Now attach the location information to the DIE.
addBlock(Die, Attribute, 0, Block);
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index e1af572..36f5652 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -257,7 +257,7 @@ public:
/// addAddress - Add an address attribute to a die based on the location
/// provided.
void addAddress(DIE *Die, unsigned Attribute,
- const MachineLocation &Location);
+ const MachineLocation &Location, bool Indirect = false);
/// addConstantValue - Add constant value entry in variable DIE.
bool addConstantValue(DIE *Die, const MachineOperand &MO, DIType Ty);
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 130e295..39caa41 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1519,11 +1519,9 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
DEBUG(dbgs() << "Dropping DBG_VALUE for empty range:\n"
<< "\t" << *Prev << "\n");
History.pop_back();
- }
- else {
+ } else if (llvm::next(PrevMBB) != PrevMBB->getParent()->end())
// Terminate after LastMI.
History.push_back(LastMI);
- }
}
}
}
@@ -1592,7 +1590,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
if (LastMI == PrevMBB->end())
// Drop DBG_VALUE for empty range.
History.pop_back();
- else {
+ else if (PrevMBB != &PrevMBB->getParent()->back()) {
// Terminate after LastMI.
History.push_back(LastMI);
}
diff --git a/test/CodeGen/X86/dbg-merge-loc-entry.ll b/test/CodeGen/X86/dbg-merge-loc-entry.ll
index 30d0305..566af59 100644
--- a/test/CodeGen/X86/dbg-merge-loc-entry.ll
+++ b/test/CodeGen/X86/dbg-merge-loc-entry.ll
@@ -1,18 +1,12 @@
-; RUN: llc < %s | FileCheck %s
-; RUN: llc < %s -regalloc=basic | FileCheck %s
+; RUN: llc < %s -o %t -filetype=obj
+; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
+; RUN: llc < %s -o %t -filetype=obj -regalloc=basic
+; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin8"
-;CHECK: Ldebug_loc0:
-;CHECK-NEXT: .quad Lfunc_begin0
-;CHECK-NEXT: .quad L
-;CHECK-NEXT: Lset{{.*}} = Ltmp{{.*}}-Ltmp{{.*}} ## Loc expr size
-;CHECK-NEXT: .short Lset
-;CHECK-NEXT: Ltmp
-;CHECK-NEXT: .byte 85 ## DW_OP_reg5
-;CHECK-NEXT: Ltmp
-;CHECK-NEXT: .quad 0
-;CHECK-NEXT: .quad 0
+;CHECK: DW_AT_location{{.*}}(<0x01> 55 )
%0 = type { i64, i1 }
diff --git a/test/DebugInfo/X86/dbg-value-inlined-parameter.ll b/test/DebugInfo/X86/dbg-value-inlined-parameter.ll
index da6423f..6f4d3ab 100644
--- a/test/DebugInfo/X86/dbg-value-inlined-parameter.ll
+++ b/test/DebugInfo/X86/dbg-value-inlined-parameter.ll
@@ -3,14 +3,15 @@
; RUN: llc -mtriple=x86_64-apple-darwin -regalloc=basic %s -filetype=obj -o %t
; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
-;CHECK: DW_TAG_inlined_subroutine [12]
+;CHECK: DW_TAG_inlined_subroutine
;CHECK-NEXT: DW_AT_abstract_origin
;CHECK-NEXT: DW_AT_low_pc
;CHECK-NEXT: DW_AT_high_pc
;CHECK-NEXT: DW_AT_call_file
;CHECK-NEXT: DW_AT_call_line
-;CHECK: DW_TAG_formal_parameter [9]
+;CHECK: DW_TAG_formal_parameter
+;CHECK: DW_TAG_formal_parameter
;CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000055] = "sp")
%struct.S1 = type { float*, i32 }
diff --git a/test/DebugInfo/X86/parameters.ll b/test/DebugInfo/X86/parameters.ll
index 58ff62b..e83f114 100644
--- a/test/DebugInfo/X86/parameters.ll
+++ b/test/DebugInfo/X86/parameters.ll
@@ -13,16 +13,26 @@
; foo func(foo f) {
; return f; // reference 'f' for now because otherwise we hit another bug
; }
+;
+; void sink(void*);
+;
+; void func2(bool b, foo g) {
+; if (b)
+; sink(&g); // reference 'f' for now because otherwise we hit another bug
+; }
; }
; CHECK: debug_info contents
; CHECK: DW_AT_name{{.*}} = "f"
-; CHECK: DW_AT_location{{.*}}([[LOC:0x[0-9]*]])
-; CHECK: debug_loc contents
-; CHECK-NEXT: [[LOC]]: Beginning
-; CHECK-NEXT: Ending
; 0x74 is DW_OP_breg0 + 4, showing that the parameter is accessed indirectly
; (with a zero offset) from the register parameter
+; CHECK: DW_AT_location{{.*}}(<0x02> 74 00 )
+
+; CHECK: DW_AT_name{{.*}} = "g"
+; CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9]*]])
+; CHECK: debug_loc contents
+; CHECK-NEXT: [[G_LOC]]: Beginning
+; CHECK-NEXT: Ending
; CHECK-NEXT: Location description: 74 00
%"struct.pr14763::foo" = type { i8 }
@@ -30,9 +40,9 @@
; Function Attrs: uwtable
define void @_ZN7pr147634funcENS_3fooE(%"struct.pr14763::foo"* noalias sret %agg.result, %"struct.pr14763::foo"* %f) #0 {
entry:
- call void @llvm.dbg.declare(metadata !{%"struct.pr14763::foo"* %f}, metadata !17), !dbg !20
- call void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"* %agg.result, %"struct.pr14763::foo"* %f), !dbg !21
- ret void, !dbg !21
+ call void @llvm.dbg.declare(metadata !{%"struct.pr14763::foo"* %f}, metadata !22), !dbg !24
+ call void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"* %agg.result, %"struct.pr14763::foo"* %f), !dbg !25
+ ret void, !dbg !25
}
; Function Attrs: nounwind readnone
@@ -40,16 +50,40 @@ declare void @llvm.dbg.declare(metadata, metadata) #1
declare void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"*, %"struct.pr14763::foo"*) #2
+; Function Attrs: uwtable
+define void @_ZN7pr147635func2EbNS_3fooE(i1 zeroext %b, %"struct.pr14763::foo"* %g) #0 {
+entry:
+ %b.addr = alloca i8, align 1
+ %frombool = zext i1 %b to i8
+ store i8 %frombool, i8* %b.addr, align 1
+ call void @llvm.dbg.declare(metadata !{i8* %b.addr}, metadata !26), !dbg !27
+ call void @llvm.dbg.declare(metadata !{%"struct.pr14763::foo"* %g}, metadata !28), !dbg !27
+ %0 = load i8* %b.addr, align 1, !dbg !29
+ %tobool = trunc i8 %0 to i1, !dbg !29
+ br i1 %tobool, label %if.then, label %if.end, !dbg !29
+
+if.then: ; preds = %entry
+ %1 = bitcast %"struct.pr14763::foo"* %g to i8*, !dbg !31
+ call void @_ZN7pr147634sinkEPv(i8* %1), !dbg !31
+ br label %if.end, !dbg !31
+
+if.end: ; preds = %if.then, %entry
+ ret void, !dbg !32
+}
+
+declare void @_ZN7pr147634sinkEPv(i8*) #2
+
attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone }
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!21}
!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/pass.cpp] [DW_LANG_C_plus_plus]
!1 = metadata !{metadata !"pass.cpp", metadata !"/tmp"}
!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4}
+!3 = metadata !{metadata !4, metadata !17}
!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"func", metadata !"func", metadata !"_ZN7pr147634funcENS_3fooE", i32 6, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%"struct.pr14763::foo"*, %"struct.pr14763::foo"*)* @_ZN7pr147634funcENS_3fooE, null, null, metadata !2, i32 6} ; [ DW_TAG_subprogram ] [line 6] [def] [func]
!5 = metadata !{i32 786489, metadata !1, null, metadata !"pr14763", i32 1} ; [ DW_TAG_namespace ] [pr14763] [line 1]
!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
@@ -63,8 +97,19 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!14 = metadata !{i32 786448, null, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !15} ; [ DW_TAG_reference_type ] [line 0, size 0, align 0, offset 0] [from ]
!15 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !8} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from foo]
!16 = metadata !{i32 786468}
-!17 = metadata !{i32 786689, metadata !4, metadata !"f", metadata !18, i32 16777222, metadata !19, i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f] [line 6]
-!18 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/pass.cpp]
-!19 = metadata !{i32 786448, null, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !8} ; [ DW_TAG_reference_type ] [line 0, size 0, align 0, offset 0] [from foo]
-!20 = metadata !{i32 6, i32 0, metadata !4, null}
-!21 = metadata !{i32 7, i32 0, metadata !4, null}
+!17 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"func2", metadata !"func2", metadata !"_ZN7pr147635func2EbNS_3fooE", i32 12, metadata !18, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i1, %"struct.pr14763::foo"*)* @_ZN7pr147635func2EbNS_3fooE, null, null, metadata !2, i32 12} ; [ DW_TAG_subprogram ] [line 12] [def] [func2]
+!18 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !19, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
+!19 = metadata !{null, metadata !20, metadata !8}
+!20 = metadata !{i32 786468, null, null, metadata !"bool", i32 0, i64 8, i64 8, i64 0, i32 0, i32 2} ; [ DW_TAG_base_type ] [bool] [line 0, size 8, align 8, offset 0, enc DW_ATE_boolean]
+!21 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}
+!22 = metadata !{i32 786689, metadata !4, metadata !"f", metadata !23, i32 16777222, metadata !8, i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f] [line 6]
+!23 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/pass.cpp]
+!24 = metadata !{i32 6, i32 0, metadata !4, null}
+!25 = metadata !{i32 7, i32 0, metadata !4, null}
+!26 = metadata !{i32 786689, metadata !17, metadata !"b", metadata !23, i32 16777228, metadata !20, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 12]
+!27 = metadata !{i32 12, i32 0, metadata !17, null}
+!28 = metadata !{i32 786689, metadata !17, metadata !"g", metadata !23, i32 33554444, metadata !8, i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [g] [line 12]
+!29 = metadata !{i32 13, i32 0, metadata !30, null}
+!30 = metadata !{i32 786443, metadata !1, metadata !17, i32 13, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/tmp/pass.cpp]
+!31 = metadata !{i32 14, i32 0, metadata !30, null}
+!32 = metadata !{i32 15, i32 0, metadata !17, null}