This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Fix missing cases in UpdateVCE pass
AbandonedPublic

Authored by ThomasRaoux on Jun 5 2020, 11:17 AM.

Details

Summary

Builtin attached to global variable may have capabilities requirements. Some capabilities may also require minimum spirv version.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Jun 5 2020, 11:17 AM
Herald added a project: Restricted Project. · View Herald Transcript
antiagainst requested changes to this revision.Jun 9 2020, 5:59 PM

Good catch Thomas! The required capability for builtin is indeed not tightly wired up. We can synthesis SPIR-V operation's availability requirements, even requirements from using a particular enum attribute. But it does require the enum attribute to be statically declared on the op's ODS. But here for global variables the builtin decoration is not specified in global variable's ODS. This is actually a deeper problem to solve becuase I can see other ops can potentially have attributes that require additional capabilities... I need to file an issue to track this and solve it properly later.

For now to support global variable, I think this might not be the preferred way. Note that this is just one place we query the availability info; we also do similar things in SPIRVConversionTarget. So to support it, we should have the op report the capabilities required for the builtin decoration too. I think we can do the following:

  1. Add an bit autogenAvailability = 1 field in SPIRV_Op in SPIRVBase.td to control whether we should auto-generate availablity for a particular SPIR-V op.
  2. Modify emitAvailabilityImpl in SPIRVUtilsGen.cpp to return directly if autogenAvailability is false. So with this we can turn off the availablity autogen for global variables.
  3. Implement the autogen'd availablity methods manually so you can inject the logic to report versions/capabilities properly there. (You can find lots of examples in the autogen'd SPIRVOpAvailabilityImpl.inc.)

This way all places will automatically get the proper support.

This revision now requires changes to proceed.Jun 9 2020, 5:59 PM
ThomasRaoux abandoned this revision.Nov 2 2021, 7:39 AM