This is an archive of the discontinued LLVM Phabricator instance.

[Scalarizer] PR28108: Skip over nullptr rather than crashing on it.
ClosedPublic

Authored by uabelho on Jun 20 2016, 2:13 AM.

Details

Summary

In Scalarizer::gather we see if we already have a scattered form of Op,
and in that case use the new form.

In the particular case of PR28108, the found ValueVector SV has size 2,
where the first Value is nullptr, and the second is indeed a proper Value.
The nullptr then caused an assert to blow when we tried to do
cast<Instruction>(SV[I]).

With this patch we check SV[I] before doing the cast, and if it's nullptr
we just skip over it.

I don't know the Scalarizer well enough to know if this is the best fix
or if something should be done else where to prevent the nullptr from
being in the ValueVector at all, but at least this avoids the crash
and looking at the test case output it looks reasonable.

Diff Detail

Event Timeline

uabelho updated this revision to Diff 61238.Jun 20 2016, 2:13 AM
uabelho retitled this revision from to [Scalarizer] PR28108: Skip over nullptr rather than crashing on it..
uabelho updated this object.
uabelho added a subscriber: llvm-commits.

I don't know who could review this so I added some people that seems to have done or reviewed things in the Scalarizer before.

uabelho updated this revision to Diff 61244.Jun 20 2016, 3:38 AM

Had wrong name on the test case file.

Ping. Anyone wanna review this?

mehdi_amini accepted this revision.Jul 12 2016, 3:30 PM
mehdi_amini edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jul 12 2016, 3:30 PM

Thank you Mehdi.

I don't have commit rights, could you or someone else possibly commit this or is there something else I should do?

This revision was automatically updated to reflect the committed changes.