<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-27 0:14 GMT+04:00 Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank" class="cremed">echristo@gmail.com</a>></span>:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Wed, Mar 26, 2014 at 1:00 PM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" target="_blank" class="cremed">timurrrr@google.com</a>> wrote:<br>



><br>
><br>
><br>
> 2014-03-26 19:24 GMT+04:00 David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="cremed">dblaikie@gmail.com</a>>:<br>
><br>
>> On Wed, Mar 26, 2014 at 4:24 AM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" target="_blank" class="cremed">timurrrr@google.com</a>><br>
>> wrote:<br>
>> > Author: timurrrr<br>
>> > Date: Wed Mar 26 06:24:36 2014<br>
>> > New Revision: 204795<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=204795&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=204795&view=rev</a><br>
>> > Log:<br>
>> > Follow-up to r204790: don't try to emit line tables if there are no<br>
>> > functions with DI in the TU<br>
>><br>
>> Hmm - is there any better way to do this? Should we only be building<br>
>> line tables for those functions with DI? Then we'd just emit line<br>
>> tables if we have any (non-empty) line tables to emit, right?<br>
><br>
><br>
> Is there a handy function available for that? :)<br>
><br>
<br>
</div>From DwarfDebug::beginFunction:<br>
<br>
  // If there's no debug info for the function we're not going to do<br>
anything.<br>
  if (!MMI->hasDebugInfo())<br>
    return;<br>
<br>
  // Grab the lexical scopes for the function, if we don't have any of<br>
those<br>
  // then we're not going to be able to do anything.<br>
  LScopes.initialize(*MF);<br>
  if (LScopes.empty())<br>
    return;<br>
<br>
-eric</blockquote><div><br></div><div>This is almost exactly the beginning of WinCodeViewLineTables::beginFunction() as of yesterday :)</div><div>So yes, I'm aware of this and I do/did use it.</div><div><br></div><div>

However, IIUC it turns out that "if we don't have any [lexical scopes] then we're not going to be able to do anything" we still can emit minimal DI for a function. [see r204790 + r204791]</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>
>> I assume these COFF line tables don't actually get referenced from any<br>
>> other debug info (since the rest of our info is DWARF), but I've been<br>
>> thinking of cleaning up our other line table handling code a bit so<br>
>> that it's a bit more structured - letting the line table object itself<br>
>> decide whether it should be emitted (by virtue of being non-empty) and<br>
>> then having line table clients (CUs in DwarfDebug - no analogy for<br>
>> COFF which has no line table client) query the line table to see if<br>
>> it'll be there and attach the DW_AT_stmt_list if there will be a line<br>
>> table.<br>
>><br>
>> - David<br>
>><br>
>> ><br>
>> > Added:<br>
>> >     llvm/trunk/test/DebugInfo/COFF/asan2.ll<br>
>> > Modified:<br>
>> >     llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp<br>
>> ><br>
>> > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp?rev=204795&r1=204794&r2=204795&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp?rev=204795&r1=204794&r2=204795&view=diff</a><br>



>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp<br>
>> > (original)<br>
>> > +++ llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp Wed Mar<br>
>> > 26 06:24:36 2014<br>
>> > @@ -304,11 +304,18 @@ void WinCodeViewLineTables::beginFunctio<br>
>> >    }<br>
>> >  }<br>
>> ><br>
>> > -void WinCodeViewLineTables::endFunction(const MachineFunction *) {<br>
>> > +void WinCodeViewLineTables::endFunction(const MachineFunction *MF) {<br>
>> >    if (!Asm || !CurFn)  // We haven't created any debug info for this<br>
>> > function.<br>
>> >      return;<br>
>> ><br>
>> > -  if (!CurFn->Instrs.empty()) {<br>
>> > +  const Function *GV = MF->getFunction();<br>
>> > +  assert(FnDebugInfo.count(GV) == true);<br>
>><br>
>> "count == true" seems a bit confusing for a few reasons. Should that<br>
>> be either just "assert(x.count(y))" or "assert(x.count(y) != 0)" (or<br>
>> greater than zero or 1 or whatever). "== true" always reads as<br>
>> weird/redundant to me.<br>
>><br>
>> > +  assert(CurFn == &FnDebugInfo[GV]);<br>
>> > +<br>
>> > +  if (CurFn->Instrs.empty()) {<br>
>> > +    FnDebugInfo.erase(GV);<br>
>> > +    VisitedFunctions.pop_back();<br>
>> > +  } else {<br>
>> >      // Define end label for subprogram.<br>
>> >      MCSymbol *FunctionEndSym =<br>
>> > Asm->OutStreamer.getContext().CreateTempSymbol();<br>
>> >      Asm->OutStreamer.EmitLabel(FunctionEndSym);<br>
>> ><br>
>> > Added: llvm/trunk/test/DebugInfo/COFF/asan2.ll<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asan2.ll?rev=204795&view=auto" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asan2.ll?rev=204795&view=auto</a><br>



>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/test/DebugInfo/COFF/asan2.ll (added)<br>
>> > +++ llvm/trunk/test/DebugInfo/COFF/asan2.ll Wed Mar 26 06:24:36 2014<br>
>> > @@ -0,0 +1,52 @@<br>
>> > +; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -O0 < %s | FileCheck<br>
>> > --check-prefix=X86 %s<br>
>> > +<br>
>> > +; This LL file was generated by running clang on the following code<br>
>> > with<br>
>> > +; -fsanitize=address<br>
>> > +; D:\asan.c:<br>
>> > +; 1 unsigned char c = 42;<br>
>> > +<br>
>> > +; Just make sure we don't try to emit the line table.<br>
>> > +; X86-NOT: .section        .debug$S,"rn"<br>
>> > +<br>
>> > +; ModuleID = 'asan.c'<br>
>> > +target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"<br>
>> > +target triple = "i686-pc-win32"<br>
>> > +<br>
>> > +@c = global { i8, [63 x i8] } { i8 42, [63 x i8] zeroinitializer },<br>
>> > align 32<br>
>> > +@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32,<br>
>> > void ()* } { i32 1, void ()* @asan.module_ctor }]<br>
>> > +@__asan_gen_ = private constant [7 x i8] c"asan.c\00", align 1<br>
>> > +@__asan_gen_1 = private unnamed_addr constant [2 x i8] c"c\00", align 1<br>
>> > +@0 = internal global [1 x { i32, i32, i32, i32, i32, i32 }] [{ i32,<br>
>> > i32, i32, i32, i32, i32 } { i32 ptrtoint ({ i8, [63 x i8] }* @c to i32), i32<br>
>> > 1, i32 64, i32 ptrtoint ([2 x i8]* @__asan_gen_1 to i32), i32 ptrtoint ([7 x<br>
>> > i8]* @__asan_gen_ to i32), i32 0 }]<br>
>> > +@llvm.global_dtors = appending global [1 x { i32, void ()* }] [{ i32,<br>
>> > void ()* } { i32 1, void ()* @asan.module_dtor }]<br>
>> > +<br>
>> > +define internal void @asan.module_ctor() {<br>
>> > +  call void @__asan_init_v3()<br>
>> > +  call void @__asan_register_globals(i32 ptrtoint ([1 x { i32, i32,<br>
>> > i32, i32, i32, i32 }]* @0 to i32), i32 1)<br>
>> > +  ret void<br>
>> > +}<br>
>> > +<br>
>> > +declare void @__asan_init_v3()<br>
>> > +<br>
>> > +declare void @__asan_before_dynamic_init(i32)<br>
>> > +<br>
>> > +declare void @__asan_after_dynamic_init()<br>
>> > +<br>
>> > +declare void @__asan_register_globals(i32, i32)<br>
>> > +<br>
>> > +declare void @__asan_unregister_globals(i32, i32)<br>
>> > +<br>
>> > +define internal void @asan.module_dtor() {<br>
>> > +  call void @__asan_unregister_globals(i32 ptrtoint ([1 x { i32, i32,<br>
>> > i32, i32, i32, i32 }]* @0 to i32), i32 1)<br>
>> > +  ret void<br>
>> > +}<br>
>> > +<br>
>> > +!<a href="http://llvm.dbg.cu" target="_blank" class="cremed">llvm.dbg.cu</a> = !{!0}<br>
>> > +!llvm.module.flags = !{!3, !4}<br>
>> > +!llvm.ident = !{!5}<br>
>> > +<br>
>> > +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang<br>
>> > version 3.5.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2,<br>
>> > metadata !2, metadata !2, metadata !2, metadata !"", i32 2} ; [<br>
>> > DW_TAG_compile_unit ] [D:\/asan.c] [DW_LANG_C99]<br>
>> > +!1 = metadata !{metadata !"asan.c", metadata !"D:\5C"}<br>
>> > +!2 = metadata !{}<br>
>> > +!3 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}<br>
>> > +!4 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}<br>
>> > +!5 = metadata !{metadata !"clang version 3.5.0 "}<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > llvm-commits mailing list<br>
>> > <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
>> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div></blockquote></div><br></div></div>