diff options
author | Vedant Kumar <vsk@apple.com> | 2017-05-02 23:46:56 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-05-02 23:46:56 +0000 |
commit | d919115983a85f1b772f90d945a4ee8360771c36 (patch) | |
tree | d9985663621c1964229c3da1a0858b86904cdb0d /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 67736594f7cc1f789060a89f0bc981b58b66bca1 (diff) | |
download | bcm5719-llvm-d919115983a85f1b772f90d945a4ee8360771c36.tar.gz bcm5719-llvm-d919115983a85f1b772f90d945a4ee8360771c36.zip |
[ubsan] Skip overflow checks on safe arithmetic (fixes PR32874)
Currently, ubsan emits overflow checks for arithmetic that is known to
be safe at compile-time, e.g:
1 + 1 => CheckedAdd(1, 1)
This leads to breakage when using the __builtin_prefetch intrinsic. LLVM
expects the arguments to @llvm.prefetch to be constant integers, and
when ubsan inserts unnecessary checks on the operands to the intrinsic,
this contract is broken, leading to verifier failures (see PR32874).
Instead of special-casing __builtin_prefetch for ubsan, this patch fixes
the underlying problem, i.e that clang currently emits unnecessary
overflow checks.
Testing: I ran the check-clang and check-ubsan targets with a stage2,
ubsan-enabled build of clang. I added a regression test for PR32874, and
some extra checking to make sure we don't regress runtime checking for
unsafe arithmetic. The existing ubsan-promoted-arithmetic.cpp test also
provides coverage for this change.
llvm-svn: 301988
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions