This is an archive of the discontinued LLVM Phabricator instance.

[IR] add bounds checking to paramHasAttr
ClosedPublic

Authored by sanjoy on Nov 3 2015, 2:06 PM.

Details

Summary

This is intended to make a later change simpler.

Note: adding this bounds checking required fixing X86FastISel. As
far I can tell I've preserved original behavior but a careful review
will be appreciated.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 39116.Nov 3 2015, 2:06 PM
sanjoy retitled this revision from to [IR] Restrain paramHasAttr: disallow function attrs.
sanjoy updated this object.
sanjoy added a reviewer: reames.
sanjoy added a subscriber: llvm-commits.
reames accepted this revision.Nov 3 2015, 3:20 PM
reames edited edge metadata.

LGTM

Do we intend to allow ReturnIndex here?

This revision is now accepted and ready to land.Nov 3 2015, 3:20 PM
sanjoy added a comment.Nov 3 2015, 3:41 PM

LGTM

Do we intend to allow ReturnIndex here?

At least for now I think we should allow ReturnIndex here since there isn't an existing hasReturnAttr.

sanjoy retitled this revision from [IR] Restrain paramHasAttr: disallow function attrs to [IR] add bounds checking to paramHasAttr.Nov 3 2015, 6:43 PM
sanjoy updated this object.
sanjoy edited edge metadata.
sanjoy updated this revision to Diff 39146.Nov 3 2015, 6:44 PM
  • make the bounds checking stricter, and fix an out of bounds access

@ributzka, @eli.friedman -- can one of you please take a look at the X86 FastISel fix?

eli.friedman edited edge metadata.Nov 3 2015, 8:28 PM

The FastIsel changes appear to be correct... but probably not the most clear way to write it. It would be better to combine the if statements so it only checks arg_size != 0 once.

Granted, I'm just basing that assessment off of r160725. If I did have any special knowledge here, I've forgotten it.

sanjoy updated this revision to Diff 39160.Nov 3 2015, 8:58 PM
sanjoy edited edge metadata.
  • address review: clean up the edit to X86FastISel.cpp

LGTM w/minor comment addressed given the FastISel correctness is now covered.

lib/Target/X86/X86FastISel.cpp
2822 ↗(On Diff #39160)

This would be clearer as a single if within the CS one.
if (CS->arg_empty() ||

  no struct ret ||
  inref) 
return 0
This revision was automatically updated to reflect the committed changes.