[ubsan] Skip alignment checks on allocas with known alignment
authorVedant Kumar <vsk@apple.com>
Wed, 26 Apr 2017 02:17:21 +0000 (02:17 +0000)
committerVedant Kumar <vsk@apple.com>
Wed, 26 Apr 2017 02:17:21 +0000 (02:17 +0000)
commite859ebbd0619c901f2f845c54ce484f5afdd8ab6
tree3b553163aacada92afca4d47b3c9666bfc65c26d
parent0827b7ff3ecbe9d826ecc8fadb52717e373200e5
[ubsan] Skip alignment checks on allocas with known alignment

It's possible to determine the alignment of an alloca at compile-time.
Use this information to skip emitting some runtime alignment checks.

Testing: check-clang, check-ubsan.

This significantly reduces the amount of alignment checks we emit when
compiling X86ISelLowering.cpp. Here are the numbers from patched/unpatched
clangs based on r301361.

  ------------------------------------------
  | Setup          | # of alignment checks |
  ------------------------------------------
  | unpatched, -O0 |                 47195 |
  | patched, -O0   |                 30876 | (-34.6%)
  ------------------------------------------

llvm-svn: 301377
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGen/catch-undef-behavior.c
clang/test/CodeGen/sanitize-recover.c
clang/test/CodeGenCXX/ubsan-suppress-checks.cpp