This is an archive of the discontinued LLVM Phabricator instance.

[Attributes] Determine attribute properties from TableGen data
ClosedPublic

Authored by nikic on Jul 11 2021, 9:16 AM.

Details

Summary

Continuing from D105763, this allows placing certain properties about attributes in the TableGen definition. In particular, we store whether an attribute applies to fn/param/ret (or a combination thereof). This information is used by the Verifier, as well as the ForceFunctionAttrs pass. I also plan to use this in LLParser, which also duplicates info on which attributes are valid where.

This keeps metadata about attributes in one place, and makes it more likely that it stays in sync, rather than in various functions spread across the codebase.

Diff Detail

Event Timeline

nikic created this revision.Jul 11 2021, 9:16 AM
nikic requested review of this revision.Jul 11 2021, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2021, 9:16 AM
madhur13490 added inline comments.
llvm/include/llvm/IR/Attributes.td
14

What about a better name - something like, AttrPlace or AttrLocation?

nikic added inline comments.Jul 11 2021, 9:37 AM
llvm/include/llvm/IR/Attributes.td
14

This is intended as a generic mechanism for specifying metadata about attributes. Right now it only specifies where it can be placed, but there's more properties we can track. For example, it would be nice to replace this switch: https://github.com/llvm/llvm-project/blob/98c2e4115d8d7d4962df52f595e8d2d0cfdfdc8f/llvm/lib/Transforms/Utils/CodeExtractor.cpp#L893

aeubanks accepted this revision.Jul 12 2021, 10:53 AM
aeubanks added a subscriber: aeubanks.

lgtm with some nits

llvm/lib/IR/Attributes.cpp
500

formatting?

llvm/lib/IR/Verifier.cpp
1871

if we're updating this message in a test, might as well make this "function return values"

This revision is now accepted and ready to land.Jul 12 2021, 10:53 AM
This revision was landed with ongoing or failed builds.Jul 12 2021, 1:13 PM
This revision was automatically updated to reflect the committed changes.