<div>I did some investigation into some sizes, with the following results.</div>
<div> </div>
<div>First some sizes of the items using vector:</div>
<div> </div>
<div>ConstraintString = =*m,*m,~{dirflag},~{fpsr},~{flags}<br>visitInlineAsm stack size = 2120</div>
<div>sizeof(SDISelAsmOperandInfo) = 240<br>sizeof(AsmOperandInfo) = 104<br>sizeof(ConstraintInfo) = 56</div>
<div>vector<*> = 20</div>
<div> </div>
<div>Next with some reduced SmallVector sizes:</div>
<div> </div>
<div>
<div>
<div>ConstraintString = =*m,*m,~{dirflag},~{fpsr},~{flags}<br>visitInlineAsm stack size = 14480</div>
<div>sizeof(SDISelAsmOperandInfo) = 672<br>sizeof(AsmOperandInfo) = 536<br>sizeof(ConstraintInfo) = 488</div></div>
<div>sizeof(SmallVector<SDISelAsmOperandInfo,5>) = 3376<br>sizeof(SmallVector<AsmOperandInfo,5>) = 2696<br>sizeof(SmallVector<ConstraintInfo,5>) = 2456<br>sizeof(SmallVector<SubConstraintInfo,2>) = 320<br>
sizeof(SmallVector<std::string,4>) = 144</div>
<div> </div>
<div>Note that I picked 5 for the main size for the constraint info structures because with x86, the 3 clobbers always make the total constraint info count 5, and we want the typical case to not cause the SmallVector to switch to dynamic.</div>

<div> </div>
<div>Finally with the original SmallVector sizes:</div>
<div> </div>
<div>ConstraintString = =*m,*m,~{dirflag},~{fpsr},~{flags}<br>stackSize = 53024 
<div>sizeof(SDISelAsmOperandInfo) = 1616<br>sizeof(AsmOperandInfo) = 1480<br>sizeof(ConstraintInfo) = 1432</div>
<div>sizeof(SmallVector<SDISelAsmOperandInfo,16>) = 25872<br>sizeof(SmallVector<AsmOperandInfo,16>) = 23696<br>sizeof(SmallVector<ConstraintInfo,16>) = 22928<br>sizeof(SmallVector<SubConstraintInfo,4>) = 1136<br>
sizeof(SmallVector<std::string,8>) = 272</div></div></div>
<div> </div>
<div>To approximate the stack frame size I used the difference between call arguments in a run of a debug-built llc, i.e.</div>
<div> </div>
<div>void dumpSizes(void *stackRefInner)</div>
<div>{</div>
<div>    printf("visitInlineAsm stack size = %d\n", (char*)stackRefInner - (char*)&stackRefInner);</div>
<div>}</div>
<div> </div>
<div>void SelectionDAGBuilder::visitInlineAsm(ImmutableCallSite CS) {</div>
<div>    dumpSizes(&CS);</div>
<div>...}</div>
<div> </div>
<div> </div>
<div>Question 1:</div>
<div> </div>
<div>From the above, it appears that reducing the SmallVector sizes to the intermediate size used will get the visitInline stack frame size down to a bit less than 16K.  So, would having the still somewhat largish 14.5K stack frame be better than having the dynamic allocations otherwise done with vector?  I'm thinking yes, because the heap activity is probably slower and fragments memory.</div>

<div> </div>
<div>Question 2:</div>
<div> </div>
<div>If we wanted to look deeper into this, we'd probably want to look at timing and heap activity.  I see that there is a Timer class that could be used for measuring timing.  I didn't see a mechanism for tracking memory usage, i.e the total allocations and frees, and peak memory usage.  Is there something like this in there?</div>

<div> </div>
<div>-John</div>
<div><br> </div>
<div class="gmail_quote">On Fri, Oct 29, 2010 at 3:47 PM, John Thompson <span dir="ltr"><<a href="mailto:john.thompson.jtsoftware@gmail.com" target="_blank">john.thompson.jtsoftware@gmail.com</a>></span> wrote:<br>

<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>If stack space is of concern, I think it would be safer to go back to vector.  Using vector will mean more heap allocations, but the overall memory usage would probably be less.</div>
<div> </div>
<div>How do you measure the stack space (i.e. is there a simple way besides inspection in the debugger)?  I'd like to measure both.<br></div><font color="#888888">
<div>-John<br></div></font>
<div>
<div></div>
<div>
<div class="gmail_quote">On Fri, Oct 29, 2010 at 2:22 PM, Dale Johannesen <span dir="ltr"><<a href="mailto:dalej@apple.com" target="_blank">dalej@apple.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div style="WORD-WRAP: break-word">Interesting.  It's true very small sizes are most common for these vectors, but I wouldn't have expected the overhead to be that significant.  Perhaps try lowering all the fixed allocations to 4? 
<div>
<div><br>
<div>
<div>On Oct 29, 2010, at 2:10 PMPDT, Nick Lewycky wrote:</div><br>
<blockquote type="cite"><span style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px">On 29 October 2010 10:29, John Thompson<span> </span><span dir="ltr"><<a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a>></span><span> </span>wrote:<br>

<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Author: jtsoftware<br>Date: Fri Oct 29 12:29:13 2010<br>New Revision: 117667<br><br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=117667&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=117667&view=rev</a><br>
Log:<br>Inline asm multiple alternative constraints development phase 2 - improved basic logic, added initial platform support.<br></blockquote>
<div><br></div>
<div>This change makes SelectionDAGBuilder::visitInlineAsm use up 30k of stack space, largely due to the switch from std::vector to SmallVector. Please fix!</div></span></blockquote></div><br></div></div></div></blockquote>
</div><br><br clear="all"><br></div></div>-- <br>
<div>
<div></div>
<div>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a><br><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a><br>
<br>