[ConstFold] Support opaque pointers in constexpr GEPs
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 20 Jul 2021 15:19:52 +0000 (17:19 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Sep 2021 18:50:29 +0000 (20:50 +0200)
commit58db5f6e959419aaca20798835d75d3646b99293
treeb223cc006acec0978c36d91fdb37462e08893a3b
parent34528c32d23f98312434bb8d67510bef616e5b44
[ConstFold] Support opaque pointers in constexpr GEPs

Support opaque pointers in SymbolicallyEvaluateGEP() by using the
value type of a GlobalValue base or falling back to i8 if there
isn't one. We don't unconditionally generate i8 GEPs here because
that would lose inrange attribues, and because some optimizations
on globals currently rely on GEP types (e.g. the globals SROA
mentioned in the comment).

Differential Revision: https://reviews.llvm.org/D109297
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Transforms/InstCombine/force-opaque-ptr.ll [new file with mode: 0644]