Skip to content

[TableGen] Add check for number of intrinsic return values #107326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Sep 4, 2024

Fail if we see an intrinsic that returns more than the supported number of return values.

Intrinsics can return only upto a certain nyumber of values, as defined by the IIT_RetNumbers list in Intrinsics.td. Currently, if we define an intrinsic that exceeds the limit, llvm-tblgen crashes. Instead, read this limit and fail if it's exceeded with a proper error message.

@jurahul jurahul changed the title [TableGen] Add error checks for number of intrinsic return values [TableGen] Add error check for number of intrinsic return values Sep 4, 2024
@jurahul jurahul changed the title [TableGen] Add error check for number of intrinsic return values [TableGen] Add check for number of intrinsic return values Sep 4, 2024
@jurahul
Copy link
Contributor Author

jurahul commented Sep 5, 2024

Linux build failure in lldb test seems unrelated. Also, currently without this check, we hit the following assert:

llvm-tblgen: /home/rjoshi/upstream_llvm/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::ListInit, From = const llvm::Init]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.

That's because in :

  list<list<int>> TypeSig = !listconcat(
    [IIT_RetNumbers[!size(RetTypes)]],

There is OOB indexing into the IIT_RetNumbers list, resulting in an unresolved record or something like that.

@jurahul jurahul marked this pull request as ready for review September 5, 2024 04:19
@jurahul jurahul force-pushed the intrinsic_num_rets_check branch from 6e0a65e to 3da448b Compare September 5, 2024 15:21
Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful, thanks

Fail if we see an intrinsic that returns more than the supported
number of return values.

Intrinsics can return only upto a certain nyumber of values, as
defined by the `IIT_RetNumbers` list in Intrinsics.td. Currently,
if we define an intrinsic that exceeds the limit, llvm-tblgen
crashes. Instead, read this limit and fail its exceeded with a
proper error message.
@jurahul jurahul force-pushed the intrinsic_num_rets_check branch from 3da448b to a57bbb8 Compare September 5, 2024 17:49
@jurahul
Copy link
Contributor Author

jurahul commented Sep 5, 2024

updated unit test to reflect the lowecase error message.

@jurahul jurahul merged commit 50be455 into llvm:main Sep 5, 2024
8 checks passed
@jurahul jurahul deleted the intrinsic_num_rets_check branch September 5, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants