[PATCH] D95734: Use alias analysis to remove redundant instrumentation for Asan

Chijin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 21:25:39 PST 2021


ChijinZ added a comment.

In D95734#2551939 <https://reviews.llvm.org/D95734#2551939>, @eugenis wrote:

> This is what Vitaly is talking about:
>
>   __attribute__((noinline)) void deallocate(void *p) {
>     free(p);
>   }
>   
>   int main(int argc, char **argv) {
>     int *p = (int *)malloc(sizeof(int));
>     *p = 42;
>     deallocate(p);
>     return *p;
>   }
>
> Your optimization is missing the bug. Any call to a function without the "nofree" attribute needs to forget about the earlier checks.
>
> In general, optimizations like this are dangerous because there is no good test set for memory bugs. We could be missing bugs left and right and will never notice...

It seems that my optimization doesn't miss the bug. If you pass a pointer as an argument to a function, then the following use of this pointer will *MayAlias* the previous use. Thus, the corresponding check will not be removed. In my experiment, all the asan checks of this example are not removed. Did I miss something?

Besides, I don't think it is dangerous because the implementation of llvm's alias analysis is always conservative, and my optimization is also conservative (only remove one when "MustAlias").


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95734/new/

https://reviews.llvm.org/D95734



More information about the llvm-commits mailing list