<p dir="ltr">Formatting, a comment about the discriminator in the comment there and lgtm. </p>
<br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 25, 2016, 9:48 PM Dehao Chen <<a href="mailto:danielcdh@gmail.com">danielcdh@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">danielcdh created this revision.<br>
danielcdh added reviewers: dblaikie, dnovillo, echristo.<br>
danielcdh added a subscriber: llvm-commits.<br>
Herald added a subscriber: joker.eph.<br>
<br>
This is the follow-up patch for <a href="http://reviews.llvm.org/D19436" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19436</a><br>
* Update the discriminator reading algorithm to match the assignment algorithm.<br>
* Add test to cover the new algorithm.<br>
<br>
<a href="http://reviews.llvm.org/D19522" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19522</a><br>
<br>
Files:<br>
lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
test/DebugInfo/X86/discriminator2.ll<br>
<br>
Index: test/DebugInfo/X86/discriminator2.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/DebugInfo/X86/discriminator2.ll<br>
@@ -0,0 +1,43 @@<br>
+; RUN: llc -mtriple=i386-unknown-unknown -mcpu=core2 %s -o %t -filetype=obj<br>
+; RUN: llvm-dwarfdump -debug-dump=line %t | FileCheck %s<br>
+<br>
+; Function Attrs: uwtable<br>
+define void @_Z3bazv() #0 !dbg !6 {<br>
+ %1 = call i32 @_Z3barv(), !dbg !9<br>
+ %2 = call i32 @_Z3barv(), !dbg !10<br>
+ call void @_Z3fooii(i32 %1, i32 %2), !dbg !11<br>
+ %3 = call i32 @_Z3barv(), !dbg !13<br>
+ ret void, !dbg !14<br>
+}<br>
+<br>
+declare void @_Z3fooii(i32, i32) #1<br>
+<br>
+declare i32 @_Z3barv() #1<br>
+<br>
+attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
+attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3, !4}<br>
+!llvm.ident = !{!5}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 267219)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "test.cc", directory: ".")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!5 = !{!"clang version 3.9.0 (trunk 267219)"}<br>
+!6 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)<br>
+!7 = !DISubroutineType(types: !8)<br>
+!8 = !{null}<br>
+!9 = !DILocation(line: 4, column: 7, scope: !6)<br>
+!10 = !DILocation(line: 5, column: 14, scope: !6)<br>
+!11 = !DILocation(line: 4, column: 3, scope: !12)<br>
+!12 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)<br>
+!13 = !DILocation(line: 5, column: 21, scope: !12)<br>
+!14 = !DILocation(line: 6, column: 1, scope: !6)<br>
+<br>
+; CHECK: Address Line Column File ISA Discriminator Flags<br>
+; CHECK: ------------------ ------ ------ ------ --- ------------- -------------<br>
+; CHECK: {{.*}} 4 3 1 0 1 {{.*}}<br>
+; CHECK: {{.*}} 5 21 1 0 1 {{.*}}<br>
Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
===================================================================<br>
--- lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
+++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
@@ -375,10 +375,15 @@<br>
break;<br>
<br>
case DW_LNS_advance_line:<br>
- // Takes a single signed LEB128 operand and adds that value to<br>
- // the line register of the state machine.<br>
- State.Row.Line += debug_line_data.getSLEB128(offset_ptr);<br>
- break;<br>
+ {<br>
+ // Takes a single signed LEB128 operand and adds that value to<br>
+ // the line register of the state machine.<br>
+ int32_t line_offset = debug_line_data.getSLEB128(offset_ptr);<br>
+ State.Row.Line += line_offset;<br>
+ if (line_offset != 0)<br>
+ State.Row.Discriminator = 0;<br>
+ break;<br>
+ }<br>
<br>
case DW_LNS_set_file:<br>
// Takes a single unsigned LEB128 operand and stores it in the file<br>
@@ -509,6 +514,8 @@<br>
State.Row.Line += line_offset;<br>
State.Row.Address += addr_offset;<br>
State.appendRowToMatrix(*offset_ptr);<br>
+ if (line_offset != 0)<br>
+ State.Row.Discriminator = 0;<br>
}<br>
}<br>
<br>
<br>
<br>
</blockquote></div>