clspv icon indicating copy to clipboard operation
clspv copied to clipboard

RFC: Rewrite private-AS GEP increments in loops

Open polsenferreira opened this issue 4 years ago • 1 comments

When a pointer in the private address space is incremented in a loop, the first offset in the GEP will not be a 0. This breaks the assumptions in the SPV writer pass, leading to an assertion. Rewrite GEPs in loops to use an offset counter instead.

I have not done extensive testing on this pass, as I am not sure this is the right solution going forward. The pattern searched for in this pass is fragile, and this is effectively working-around a deficiency in the SPV spec (or the SPV writer), but I can't think of a different way to solve the problem.

A reduced test case is attached, along with a .ll file where the FileCheck checks describe what the pass is doing.

Signed-off-by: Pedro Olsen Ferreira [email protected] Change-Id: I0abf1eeff2035101f01de0ccfddfbc663e92b998

polsenferreira avatar Oct 21 '21 08:10 polsenferreira

I think generally this approach can work, but it feels like there will be some corner cases with multi-dimensional arrays. Not sure how best to proceed with those.

alan-baker avatar Nov 05 '21 17:11 alan-baker