[llvm-dev] The bit pattern after stripPointerCasts()
Doerfert, Johannes Rudolf via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 11 16:51:45 PST 2018
in a recent review , Florian Hahn helped me to realize something that
was rather surprising to me:
The widely popular and very useful function
llvm::Value::stripPointerCasts() can return a value with a different
bit pattern than the input.
Now, I think this should not be the case but I want the hear other
opinions. Before I go on, please not that there is at least one location
in the code base  that makes a wrong assumption about the bit pattern
StripPointerCasts will peel of address space casts but these can
potentially change the bit pattern.
1) Make stripPointerCasts not look through address space casts. A new
function (or parameter) would then be introduced to do the same thing
_and_ peel of address space casts.
2) Keep looking through address space casts in stripPointerCasts. A new
function (or parameter) would then be introduced to do the same but with
the guarantee that the bit pattern is preserved.
Note that the module implementation of stripPointerCasts and friends
makes basically all the changes to them easy.
Solution one has the benefit that our code is "more sound" than before
because the stripPointerCasts function is more restrictive. We might
lose performance though. Solution two will not disturb any existing code
but we might need to revisit the uses of stripPointerCasts to fix
 LazyValueInfo::getPredicateAt() line ~1714, isKnownNull(...) is used
after the stripPointerCasts() function might have changed the bit
pattern (and thereby the null-ness).
Argonne National Laboratory
Lemont, IL 60439, USA
jdoerfert at anl.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 228 bytes
Desc: not available
More information about the llvm-dev