[Evaluator] Look through invariant.group intrinsics
authorArthur Eubanks <aeubanks@google.com>
Thu, 18 Mar 2021 04:26:26 +0000 (21:26 -0700)
committerArthur Eubanks <aeubanks@google.com>
Mon, 12 Apr 2021 23:12:15 +0000 (16:12 -0700)
commita8ab1f98d22cf15f39dd1c2ce77675e628fceb31
tree081454bccd5f49f3887ac964105fe9fb2d3c9622
parent4914c9836765532ffaec9c85bc57690dbdaeb50f
[Evaluator] Look through invariant.group intrinsics

Turning on -fstrict-vtable-pointers in Chrome caused an extra global
initializer. Turns out that a llvm.strip.invariant.group intrinsic was
causing GlobalOpt to fail to step through some simple code.

We can treat *.invariant.group uses as simply their operand.
Value::stripPointerCastsForAliasAnalysis() does exactly this. This
should be safe because the Evaluator does not skip memory accesses due
to invariants or alias analysis.

However, we don't want to leak that we've stripped arbitrary pointer
casts to users of Evaluator, so we bail out if we evaluate a function to
any constant, since we may have looked through *.invariant.group calls
and aliasing pointers cannot be arbitrarily substituted.

Reviewed By: rnk

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