<div class="gmail_quote">On Wed, Sep 23, 2009 at 1:04 PM, 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="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Tue, Sep 22, 2009 at 4:49 PM, Talin <<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <<a href="mailto:devang.patel@gmail.com">devang.patel@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <<a href="mailto:devang.patel@gmail.com">devang.patel@gmail.com</a>><br>
>> wrote:<br>
<div><div></div><div class="h5">>> > On Tue, Sep 22, 2009 at 12:14 AM, Talin <<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>> wrote:<br>
>> >> So, one feature of the late, lamented DebugInfoBuilder that I am<br>
>> >> missing<br>
>> >> quite badly, and which is not available in the current DIFactory, is<br>
>> >> the<br>
>> >> ability to specify structure offsets abstractly. The DebugFactory<br>
>> >> requires that you pass in structure offset information as ints, whereas<br>
>> >> DebugInfoBuilder had "offsetOf" and "alignOf" methods, similar to the<br>
>> >> "sizeOf" trick, that would create the constants for you in a way that<br>
>> >> didn't require your front end to know the sizes of things. So far I've<br>
>> >> been able to avoid having any references to target machines in my<br>
>> >> frontend, but now that I am trying to flesh out my debug info more<br>
>> >> fully<br>
>> >> I'm finding it hard to use DIFactory as-is.<br>
>> >><br>
>> >> What I'd like to see is a set of alternative factory methods in<br>
>> >> DIFactory, where you pass in an LLVM type, and possibly a GEP index,<br>
>> >> plus all of the parameters that it can't figure out from looking at the<br>
>> >> type. So you can eliminate the offset, size, and alignment parameters<br>
>> >> since those can be figured out from the type.<br>
>> ><br>
</div></div>>> > Is it true that DIFactory can figure this out with Target info in all<br>
>> > cases ?<br>
>><br>
>> oops... I meant to say "... without Target info..."<br>
>><br>
> // Calculate the size of the specified LLVM type.<br>
> Constant * DebugInfoBuilder::getSize(const Type * type) {<br>
> Constant * one = ConstantInt::get(Type::Int32Ty, 1);<br>
> return ConstantExpr::getPtrToInt(<br>
> ConstantExpr::getGetElementPtr(<br>
> ConstantPointerNull::get(PointerType::getUnqual(type)),<br>
> &one, 1), Type::Int32Ty);<br>
> }<br>
><br>
> Constant * DebugInfoBuilder::getAlignment(const Type * type) {<br>
> // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)"<br>
> return ConstantExpr::getSub(<br>
> getSize(StructType::get(Type::Int8Ty, type, NULL)),<br>
> getSize(type));<br>
> }<br>
><br>
> This was code that was checked in before DebugInfoBuilder was replaced by<br>
> DIFactory.<br>
<br>
This adds code to find the info that FE knows anyway. That is<br>
undesirable IMO. If there is a need, you can do this trick in your FE.<br>
<br></blockquote><div>Eh? My point is that the FE *doesn't* know this information. A platform-agnostic FE doesn't know how many bits are in a pointer, for example. By using this code, the knowledge of how big fields are can be deferred until the target is selected.</div>
<div><br></div><div>In other words - with the old code, I could generate valid DWARF debugging information without having a target selected. With the new code, I'm required to select a target before I can generate debug info.<br>
</div></div>-- <br>-- Talin<br>