[MSAN] Instrument libatomic load/store calls
authorGui Andrade <guiand@google.com>
Wed, 22 Jul 2020 16:34:55 +0000 (16:34 +0000)
committerGui Andrade <guiand@google.com>
Wed, 22 Jul 2020 16:45:06 +0000 (16:45 +0000)
commit33d239513c881d8c11c60d5710c55cf56cc309a5
treed99ef1bc557db881e888f874cbc180acce6a8926
parenta5e0194709c40212694370e0ea789a1ca14548b5
[MSAN] Instrument libatomic load/store calls

These calls are neither intercepted by compiler-rt nor is libatomic.a
naturally instrumented.

This patch uses the existing libcall mechanism to detect a call
to atomic_load or atomic_store, and instruments them much like
the preexisting instrumentation for atomics.

Calls to _load are modified to have at least Acquire ordering, and
calls to _store at least Release ordering. Because this needs to be
converted at runtime, msan injects a LUT (implemented as a vector
with extractelement).

Differential Revision: https://reviews.llvm.org/D83337
compiler-rt/test/msan/libatomic.c [new file with mode: 0644]
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/libatomic.ll [new file with mode: 0644]