<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-26 19:24 GMT+04:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank" class="cremed">dblaikie@gmail.com</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Wed, Mar 26, 2014 at 4:24 AM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" class="cremed">timurrrr@google.com</a>> 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 functions with DI in the TU<br>
<br>
</div>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></blockquote><div><br></div><div>Is there a handy function available for that? :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


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>
<div class=""><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: <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>
> --- llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp Wed Mar 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 function.<br>
>      return;<br>
><br>
> -  if (!CurFn->Instrs.empty()) {<br>
> +  const Function *GV = MF->getFunction();<br>
> +  assert(FnDebugInfo.count(GV) == true);<br>
<br>
</div>"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>
<div class="HOEnZb"><div class="h5"><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 = Asm->OutStreamer.getContext().CreateTempSymbol();<br>
>      Asm->OutStreamer.EmitLabel(FunctionEndSym);<br>
><br>
> Added: llvm/trunk/test/DebugInfo/COFF/asan2.ll<br>
> URL: <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>
> --- 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 --check-prefix=X86 %s<br>
> +<br>
> +; This LL file was generated by running clang on the following code 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 }, align 32<br>
> +@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, 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, i32, i32, i32, i32, i32 } { i32 ptrtoint ({ i8, [63 x i8] }* @c to i32), i32 1, i32 64, i32 ptrtoint ([2 x i8]* @__asan_gen_1 to i32), i32 ptrtoint ([7 x i8]* @__asan_gen_ to i32), i32 0 }]<br>


> +@llvm.global_dtors = appending global [1 x { i32, void ()* }] [{ i32, 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, 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, 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 version 3.5.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !2, metadata !2, metadata !2, metadata !"", i32 2} ; [ 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" 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>
</div></div></blockquote></div><br></div></div>