Go to file
Vedant Kumar 34b1fd6aaa Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

I also compiled X86FastISel.cpp with -fsanitize=null using
patched/unpatched clangs based on r293572. Here are the number of null
checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit:
- Don't introduce any unintentional object-size or alignment checks.
- Don't rely on IRGen of C labels in the test.

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

llvm-svn: 295515
2017-02-17 23:22:59 +00:00
clang Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581) 2017-02-17 23:22:59 +00:00
clang-tools-extra Fix windows buildbots that don't have full shell support 2017-02-17 21:31:31 +00:00
compiler-rt [PGO] remove unintended debug trace. NFC 2017-02-17 17:42:16 +00:00
debuginfo-tests
libclc Move BufferPtr into the block where it it being used 2017-02-12 21:33:49 +00:00
libcxx test: prevent incorrect quoting of paths 2017-02-17 23:08:46 +00:00
libcxxabi Fix test_exception_storage.pass.cpp in C++17 my re-enabling the unexpected handlers 2017-02-17 04:26:22 +00:00
libunwind [libunwind][CMake] Use libc++ headers when available 2017-02-16 05:18:08 +00:00
lld [COFF] support /ERRORLIMIT option 2017-02-17 22:46:06 +00:00
lldb NPL: Fix an incorrect logging formatv call 2017-02-17 16:09:10 +00:00
llgo [llgo] Remove support for LLVM attributes 2016-12-06 19:22:04 +00:00
llvm [InstCombine] add tests for trunc(shuffle X, C, M); NFC 2017-02-17 23:16:54 +00:00
openmp [stats] add stats-gathering for static_steal scheduling method 2017-02-17 17:06:16 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly Drop leftover debug statement 2017-02-17 13:39:45 +00:00