[MSan] another take at instrumenting inline assembly - now with calls
authorAlexander Potapenko <glider@google.com>
Wed, 31 Oct 2018 09:32:47 +0000 (09:32 +0000)
committerAlexander Potapenko <glider@google.com>
Wed, 31 Oct 2018 09:32:47 +0000 (09:32 +0000)
commitc1c4c9a494ba59d8de6dc2888ad166466d877d06
tree569046a5e8c05b36601cf3fe3f336d1abab54267
parentfadebc8aaefb9461dcfe10a5e1f5482d2199e3f2
[MSan] another take at instrumenting inline assembly - now with calls

Turns out it's not always possible to figure out whether an asm()
statement argument points to a valid memory region.
One example would be per-CPU objects in the Linux kernel, for which the
addresses are calculated using the FS register and a small offset in the
.data..percpu section.
To avoid pulling all sorts of checks into the instrumentation, we replace
actual checking/unpoisoning code with calls to
msan_instrument_asm_load(ptr, size) and
msan_instrument_asm_store(ptr, size) functions in the runtime.

This patch doesn't implement the runtime hooks in compiler-rt, as there's
been no demand in assembly instrumentation for userspace apps so far.

llvm-svn: 345702
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/msan_asm_conservative.ll [new file with mode: 0644]
llvm/test/Instrumentation/MemorySanitizer/msan_x86_bts_asm.ll