Yes, running SafeStack with opt would certainly simplify debugging. However, we want to apply the SafeStack transformation as the very last step before code generation, to make sure that it operate on the final stack layout. Doing so earlier might prevent some other optimizations from succeeding (as it e.g., complicates the alias analysis, breaks mem2reg pass, etc.) or might force the SafeStack pass move more objects to the unsafe stack than necessary (e.g., if the operations on such objects that the SafeStack considered potentially unsafe are actually later optimized away). In principle, in some pathological cases, it might even break correctness, e.g., if the SafeStack decides to keep some object on the normal stack, but the subsequent optimization or instrumentation passes add potentially unsafe operations on such objects.<br><br><div class="gmail_quote">On Tue Nov 04 2014 at 12:09:46 AM Kostya Serebryany <<a href="mailto:kcc@google.com">kcc@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am curious why you are doing transformations in CodeGen as opposed to LLVM IR?<br>
<br>
Note that AddressSanitizer has similar transformation done as an LLVM IR pass (i.e. 'opt', not 'llc')<br>
which makes testing much simpler (IMHO) and not x86-dependent.<br>
See FunctionStackPoisoner::<u></u>poisonStack in lib/Transforms/<u></u>Instrumentation/<u></u>AddressSanitizer.cpp<br>
<br>
<a href="http://reviews.llvm.org/D6094" target="_blank">http://reviews.llvm.org/D6094</a><br>
<br>
<br>
</blockquote></div>