<div dir="ltr"><br><div class="gmail_extra">On Mon, Apr 22, 2013 at 10:41 AM, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@google.com" target="_blank">eliben@google.com</a>></span> wrote:<br><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Mon, Apr 22, 2013 at 10:20 AM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Eli,<div><br></div><div>What is the specific problem here?  Is the cost to compute this too high, or is the symbol requested for the same MBB multiple times?  If it is the latter, it should be enough to add a simple "MCSymbol*" cache to MBB.  This would be cleaner than adding a scratch buffer to MachineFunction.</div>

<div><br></div><div>-Chris<br><div><br></div></div></div></blockquote><div><br></div></div><div>Hi Chris,</div><div><br></div><div>My fix addresses the first problem: multiple MBBs in the same MF recomputing the same information, which is wasteful.</div>

<div>You're raising a good point that there may be another problem hiding here - this computation being done multiple times for a single MBB. In that case, a cache can be added, yes. I'll take a look if this is indeed a problem. In any case, the patch still addresses a slightly different problem of caching most of the computation between different MBBs.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>Eli</div></font></span></div></div></div></blockquote><div><br></div><div style>Hi Chris,</div><div style><br></div><div style>I did a bit more measuring, implementing also rudimentary caching of the MCSymbol as you suggested. The results suggest that a large part of the cost comes from symbol requests in the same MBB multiple times, and both solutions mitigate that (my original patch simply by virtue of making the computation much cheaper). The numbers are:</div>
<div style><br></div><div style>baseline runtime of all getSymbol calls combined (no patches): B</div><div style>with original (scratch buffer in MC) patch: ~0.75B</div><div style>with caching MCSymbol patch: ~0.75B</div>
<div style>with both patches: ~0.7B</div><div style><br></div><div style>Given this, do you think it's worth it to apply both patches? If not then I agree that caching MCSymbol is the cleaner way to go.</div><div style>
<br></div><div style>Eli</div><div style><br></div><div><br></div><div><br></div><div> </div></div></div></div>