<div class="gmail_quote">On Thu, Dec 15, 2011 at 5:14 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com">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">
<br><br><div class="gmail_quote"><div class="im">On Thu, Dec 15, 2011 at 4:45 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@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 class="gmail_quote"><div>On Thu, Dec 15, 2011 at 4:25 PM, 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>yea, agree. </div><div>asan currently (almost) lacks this kind of testing and we will need to add more tests (not just this one). </div></blockquote><div><br></div></div><div>I understand. It's useful for reviewers as well when fixing bugs to include at least the test for that fix, as it helps document exactly what the end result should be. Might be a good place to start fleshing out the test suite.</div>

</div></blockquote><div><br></div></div><div>For this particular case, what would you say about this test? </div></div></blockquote><div><br></div><div>Generally makes sense, one comment inline...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div><br></div><div><div><div>; RUN: opt < %s -asan -S | FileCheck %s                                                                                                                                                             </div>

<div>target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"                                  </div><div>

target triple = "x86_64-unknown-linux-gnu"                                                                                                                                                          </div><div>@xxx = global i32 0, align 4                                                                                                                                                                        </div>

<div>; If a global is present, __asan_[un]register_globals should be called from                                                                                                                         </div><div>; module ctor/dtor                                                                                                                                                                                  </div>

<div>; CHECK: llvm.global_dtors                                                                                                                                                                          </div><div>; CHECK: llvm.global_ctors                                                                                                                                                                          </div>

<div>; CHECK: asan.module_ctor                                                                                                                                                                           </div><div>; CHECK: call void @__asan_register_globals                                                                                                                                                         </div>

<div></div></div></div></div></blockquote><div><br></div><div>It would be good to ensure that nothing untoward ends up between asan.module_ctor and the call. I've not looked at the IR generated, but something like 'CHECK-NEXT' might work. For cases where that is too brittle, a NOT-pinning pattern is very common:</div>
<div><br></div><div>; CHECK: asan.module_ctor</div><div>; CHECK-NOT: ret</div><div>; CHECK: call ...</div><div>; CHECK: ret</div><div><br></div><div><br></div><div>Thanks for looking into how to write test cases here!</div>
</div>