<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 30, 2009, at 12:01 PM, Villmow, Micah wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="address">
<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">
<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>



<div lang="EN-US" link="blue" vlink="purple">

<div class="Section1"><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">I am running into an issue where if I have multiple
functions compiled in the same compilation unit the stack offset is not
starting at zero. For example:<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">func1(…)<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">{<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">…<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">}<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">func2(…)<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">{<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">…<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">}<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Say the first function uses 64 bytes of the stack and an
assumed offset of 0 and the second function uses 32 bytes of the stack but an
assumed offset of 64. I’ve found out how to get the size of the stack via
MachineFrameInfo.StackSize/getObjectSize, however I have not found out how to
determine the starting offset of the stack for that specific function. I need
this information so that I can offset my stack pointer correctly since all my
indices into my stack need to start at 0 for each independent function call. <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">So, what this means is that if I call func1 or func2 I need
to make sure all offsets into the stack start at zero.</span></font></p></div></div></o:smarttagtype></o:smarttagtype></o:smarttagtype></blockquote><div><br></div>Micah, stack offset is always relative to the stack pointer which is unchanged in the function unless you have dynamic stack allocation. So from the compiler's point of view, the starting offset for a function is always zero.</div><div><br></div><div>Evan</div><div><br><blockquote type="cite"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="address"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"><div lang="EN-US" link="blue" vlink="purple"><div class="Section1"><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Thanks for any tips/hints, <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Micah Villmow<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Systems Engineer<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Advanced Technology & Performance<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Advanced Micro Devices Inc.<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><ns0:street w:insauthor="Micah Villmow" w:insdate="2009-03-30T11:47:00Z" w:endinsauthor="Micah Villmow" w:endinsdate="2009-03-30T11:47:00Z"><ns0:address w:insauthor="Micah Villmow" w:insdate="2009-03-30T11:47:00Z" w:endinsauthor="Micah Villmow" w:endinsdate="2009-03-30T11:47:00Z">S1-609 One AMD Place</ns0:address></ns0:street></span></font><o:p></o:p></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><ns0:place w:insauthor="Micah Villmow" w:insdate="2009-03-30T11:47:00Z" w:endinsauthor="Micah Villmow" w:endinsdate="2009-03-30T11:47:00Z"><ns0:city w:insauthor="Micah Villmow" w:insdate="2009-03-30T11:47:00Z" w:endinsauthor="Micah Villmow" w:endinsdate="2009-03-30T11:47:00Z"><st1:city w:st="on"><st1:place w:st="on">Sunnyvale</st1:place></st1:city></ns0:city></ns0:place>,
CA. 94085</span></font><o:p></o:p></p><p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">P: 408-749-3966</span></font><o:p></o:p></p><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:
12.0pt"> </span></font><font size="2" face="Arial"><span style="font-size:
10.0pt;font-family:Arial"><o:p></o:p></span></font></p><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:
12.0pt"><o:p> </o:p></span></font></p>

</div>

</div>


_______________________________________________<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">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></o:smarttagtype></o:smarttagtype></o:smarttagtype></blockquote></div><br></body></html>