]> granicus.if.org Git - llvm/commit
MSan: handle llvm.lifetime.start intrinsic
authorAlexander Potapenko <glider@google.com>
Tue, 30 Apr 2019 08:35:14 +0000 (08:35 +0000)
committerAlexander Potapenko <glider@google.com>
Tue, 30 Apr 2019 08:35:14 +0000 (08:35 +0000)
commita5ffeed7eff86e3cfebdb1db7fa235b74b2f7295
treea8dff6d1d6299c37069918652367eccb29f4bb8f
parent6e99e91c29275ac9b0b25d90b1bc41988384bc72
MSan: handle llvm.lifetime.start intrinsic

Summary:
When a variable goes into scope several times within a single function
or when two variables from different scopes share a stack slot it may
be incorrect to poison such scoped locals at the beginning of the
function.
In the former case it may lead to false negatives (see
https://github.com/google/sanitizers/issues/590), in the latter - to
incorrect reports (because only one origin remains on the stack).

If Clang emits lifetime intrinsics for such scoped variables we insert
code poisoning them after each call to llvm.lifetime.start().
If for a certain intrinsic we fail to find a corresponding alloca, we
fall back to poisoning allocas for the whole function, as it's now
impossible to tell which alloca was missed.

The new instrumentation may slow down hot loops containing local
variables with lifetime intrinsics, so we allow disabling it with
-mllvm -msan-handle-lifetime-intrinsics=false.

Reviewers: eugenis, pcc

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60617

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359536 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Instrumentation/MemorySanitizer.cpp
test/Instrumentation/MemorySanitizer/alloca.ll