[RS4GC] Avoid crashing on gep scalar_base, vector_idx
authorPhilip Reames <listmail@philipreames.com>
Thu, 24 Jan 2019 16:08:18 +0000 (16:08 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 24 Jan 2019 16:08:18 +0000 (16:08 +0000)
commita657510eb7492896589c97065e2ef3c770742a78
tree57f199cee86f978cab12624c7de018ccbe364264
parentf7098b3a041eaa8e6af607cc298036924ec512ee
[RS4GC] Avoid crashing on gep scalar_base, vector_idx

This is an alternative to https://reviews.llvm.org/D57103.  After discussion, we dedicided to check this in as a temporary workaround, and pursue a true fix under the original thread.

The issue at hand is that the base rewriting algorithm doesn't consider the fact that GEPs can turn a scalar input into a vector of outputs. We had handling for scalar GEPs and fully vector GEPs (i.e. all vector operands), but not the scalar-base + vector-index forms. A true fix here requires treating GEP analogously to extractelement or shufflevector.

This patch is merely a workaround. It simply hides the crash at the cost of some ugly code gen for this presumable very rare pattern.

Differential Revision: https://reviews.llvm.org/D57138

llvm-svn: 352059
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/test/Transforms/RewriteStatepointsForGC/base-vector.ll
llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll [new file with mode: 0644]