Commit Graph

6 Commits

Author SHA1 Message Date
Vedant Kumar 2b6e4a436d [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)
C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296213 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-25 00:43:36 +00:00
Alexey Samsonov e6c5c3f4be Reimplement -fsanitize-recover family of flags.
Introduce the following -fsanitize-recover flags:
  - -fsanitize-recover=<list>: Enable recovery for selected checks or
      group of checks. It is forbidden to explicitly list unrecoverable
      sanitizers here (that is, "address", "unreachable", "return").
  - -fno-sanitize-recover=<list>: Disable recovery for selected checks or
     group of checks.
  - -f(no-)?sanitize-recover is now a synonym for
    -f(no-)?sanitize-recover=undefined,integer and will soon be deprecated.

These flags are parsed left to right, and mask of "recoverable"
sanitizer is updated accordingly, much like what we do for -fsanitize= flags.
-fsanitize= and -fsanitize-recover= flag families are independent.

CodeGen change: If there is a single UBSan handler function, responsible
for implementing multiple checks, which have different recoverable setting,
then we emit two handler calls instead of one:
the first one for the set of "unrecoverable" checks, another one - for
set of "recoverable" checks. If all checks implemented by a handler have the
same recoverability setting, then the generated code will be the same.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225719 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:39:12 +00:00
Will Dietz 562d45ce29 ubsan: Only emit constants for filenames and type descriptors once.
Produces neater IR in significantly less time.

(~18% faster -O0 compile time for sqlite3 with -fsanitize=undefined)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194231 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-08 01:09:22 +00:00
Will Dietz 4a5984cc6d [ubsan] Make static check data non-const so it can be used for deduplication.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171947 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-09 03:39:41 +00:00
Dmitri Gribenko f8a6cb1f75 CodeGen/compound-assign-overflow.c: include stdint.h in freestanding mode
This hopefully fixes the ARM buildbot.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171853 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-08 14:47:41 +00:00
Will Dietz 822023a553 [ubsan] Use correct type for compound assignment ops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171801 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 22:25:52 +00:00