[ASan] Disable dynamic alloca and UAR detection in presence of returns_twice calls.
authorAlexey Samsonov <vonosmas@gmail.com>
Wed, 29 Jul 2015 19:36:08 +0000 (19:36 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Wed, 29 Jul 2015 19:36:08 +0000 (19:36 +0000)
commit869a5ff37fe76de8f8d519655a9fd313d30ab02d
tree5cac4f771f52358fb63146819913a8bfa1481756
parent8bc43a142ba4c852820ec1e285f6ead6229baa7c
[ASan] Disable dynamic alloca and UAR detection in presence of returns_twice calls.

Summary:
returns_twice (most importantly, setjmp) functions are
optimization-hostile: if local variable is promoted to register, and is
changed between setjmp() and longjmp() calls, this update will be
undone. This is the reason why "man setjmp" advises to mark all these
locals as "volatile".

This can not be enough for ASan, though: when it replaces static alloca
with dynamic one, optionally called if UAR mode is enabled, it adds a
whole lot of SSA values, and computations of local variable addresses,
that can involve virtual registers, and cause unexpected behavior, when
these registers are restored from buffer saved in setjmp.

To fix this, just disable dynamic alloca and UAR tricks whenever we see
a returns_twice call in the function.

Reviewers: rnk

Subscribers: llvm-commits, kcc

Differential Revision: http://reviews.llvm.org/D11495

llvm-svn: 243561
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/stack_dynamic_alloca.ll