<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><br><div class="gmail_quote">On Wed, Nov 28, 2012 at 3:22 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.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="font-family:arial,helvetica,sans-serif;font-size:10pt"><br><br><div class="gmail_quote"><div class="im">On Wed, Nov 28, 2012 at 10:28 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Ok. Kostya, what is your opinion?<br></blockquote><div><br></div></div><div>On which part? I like the flags.</div></div></div></blockquote><div><br></div><div>Ok.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="gmail_quote">As for "-mllvm -asan-foo" vs createAddressSanitizerPass flags I have mixed feelings. </div><div class="gmail_quote">
If we use createAddressSanitizerPass flags, what should be the behavior when "-mllvm -asan-foo" is given separately? </div></div></blockquote><div><br></div><div><div>I think that explicit -mllvm -asan-use-after-return=0 should override "-fsanitize=use-after-return" option (questionable).</div>
<div>Anyway, I think we should discourage users to use -mllvm flags. BTW, if we will add "-mllvm -asan-use-after-return" flag in</div><div>clang Driver, then the line "-fsanitize=use-after-return -mllvm -asan-use-after-return=1" will produce a compiler error, stating that</div>
<div>"-asan-use-after-return" option can be present 0 or 1 times. So, I think that we should follow Richard's suggestion.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="gmail_quote">What are other phases doing in similar situations (or we are doing something unique)? </div></div></blockquote><div><br></div><div>
GCOV profiler added in clang's BackendUtil is configured from CodeGenOpts:</div><div><div>if (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes) {</div><div> MPM->add(createGCOVProfilerPass(CodeGenOpts.EmitGcovNotes, CodeGenOpts.EmitGcovArcs, TargetTriple.isMacOSX()));</div>
</div><div>with the declaration:</div><div><div> ModulePass *createGCOVProfilerPass(bool EmitNotes = true, bool EmitData = true, bool Use402Format = false, bool UseExtraChecksum = false);</div></div><div><br></div><div>We may do smth similar for ASan.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="gmail_quote"><span style="font-family:arial;font-size:small"> </span></div>
</div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="gmail_quote">
<div> </div><div><br></div><div>--kcc </div><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
<br>
================<br>
Comment at: lib/Driver/Tools.cpp:1518-1523<br>
@@ -1517,1 +1517,8 @@<br>
</div><div>+<br>
+ // If -fsanitize contains extra features of ASan, it should also<br>
+ // explicitly contain -fsanitize=address.<br>
+ if (NeedsAsan && ((Kind & Address) == 0))<br>
+ D.Diag(diag::err_drv_argument_only_allowed_with)<br>
+ << describeSanitizeArg(Args, AsanArg, NeedsAsanRt)<br>
+ << "-fsanitize=address";<br>
}<br>
</div>----------------<br>
<div>Richard Smith wrote:<br>
> For argument lists like "-fsanitize=use-after-return -fsanitize=address -fno-sanitize=address", we'll say "-fsanitize=address is only allowed with -fsanitize=address". The existing diagnostic has a similar issue for "-fsanitize=address -fsanitize=alignment -fsanitize=vptr -fno-sanitize=vptr", where it says "-fsanitize=vptr not allowed with -fsanitize=address". I think we'd need to teach describeSanitizerArg to re-parse the argument list to handle this properly.<br>
</div>RIght, the logic is untrivial here. Mailed D143 to fix this.<br>
<div><br>
================<br>
Comment at: lib/Driver/SanitizerArgs.h:59-71<br>
@@ -58,1 +58,15 @@<br>
</div><div>+<br>
+ // Add args for LLVM backend.<br>
+ if (Kind & InitOrder) {<br>
+ CmdArgs.push_back("-mllvm");<br>
+ CmdArgs.push_back("-asan-initialization-order");<br>
+ }<br>
+ if (Kind & UseAfterReturn) {<br>
+ CmdArgs.push_back("-mllvm");<br>
+ CmdArgs.push_back("-asan-use-after-return");<br>
+ }<br>
+ if (Kind & UseAfterScope) {<br>
+ CmdArgs.push_back("-mllvm");<br>
+ CmdArgs.push_back("-asan-use-lifetime");<br>
+ }<br>
}<br>
</div>----------------<br>
<div>Richard Smith wrote:<br>
> I would prefer this to be handled by the frontend instead of by the driver (the frontend is responsible for adding all the other IR instrumentation, including adding the ASan passes).<br>
><br>
> Have you considered passing these flags to ASan when creating the passes in addAddressSanitizerPass, rather than as command-line options?<br>
</div>Hm, passing arguments to createAddressSanitizerPass() certainly seems a better (though, more intrusive) solution than playing with -mllvm flags. I'll work on that.<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D142" target="_blank">http://llvm-reviews.chandlerc.com/D142</a><br>
</blockquote></div></div></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div>