[Evaluator] Bitcast result of pointer stripping
authorArthur Eubanks <aeubanks@google.com>
Wed, 21 Apr 2021 16:41:17 +0000 (09:41 -0700)
committerArthur Eubanks <aeubanks@google.com>
Wed, 21 Apr 2021 20:32:29 +0000 (13:32 -0700)
commitb606e2df4dd49c17c9f2733f2339b6dd0dd427de
treea632492950345b779d5ab35d0c1947a4f64f2755
parent5d1c43f333c2327be61604dc90ea675f0d1e6913
[Evaluator] Bitcast result of pointer stripping

Trying to evaluate a GEP would assert with
  "Ty == cast<PointerType>(C->getType()->getScalarType())->getElementType()"
because the type of the pointer we would evaluate the GEP argument to
would be a different type than the GEP was expecting. We should treat
pointer stripping as a bitcast.

The test adds a redundant GEP that would crash due to type mismatch.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D100970
llvm/lib/Transforms/Utils/Evaluator.cpp
llvm/test/Transforms/GlobalOpt/invariant.group.ll