[RFC] `opt-out` attribute list for intrinsics

Hi all,

A while back we started annotating intrinsics with new attributes (https://reviews.llvm.org/D65377)

After some discussion it was decided it would be good to have an opt-out attribute list for intrinsics. Some attributes that can be added to the list could be: nosync, nofree, nounwind, willreturn

For now, there are 2 approaches:

  1. Filtering opt-out attributes in tablegen source (https://reviews.llvm.org/D70365)
  2. Having tablegen handle opt-out list (https://reviews.llvm.org/D70365?id=229732)
    How do people feel about these approaches? Is any of the two better than the other? Maybe I should consider something else?

Thanks,
Stefan

Hi Stefan,

A while back we started annotating intrinsics with new attributes (https://reviews.llvm.org/D65377)

After some discussion it was decided it would be good to have an `opt-out` attribute list for intrinsics. Some attributes that can be added to the list could be: nosync, nofree, nounwind, willreturn

For now, there are 2 approaches:

Filtering opt-out attributes in tablegen source (https://reviews.llvm.org/D70365)
Having tablegen handle opt-out list (https://reviews.llvm.org/D70365?id=229732)

How do people feel about these approaches? Is any of the two better than the other? Maybe I should consider something else?

First of all, thank you for looking into this. I think either approach
is fine, but tiven the prevalence of `let IntrProperties` in existing
TableGen code, I'd lean slightly towards the approach where
reconciling the opt-in and opt-out attributes is done by the TableGen
backend.

I'd recommend a slightly different tack to implementing that approach
though: Add a isOptOut field to the IntrinsicProperty class, and have
TableGen automatically determine the default attributes by looking for
attributes that have this set to true.

Cheers,
Nicolai

No strong opinion on the tablegen implementation choice but very much in

favor of “default attributes” for intrinsics.

There is a valid correctness concern but I would argue the attributes show up in the intrinisc test when you add them.

If they seem off, you need to opt-out.

Hi Nicolai,

Thanks for the reply.

While this sounds reasonable to me, I’m not sure that would work. Right now these properties are bool flags that are initialized per Record and each Record can only see properties from IntrProperties list.

If I’m missing something, please let me know.

Thanks,
Stefan

Hi Stefan,

the TableGen backend could enumerate all records derived from
IntrProperties (globally!) and collect those that have the "isOptOut"
(or perhaps better: "isDefault") value set.

Cheers,
Nicolai

[Update]

I’ve created https://reviews.llvm.org/D86021 which makes nofree, nosync and willreturn default attributes for intrinsics. I’ve also opted out of default attributes for some target independent intrinsics.

Please feel free to comment on the review.

Thanks,
Stefan