[PATCH] D41222: Handle previously ASAN-instrumented IR gracefully when ASAN re-invoked

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 08:31:39 PST 2017


tejohnson added a comment.

In https://reviews.llvm.org/D41222#954847, @vsk wrote:

> Is it possible to reduce the test case s.t the test file doesn't contain instrumented IR? ASan instrumentation is prone to change, so I worry that the test could start passing for invalid reasons. This might happen if 1) __asan_before_dynamic_init is renamed, 2) GlobalsMetadata::doInit is written more defensively, and 3) a non-idempotent ASan transform is introduced later.
>
> I envision something like:
>
>   RUN: opt -asan -asan-module < %s -S -o %t.ll
>   RUN: opt -asan -asan-module < %t.ll -S -o %t.2.ll
>   RUN: diff %t.ll %t.2.ll
>
>
> I spent a few minutes trying to come up with a test like this but did not succeed, because my test file didn't trip the assert you hit.


That's a great idea. The reason you weren't able to trigger it is because what is being tripped over the second time is the llvm.asan.globals metadata, which is inserted by clang via SanitizerMetadata::reportGlobalToASan. I was able to get this in the .ll by building the .c file with "-fsanitize=address -emit-llvm -Xclang -disable-llvm-passes". Then running it through opt twice in the manner you describe above hits the assert. I was then able to simplify the initial .ll file even more and still hit the original assert.

Updated test case being uploaded momentarily.


https://reviews.llvm.org/D41222





More information about the llvm-commits mailing list