<br><br><div class="gmail_quote">On Wed, Dec 2, 2009 at 10:04 AM, Devang Patel <span dir="ltr"><<a href="mailto:devang.patel@gmail.com">devang.patel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On Tue, Dec 1, 2009 at 10:56 PM, Talin <<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>> wrote:<br>
> So, based on the info that I got from Devang, I was able to solve the<br>
> problem with the duplicate assembly symbols, although I still don't quite<br>
> understand why it was generating erroneous metadata in the first place. For<br>
> example, through trial and error I discovered that the problem disappeared<br>
> if I passed my DICompileUnit to CreateLocation() rather than my<br>
> DISubprogram, but I don't know why.<br>
<br>
The immediate lexical scope covering the location is the right answer.<br>
Is your DISubprogram describing correct function ?<br></blockquote><div><br>I am pretty sure that it is - I've double checked the code and looked at the IR output. I did have a problem earlier where purely synthetic functions (trampoline functions generated by the compiler and so on) were being generated with the wrong DISubprogram (it wasn't reset from the previous function), and while that did cut down on the number of problems, it didn't completely eliminate them.<br>

</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
> The new API introduces a number of new parameters in DIFactory where I am<br>
> not sure what the correct value to pass is. CreateLocation() is one example<br>
> - I don't know if the context should be the compile unit, or the<br>
> subprogram/region. The latter makes more sense, but is somewhat inconvenient<br>
> in the face of templates, macros, where you have generated code within a<br>
> function whose original source lines are from a different source file. It<br>
> means that a source location (which is attached to every expression node)<br>
> can't consist of merely [file, offset, length] but now has to carry other<br>
> contextual baggage around as well, since conceivably any subtree of an<br>
> expression could originate from outside the function.<br>
<br>
DWARF specification describes how to  handle macros and we are not at<br>
all attempting to encode macros. However, we have a way (recently<br>
introduced) way to encode situation where code from original source<br>
code is found at another location.<br>
<br>
The fourth parameter in DILocation describes location where the code<br>
is copied/expanded. For example, if you have code at line no. 21 from<br>
source file A which is copied (or expanded) at line no. 41 in source<br>
file B and line no. 51 in source file C then<br>
<br>
!1 = ... CompileUnit for source file A<br>
!2 = ... CompileUnit for source file B<br>
!3 = ... CompileUnit for source file C<br>
<br>
!11 = metadata !{i32 21, i32 0, metadata !1, null }  ;  <-- Original<br>
location of the code<br>
...<br>
!21 = metadata !{i32 41, i32 0, metadata !2, null }  ;  <--- source<br>
location in file  B<br>
!22 = metadata !{i32 21, i32 0, metadata !1, !21 }  ;   <--- Code from<br>
A:21 is copied at B:41<br>
...<br>
!31 = metadata !{i32 51, i32 0, metadata !3, null }  ;  <--- source<br>
location in file  B<br>
!32 = metadata !{i32 21, i32 0, metadata !1, !31 }  ;   <--- Code from<br>
A:21 is copied at C:51<br>
<br>
[ Here !1, !2 and !3 may refer to appropriate DISubprogram or DILexicalBlock. ]<br></blockquote><div><br>Right, I saw that, and planned on using it - the explanation you give is helpful.<br><br>I want to make sure I understand the relationship between line number and context. If I have a DILocation that has a context that is not a compile unit, what is the line number relative to? My assumption is that it walks up the chain of contexts until it finds a compile unit, and the line number is relative to that.<br>

 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-<br>
Devang<br>
<br>
> Alternatively, passing<br>
> in the compile unit makes sense, except that now there's no way to tell the<br>
> IRBuilder about regions.<br>
> Also, even though my code now assembles correctly, gdb gets very unhappy<br>
> when I try to debug it - it prints<br>
> "/build/buildd/gdb-7.0/gdb/dwarf2-frame.c:983: internal-error: Unknown CFA<br>
> rule." and then asks me if I want to generate a core file of gdb.<br>
> --<br>
> -- Talin<br>
<div class="im">><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
<br>
<br>
<br>
</div>--<br>
-<br>
<font color="#888888">Devang<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>-- Talin<br>