<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">If you want to give programmers feedback at the source level, CLang is almost certainly a better choice.<br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Arial; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; "><br class="Apple-interchange-newline">--Vikram</span></font></span></div><div><font class="Apple-style-span" face="Arial"><i><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Associate Professor, Computer Science</span></font></i></font></div><div><font class="Apple-style-span" face="Arial"><i><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">University of Illinois at Urbana-Champaign</span></font></i></font></div><div><font class="Apple-style-span" face="Arial"><i><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; "><a href="http://llvm.org/~vadve">http://llvm.org/~vadve</a></span></font></i></font></div><div><font class="Apple-style-span" face="Arial" size="3"><span class="Apple-style-span" style="font-size: 12px; "><i><br></i></span></font></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></span></div></span></div></span><br class="Apple-interchange-newline"> </div><br><div><div>On Mar 27, 2009, at 10:25 AM, Anthony Danalis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Thanks Luke,<br><br>I was afraid that this would be the case.  I can see why this  <br>information is useless for most people/optimizations.<br>However, it is still useful if you are writing an analysis pass that  <br>is supposed to tell the developer things about her code, and you want  <br>the output messages to be human readable.<br><br>Regarding the "x" or "z" dilemma, I noticed that when you print the  <br>gep instruction, the generated string says "struct A" (or whatever the  <br>struct name really is), so all I would need beyond that is a list of  <br>structs and the names of their fields.  I do understand though that  <br>this is a very low priority feature for anybody to implement, and I  <br>since do not want to get involved with the front-end myself I will  <br>probably write an external perl script that given a struct name and an  <br>offset it returns a field name.<br><br>My question for the list is this:<br>Are there any optimizations that could change a struct type?  That is,  <br>could llvm deduce that the first field of a given struct is never used/ <br>defined and change the struct type (and all the offsets wherever they  <br>appear) so that this field does not exist anymore?  In other words, is  <br>it safe to do an external, trivial mapping from struct name+offset to  <br>field name, or are there optimizations that would break it?<br><br>thanks,<br>Anthony<br><br>On Mar 26, 2009, at 6:25 PM, Luke Dalessandro wrote:<br><br><blockquote type="cite">Anthony Danalis wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite">Hello,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I'm trying to construct a string like "a[1][x].y" in an optimization<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pass by digging deeper and deeper into a GetElementPtrInst.  I can<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">successfully deal with the array/pointer part, but when it comes to<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">the structure field name "y", I cannot figure out how to get anything<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">but the index into the structure.  Is there a way to do that, or is<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">this information discarded by llvm?<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">LLVM uses structural equivalence and uniqueing for types, so the<br></blockquote><blockquote type="cite">information that you are looking for isn't really relevant. For  <br></blockquote><blockquote type="cite">example,<br></blockquote><blockquote type="cite">if I have the following two types:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> struct A {<br></blockquote><blockquote type="cite">   int x, y;<br></blockquote><blockquote type="cite"> };<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> struct B {<br></blockquote><blockquote type="cite">   int z, w;<br></blockquote><blockquote type="cite"> };<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">They'll both become something like:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> { int, int }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">As you noticed, all the gep encodes is the offset into the type, so  <br></blockquote><blockquote type="cite">all<br></blockquote><blockquote type="cite">you know is that the access is to the first/second field of the  <br></blockquote><blockquote type="cite">type. It<br></blockquote><blockquote type="cite">wouldn't make sense to have a name for it because you wouldn't know if<br></blockquote><blockquote type="cite">the first field was called "x" or "z" anyway. I could imagine some  <br></blockquote><blockquote type="cite">front<br></blockquote><blockquote type="cite">end work that might embed information that you would need to  <br></blockquote><blockquote type="cite">reconstruct<br></blockquote><blockquote type="cite">this, but I imagine it would take some doing.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Hope this helps,<br></blockquote><blockquote type="cite">Luke<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">thanks,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Anthony<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">_______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">LLVM Developers mailing list<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">LLVMdev@cs.uiuc.edu         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">LLVM Developers mailing list<br></blockquote><blockquote type="cite">LLVMdev@cs.uiuc.edu         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br></blockquote><blockquote type="cite"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote><br>_______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></body></html>