This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tblgen] Reverting fatality of assemblyFormat with skipDefaultBuilders=1
ClosedPublic

Authored by wrengr on Jul 6 2022, 3:45 PM.

Details

Summary

Per @rriddle, we do not want to require skipDefaultBuilders=0 per se; that is, even though the assemblyFormat-generated parser requires a builder with the same prototype as the default-builder, that prototype could instead be implemented via custom builders. This differential reduces the FatalError introduced in D128555 to a non-fatal Warning instead, so that users can still be informed of the error condition (rather than waiting for the C++ compiler to fail).

Diff Detail

Event Timeline

wrengr created this revision.Jul 6 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2022, 3:45 PM
wrengr requested review of this revision.Jul 6 2022, 3:45 PM
rriddle accepted this revision.Jul 6 2022, 3:47 PM

Really appreciated!

mlir/lib/TableGen/AttrOrTypeDef.cpp
86

Can you file an issue for this? I 100% agree this is definitely something we want better support for, but we don't really have any good way of signaling override right now (the only real way we have right now is by checking the builder signature, but that is quite fragile).

This revision is now accepted and ready to land.Jul 6 2022, 3:47 PM

Also want to say thanks for the improved error messages in general! They make a difference.

wrengr added inline comments.Jul 6 2022, 6:02 PM
mlir/lib/TableGen/AttrOrTypeDef.cpp
86

Will do.

I have another CL in the works which tries to check the custom builders, but as you say it's fragile. The only other feasible option I see is adding a new bit hasCustomDefaultBuilder field (with a better name!!), which causes to generate the declarations but not the definitions (similar to how hasCustomAssemblyFormat relates to assemblyFormat); but that's fragile in a different direction :(

This is reporting warnings during regular builds (llvm/mlir/test/lib/Dialect/Test/TestAttrDefs.td:227:1: warning: using 'assemblyFormat' with 'skipDefaultBuilders=1' may result in C++ compilation errors) , could we disable the warnings there? I wouldn't want folks to get used to ignorning warnings.

Yeah, I don't want folks getting used to warnings either! :)

For future readers of this differential:

  • Further discussion should take place at https://llvm.org/PR56415 so we can keep things in one place.
  • D130102 (should land soon) will remove this warning entirely, pending a better resolution to PR56415
  • D129243 (WIP) attempts to detect when some custom builder matches the expected prototype. This is inherently fragile due to using string comparisons as a proxy for type equivalence, but there are some other deep-seated issues which are discussed further at https://reviews.llvm.org/D129243#3663647