HomePhabricator

[ubsan] Skip null checks if they are constant-folded away

Description

[ubsan] Skip null checks if they are constant-folded away

The IR builder can constant-fold null checks if the pointer operand
points to a constant. If the "is-non-null" check is folded away to
"true", don't emit the null check + branch.

Testing: check-clang, check-ubsan.

This slightly reduces the amount of null checks we emit when compiling
X86ISelLowering.cpp. Here are the numbers from patched/unpatched clangs
based on r300371.


| Setup          | # of null checks |
-------------------------------------
| unpatched, -O0 |            25251 |
| patched, -O0   |            23925 | (-5.3%)
-------------------------------------

Details

Committed
vedantkApr 17 2017, 3:26 PM
Parents
rL300508: [ubsan] Skip null checks on pointers to the start of an alloca
Branches
Unknown
Tags
Unknown