[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers
Vedant Kumar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 22 17:39:31 PST 2017
vsk created this revision.
This patch teaches ubsan to insert an alignment check for the 'this'
pointer at the start of each method/lambda. This allows clang to emit
significantly fewer alignment checks overall, because if 'this' is
aligned, so are its fields.
This is essentially the same thing r295515 does, but for the alignment
check instead of the null check.
Testing: check-clang, check-ubsan, and a stage2 ubsan build.
I also compiled X86FastISel.cpp with -fsanitize=alignment using
patched/unpatched clangs based on r295686. Here are the number of
alignment checks emitted:
| Setup | # of alignment checks |
| unpatched, -O0 | 24918 |
| patched, -O0 | 14307 |
There are a few possible follow-ups:
- Don't add the per method/lambda check in delegating constructors.
- Don't instrument accesses to fields with alignment = 1.
https://reviews.llvm.org/D30283
Files:
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprCXX.cpp
lib/CodeGen/CodeGenFunction.cpp
test/CodeGen/catch-undef-behavior.c
test/CodeGen/sanitize-recover.c
test/CodeGenCXX/ubsan-suppress-checks.cpp
test/CodeGenCXX/ubsan-suppress-null-checks.cpp
test/CodeGenCXX/ubsan-type-checks.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30283.89452.patch
Type: text/x-patch
Size: 15716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170223/6ba8167d/attachment.bin>
More information about the cfe-commits
mailing list