HomePhabricator

[basicaa] Fix a latent bug in isGEPBaseAtNegativeOffset

Authored by reames on Mar 3 2021, 8:43 AM.

Description

[basicaa] Fix a latent bug in isGEPBaseAtNegativeOffset

This was pointed out in review of D97520 by Nikita, but existed in the original code as well.

The basic issue is that a decomposed GEP expression describes (potentially) more than one getelementptr. The "inbounds" derived UB which justifies this aliasing rule requires that the entire offset be composed of "inbounds" geps. Otherwise, as can be seen in the recently added and changes in this patch test, we can end up with a large commulative offset with only a small sub-offset actually being "inbounds". If that small sub-offset lies within the object, the result was unsound.

We could potentially be fancier here, but for the moment, simply be conservative when any of the GEPs parsed aren't inbounds.

Details

Committed
reamesMar 3 2021, 8:43 AM
Parents
rGdd9922c487f3: [basicaa] Minor indentation fix
Branches
Unknown
Tags
Unknown