<div dir="ltr">also looks like this might be yours: <a href="http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/26024">http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/26024</a><br><br>Let me know if you need any help analyzing the failure, etc</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 29, 2015 at 9:13 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Oct 29, 2015 at 7:38 PM, Dehao Chen via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dehao<br>
Date: Thu Oct 29 21:38:29 2015<br>
New Revision: 251680<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251680&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251680&view=rev</a><br>
Log:<br>
Update the discriminator assignment algorithm<br>
<br>
* If a scope has already been assigned a discriminator, do not reassign a nested discriminator for it.<br>
* If the file and line both match, even if the column does not match, we should assign a new discriminator for the stmt.<br></blockquote></span><div><br>Why do we need a discriminator even when the column is distinct?<br> </div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
original code:<br>
; #1 int foo(int i) {<br>
; #2 if (i == 3 || i == 5) return 100; else return 99;<br>
; #3 }<br>
<br>
; i == 3: discriminator 0<br>
; i == 5: discriminator 2<br>
; return 100: discriminator 1<br>
; return 99: discriminator 3<br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp?rev=251680&r1=251679&r2=251680&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp?rev=251680&r1=251679&r2=251680&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp Thu Oct 29 21:38:29 2015<br>
@@ -180,7 +180,7 @@ bool AddDiscriminators::runOnFunction(Fu<br>
       BasicBlock *Succ = Last->getSuccessor(I);<br>
       Instruction *First = Succ->getFirstNonPHIOrDbgOrLifetime();<br>
       const DILocation *FirstDIL = First->getDebugLoc();<br>
-      if (!FirstDIL)<br>
+      if (!FirstDIL || FirstDIL->getDiscriminator())<br>
         continue;<br>
<br>
       // If the first instruction (First) of Succ is at the same file<br>
@@ -202,21 +202,22 @@ bool AddDiscriminators::runOnFunction(Fu<br>
         unsigned Discriminator = FirstDIL->computeNewDiscriminator();<br>
         auto *NewScope =<br>
             Builder.createLexicalBlockFile(Scope, File, Discriminator);<br>
-        auto *NewDIL =<br>
-            DILocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),<br>
-                            NewScope, FirstDIL->getInlinedAt());<br>
-        DebugLoc newDebugLoc = NewDIL;<br>
<br>
         // Attach this new debug location to First and every<br>
         // instruction following First that shares the same location.<br>
         for (BasicBlock::iterator I1(*First), E1 = Succ->end(); I1 != E1;<br>
              ++I1) {<br>
-          if (I1->getDebugLoc().get() != FirstDIL)<br>
-            break;<br>
-          I1->setDebugLoc(newDebugLoc);<br>
-          DEBUG(dbgs() << NewDIL->getFilename() << ":" << NewDIL->getLine()<br>
-                       << ":" << NewDIL->getColumn() << ":"<br>
-                       << NewDIL->getDiscriminator() << *I1 << "\n");<br>
+          const DILocation *CurrentDIL = I1->getDebugLoc();<br>
+          if (CurrentDIL && CurrentDIL->getLine() == FirstDIL->getLine() &&<br>
+              CurrentDIL->getFilename() == FirstDIL->getFilename()) {<br>
+            I1->setDebugLoc(DILocation::get(Ctx, CurrentDIL->getLine(),<br>
+                                            CurrentDIL->getColumn(), NewScope,<br>
+                                            CurrentDIL->getInlinedAt()));<br>
+            DEBUG(dbgs() << CurrentDIL->getFilename() << ":"<br>
+                         << CurrentDIL->getLine() << ":"<br>
+                         << CurrentDIL->getColumn() << ":"<br>
+                         << CurrentDIL->getDiscriminator() << *I1 << "\n");<br>
+          }<br>
         }<br>
         DEBUG(dbgs() << "\n");<br>
         Changed = true;<br>
<br>
Added: llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll?rev=251680&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll?rev=251680&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll (added)<br>
+++ llvm/trunk/test/Transforms/AddDiscriminators/oneline.ll Thu Oct 29 21:38:29 2015<br>
@@ -0,0 +1,98 @@<br>
+; RUN: opt < %s -add-discriminators -S | FileCheck %s<br>
+<br>
+; Discriminator support for code that is written in one line:<br>
+; #1 int foo(int i) {<br>
+; #2   if (i == 3 || i == 5) return 100; else return 99;<br>
+; #3 }<br>
+<br>
+; i == 3:     discriminator 0<br>
+; i == 5:     discriminator 2<br>
+; return 100: discriminator 1<br>
+; return 99:  discriminator 3<br>
+<br>
+define i32 @_Z3fooi(i32 %i) #0 {<br>
+  %1 = alloca i32, align 4<br>
+  %2 = alloca i32, align 4<br>
+  store i32 %i, i32* %2, align 4, !tbaa !13<br>
+  call void @llvm.dbg.declare(metadata i32* %2, metadata !9, metadata !17), !dbg !18<br>
+  %3 = load i32, i32* %2, align 4, !dbg !19, !tbaa !13<br>
+  %4 = icmp eq i32 %3, 3, !dbg !21<br>
+  br i1 %4, label %8, label %5, !dbg !22<br>
+<br>
+; <label>:5                                       ; preds = %0<br>
+  %6 = load i32, i32* %2, align 4, !dbg !23, !tbaa !13<br>
+; CHECK:  %6 = load i32, i32* %2, align 4, !dbg ![[THEN1:[0-9]+]],{{.*}}<br>
+<br>
+  %7 = icmp eq i32 %6, 5, !dbg !24<br>
+; CHECK:  %7 = icmp eq i32 %6, 5, !dbg ![[THEN2:[0-9]+]]<br>
+<br>
+  br i1 %7, label %8, label %9, !dbg !25<br>
+; CHECK:  br i1 %7, label %8, label %9, !dbg ![[THEN3:[0-9]+]]<br>
+<br>
+; <label>:8                                       ; preds = %5, %0<br>
+  store i32 100, i32* %1, align 4, !dbg !26<br>
+; CHECK: store i32 100, i32* %1, align 4, !dbg ![[ELSE:[0-9]+]]<br>
+<br>
+  br label %10, !dbg !26<br>
+; CHECK: br label %10, !dbg ![[ELSE]]<br>
+<br>
+; <label>:9                                       ; preds = %5<br>
+  store i32 99, i32* %1, align 4, !dbg !27<br>
+; CHECK: store i32 99, i32* %1, align 4, !dbg ![[COMBINE:[0-9]+]]<br>
+<br>
+  br label %10, !dbg !27<br>
+; CHECK: br label %10, !dbg ![[COMBINE]]<br>
+<br>
+; <label>:10                                      ; preds = %9, %8<br>
+  %11 = load i32, i32* %1, align 4, !dbg !28<br>
+  ret i32 %11, !dbg !28<br>
+}<br>
+<br>
+; Function Attrs: nounwind readnone<br>
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1<br>
+<br>
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
+attributes #1 = { nounwind readnone }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!10, !11}<br>
+!llvm.ident = !{!12}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 250915)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)<br>
+!1 = !DIFile(filename: "a.cc", directory: "/usr/local/google/home/dehao/discr")<br>
+!2 = !{}<br>
+!3 = !{!4}<br>
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, function: i32 (i32)* @_Z3fooi, variables: !8)<br>
+!5 = !DISubroutineType(types: !6)<br>
+!6 = !{!7, !7}<br>
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
+!8 = !{!9}<br>
+!9 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 1, type: !7)<br>
+!10 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!11 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!12 = !{!"clang version 3.8.0 (trunk 250915)"}<br>
+!13 = !{!14, !14, i64 0}<br>
+!14 = !{!"int", !15, i64 0}<br>
+!15 = !{!"omnipotent char", !16, i64 0}<br>
+!16 = !{!"Simple C/C++ TBAA"}<br>
+!17 = !DIExpression()<br>
+!18 = !DILocation(line: 1, column: 13, scope: !4)<br>
+!19 = !DILocation(line: 2, column: 7, scope: !20)<br>
+!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 7)<br>
+!21 = !DILocation(line: 2, column: 9, scope: !20)<br>
+!22 = !DILocation(line: 2, column: 14, scope: !20)<br>
+!23 = !DILocation(line: 2, column: 17, scope: !20)<br>
+!24 = !DILocation(line: 2, column: 19, scope: !20)<br>
+!25 = !DILocation(line: 2, column: 7, scope: !4)<br>
+!26 = !DILocation(line: 2, column: 25, scope: !20)<br>
+!27 = !DILocation(line: 2, column: 42, scope: !20)<br>
+!28 = !DILocation(line: 3, column: 1, scope: !4)<br>
+<br>
+; CHECK: ![[THEN1]] = !DILocation(line: 2, column: 17, scope: ![[THENBLOCK:[0-9]+]])<br>
+; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 2)<br>
+; CHECK: ![[THEN2]] = !DILocation(line: 2, column: 19, scope: ![[THENBLOCK]])<br>
+; CHECK: ![[THEN3]] = !DILocation(line: 2, column: 7, scope: ![[THENBLOCK]])<br>
+; CHECK: ![[ELSE]] = !DILocation(line: 2, column: 25, scope: ![[ELSEBLOCK:[0-9]+]])<br>
+; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 1)<br>
+; CHECK: ![[COMBINE]] = !DILocation(line: 2, column: 42, scope: ![[COMBINEBLOCK:[0-9]+]])<br>
+; CHECK: ![[COMBINEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 3)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>