This is an archive of the discontinued LLVM Phabricator instance.

[RS4GC] Avoid crashing on gep scalar, vector_idx
ClosedPublic

Authored by reames on Jan 23 2019, 9:23 PM.

Details

Summary

This is an alternative to https://reviews.llvm.org/D57103.

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.

Diff Detail

Repository
rL LLVM

Event Timeline

reames created this revision.Jan 23 2019, 9:23 PM
anna accepted this revision.Jan 24 2019, 7:44 AM

LGTM w/ comments.

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
2628 ↗(On Diff #183244)

do you think it makes sense to add an assert here as the else part:

else {
   assert(VF == I.getOperand(i)->getType()->getVectorNumElements() && "expected same VF for all operands!");
}

Btw, this property is also verified in the IRVerifier when we come across a vector GEP (vector GEP is one where *any* of the GEP operands is a vector type).

This revision is now accepted and ready to land.Jan 24 2019, 7:44 AM
This revision was automatically updated to reflect the committed changes.
reames marked an inline comment as done.