[SCEVExpander] Support opaque pointers
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 3 Jul 2021 16:09:19 +0000 (18:09 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 7 Jul 2021 18:47:59 +0000 (20:47 +0200)
commit84c15bc018fa2b64f36790ae06f76c418a5407ad
tree3b9df9e5fa7804480c405a7caa2b533acda11286
parent97c473ad394ad9360cd89eda5a8e5aeb4b5d90fe
[SCEVExpander] Support opaque pointers

This adds support for opaque pointers to expandAddToGEP() by always
generating an i8 GEP for opaque pointers. After looking at some other
cases (constexpr GEP folding, SROA GEP generation), I've come around
to the idea that we should use i8 GEPs for opaque pointers, because
the alternative would be to guess a GEP type from surrounding code,
which will not be reliable. Ultimately, i8 GEPs is where we want to
end up anyway, and opaque pointers just make that the natural choice.

There are a couple of other places in SCEVExpander that check pointer
element types, I plan to update those when I run across usable test
coverage that doesn't assert elsewhere.

Differential Revision: https://reviews.llvm.org/D105398
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/test/Transforms/LoopStrengthReduce/opaque-ptr.ll [new file with mode: 0644]