<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 4, 2013 at 1:52 PM, Puyan Lotfi <span dir="ltr"><<a href="mailto:plotfi@apple.com" target="_blank" class="cremed">plotfi@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><div>On Oct 4, 2013, at 10:43 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank" class="cremed">chandlerc@google.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 4, 2013 at 1:39 PM, Puyan Lotfi <span dir="ltr"><<a href="mailto:plotfi@apple.com" target="_blank" class="cremed">plotfi@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">I like this solution but do you think there should be some way to tell the library (optional parameter, or a separate API function) to use the argv data directly instead of allocating memory on the context. Seems like it would be good to not hurt performance of the common case.<br>

</div></blockquote><div><br></div><div>I don't think there is a common case where performance is a concern. Why?</div><div><br></div><div>1) We're parsing commandline flags in an inherently race-prone way, and for flags which are explicitly for debugging and custom manipulations only.</div>

<div>2) It can only happen once per LLVMContext spin up / tear down</div><div><br></div></div></div></div></blockquote><div><br></div></div><div>I mean the common case where ParseCommandLineOptions is being called from main and being passed argv directly. Wouldn’t it be better to not allocate duplicates inside LLVMContext in this case? But yeah, otherwise I like the idea of putting strings into LLVMContext.</div>
</blockquote></div><br>The question to ask here is what problem does it solve.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If it is being called from main, it will be called exactly once per execution. That means that it will do at most a number of allocations corresponding to the number of command line arguments passed to the binary. I think that malloc overhead is not worth *any* complexity in the system, and certainly not a bug-prone interface.</div>
</div>