This is an archive of the discontinued LLVM Phabricator instance.

[GISel]: Fix undefined behavior while accessing DefaultAction map
ClosedPublic

Authored by aditya_nandakumar on May 10 2017, 7:02 PM.

Details

Summary

We end up dereferencing the end iterator here when the Aspect doesn't exist in the DefaultAction map.
Check for end iterator.

Diff Detail

Repository
rL LLVM

Event Timeline

aditya_nandakumar added a reviewer: dsanders.
dsanders added inline comments.May 11 2017, 3:04 AM
include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
159

I'm not sure about this bit. Are the callers expecting to deal with an invalid LLT?

Updated the Patch to make the helper function return Optional<LLT> which the caller checks for validity.

Updated API to return Optional<LLT>

qcolombet edited edge metadata.May 12 2017, 12:04 PM

Hi Aditya,

LGTM with the optional update.
@dsanders Daniel, I believe it fixes your concern, right?

Cheers,
-Quentin

qcolombet accepted this revision.May 12 2017, 2:31 PM
This revision is now accepted and ready to land.May 12 2017, 2:31 PM
dsanders accepted this revision.May 12 2017, 2:59 PM

Yep, LGTM.

One nit: We could avoid introducing the Optional<> by testing for LLT.isValid() instead of testing for whether the Optional has a value

Sure - LLT.isValid() also sounds good - I'll go ahead and do it that way.

committed in r302963