This is an archive of the discontinued LLVM Phabricator instance.

[Analysis] Fix issues when querying vscale attributes on functions
ClosedPublic

Authored by david-arm on Sep 21 2021, 5:19 AM.

Details

Summary

There are several places in the code that are currently broken as
they assume an Instruction always has a parent Function when
attempting to get the vscale_range attribute. This patch adds checks
that an Instruction has a parent.

Diff Detail

Event Timeline

david-arm created this revision.Sep 21 2021, 5:19 AM
david-arm requested review of this revision.Sep 21 2021, 5:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 5:19 AM

I don't think all these cases are currently broken, because InstCombine traverses nodes that are in the IR. I'm not against having an extra guard for it though.
Is it worth adding a test for the ValueTracking case to avoid regression?

Hi @sdesmalen, yeah I agree it would be good to have a test for the ValueTracking.cpp fix, but I wasn't sure how to create a simple, reliable test case where I is guaranteed not to have a parent?

Hi @sdesmalen, yeah I agree it would be good to have a test for the ValueTracking.cpp fix, but I wasn't sure how to create a simple, reliable test case where I is guaranteed not to have a parent?

Maybe a unittest in llvm/unittests/Support/KnownBitsTest.cpp?

david-arm updated this revision to Diff 374159.Sep 22 2021, 1:58 AM
  • Added unit test for parentless vscale call instructions
david-arm updated this revision to Diff 374492.Sep 23 2021, 3:21 AM
  • Simplified the unit test so we can avoid calling parseAssembly
sdesmalen accepted this revision.Sep 23 2021, 3:25 AM

LGTM, cheers @david-arm!

This revision is now accepted and ready to land.Sep 23 2021, 3:25 AM
This revision was landed with ongoing or failed builds.Sep 24 2021, 1:58 AM
This revision was automatically updated to reflect the committed changes.