This is an archive of the discontinued LLVM Phabricator instance.

Fix crash when looking up the addrspace of GEPs with vector types
ClosedPublic

Authored by dotdash on Aug 31 2014, 6:35 AM.

Details

Reviewers
arsenm

Diff Detail

Event Timeline

dotdash updated this revision to Diff 13128.Aug 31 2014, 6:35 AM
dotdash retitled this revision from to Fix crash when looking up the addrspace of GEPs with vector types.
dotdash updated this object.
dotdash edited the test plan for this revision. (Show Details)
dotdash added a subscriber: Unknown Object (MLST).
arsenm added a subscriber: arsenm.Aug 31 2014, 10:09 AM

I'm kind of surprised this was broken. It would probably be better to come up with a testcase where this breaks in a more fundamental pass like instcombine

include/llvm/IR/Instructions.h
890 ↗(On Diff #13128)

This one looks correct already, and this change should be unnecessary. getPointerAddressSpace() already calls getScalarType()

include/llvm/IR/Operator.h
405–406

This is a correct fix, but this should use Ty->getPointerAddressSpace() like everywhere else

dotdash updated this revision to Diff 13130.Aug 31 2014, 1:06 PM

Updated the patch to use getPointerAddressSpace(), couldn't find a different
pass that triggers the bug though, so the test still uses mergefunc

arsenm accepted this revision.Sep 1 2014, 9:27 AM
arsenm added a reviewer: arsenm.

LGTM. I would expect you could trigger this by running instcombine with a GEP that ends up getting some kind of constant folding

This revision is now accepted and ready to land.Sep 1 2014, 9:27 AM

Had another look, still couldn't find anything. The code is either using GetElementPtrInst instead of GEPOperator, calls getType()->getPointerAddressSpace() or checks for vector types beforehand, so it doesn't trigger the bug. Alias analysis seemed like it could work, but I didn't manage to get a testcase with that either (and I'm too clueless about that code).

Anyway, could someone please land this for me? I don't have commit access. Thanks!

arsenm closed this revision.Sep 2 2014, 11:57 AM

Committed r216930