Skip to content
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

Ambiguity between symbol visibility and linkage type in cir.func assembly format #69

Closed
sitio-couto opened this issue May 13, 2023 · 2 comments

Comments

@sitio-couto
Copy link
Collaborator

The following cir.func is valid and can be either a function with private linkage or a function with private symbol visibility.

cir.func private @func() -> ()

Both linkage and visibility tags are optional. In the example, only one is specified, however, it is impossible to know if private refers to linkage or symbol visibility since the keyword private is a valid value for both of these attributes.

// Default to external linkage if no keyword is provided.
state.addAttribute(getLinkageAttrNameString(),
GlobalLinkageKindAttr::get(
parser.getContext(),
parseOptionalCIRKeyword<GlobalLinkageKind>(
parser, GlobalLinkageKind::ExternalLinkage)));
::llvm::StringRef visAttrStr;
if (parser.parseOptionalKeyword(&visAttrStr, {"private", "public", "nested"})
.succeeded()) {
state.addAttribute(visNameAttr,
parser.getBuilder().getStringAttr(visAttrStr));
}

@bcardosolopes
Copy link
Member

I fixed this Friday by changing the linkage one to always be cir_private, so it's not ambiguous anymore. I found it while trying to full circle on a emitted test case (which is a good practice when doing CIRGen).

In the future I would like to get rid of the MLIR one somehow and implement our own CIR symbol rules based on linkage instead.

@sitio-couto
Copy link
Collaborator Author

Fixed in 2ae0230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants