[PATCH] D81699: MemorySanitizer: Add option to insert init checks at call site

Gui Andrade via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 16:33:36 PDT 2020


guiand created this revision.
guiand added a reviewer: eugenis.
Herald added subscribers: llvm-commits, Sanitizers, aaron.ballman, hiraditya, mgorny.
Herald added projects: Sanitizers, LLVM.
guiand added a parent revision: D81678: Introduce partialinit attribute at call sites for stricter poison analysis.

This change depends on a previous patch adding the partialinit attribute to LLVM calls.

With this change, specifying the option `-msan-eager-checks` will cause MemorySanitizer to insert initialization checks for function arguments before calling them, and for return values before returning.

This change is unsound when the value has been lowered from a type that may contain legal uninitialized bits, such as a struct (padding) or a union's inactive fields. So it depends on the `partialinit` keyword for determining these cases, and continues to pass `partialinit` values by TLS.

Checking at call boundaries enforces undefined behavior rules with passing uninitialized arguments by value. It also provides substantial improvements to the optimized instrumented code, decreasing binary size by up to 17% and runtime up to 25%.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81699

Files:
  compiler-rt/test/msan/CMakeLists.txt
  compiler-rt/test/msan/bitfield.cpp
  compiler-rt/test/msan/chained_origin.cpp
  compiler-rt/test/msan/chained_origin_empty_stack.cpp
  compiler-rt/test/msan/chained_origin_memcpy.cpp
  compiler-rt/test/msan/cxa_atexit.cpp
  compiler-rt/test/msan/in-struct-padding.cpp
  compiler-rt/test/msan/insertvalue_origin.cpp
  compiler-rt/test/msan/lit.site.cfg.py.in
  compiler-rt/test/msan/no_sanitize_memory_prop.cpp
  compiler-rt/test/msan/param_tls_limit.cpp
  compiler-rt/test/msan/parameter-mixing.cpp
  compiler-rt/test/msan/qsort.cpp
  compiler-rt/test/msan/signal_stress_test.cpp
  compiler-rt/test/msan/stack-origin2.cpp
  compiler-rt/test/msan/test.h
  compiler-rt/test/msan/unaligned_read_origin.cpp
  compiler-rt/test/msan/unpoison_param.cpp
  compiler-rt/test/msan/vararg.cpp
  compiler-rt/test/msan/vector_cvt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81699.270260.patch
Type: text/x-patch
Size: 37458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/240766c5/attachment-0001.bin>


More information about the llvm-commits mailing list