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

[CIR][CIRGen] Add setNonAliasAttributes for GlobalOp and FuncOp #707

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

ghehg
Copy link
Contributor

@ghehg ghehg commented Jun 29, 2024

In this PR:
as title we added setNonAliasAttributes in the skeleton of OG's setNonAliasAttributes, and call this function in buildGlobalFunctionDefinition after code for FuncOP is generated. This is needed for CIR OG to know FuncOP is not declaration anymore, thus giving shouldAssumeDsoLocal another run to make dso_local right.

A couple of notes about test;

  1. having to changed driver.c, because in terms of dso_local for func, masOS is different from other targets as even in OG, as macOS is !isOSBinFormatELF(), thus even OG doesn't set dso_local for its functions.

  2. most of functions in existing tests still not getting dso_local in LLVM yet because they fall into case of (RM != llvm::Reloc::Static && !LOpts.PIE) , which is more complicated to implement as we need to get canBenefitFromLocalAlias right. So I treated it as a missing feature and default it to false. We gonna leave it to another PR to address. In this PR, I just added additional test with -fpie option to my test so we get dso_local for functions without having to deal with this case.

Next 2 PRs:
PR1. call setNonAliasAttributes in buildGlobalVarDefinition, after initialization for GlobalOP is found, similar to FuncOp.
didn't to it in this PR as there are many more test cases needed to be fixed/added for this case.
PR2: try to implement canBenefitFromLocalAlias.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for adding the macOS bits too.

}

if (const auto *CSA = D->getAttr<CodeSegAttr>()) {
assert(!MissingFeatures::setSectionForFuncOp());
Copy link
Member

Choose a reason for hiding this comment

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

@roro47 back to our discussion about sections, perhaps this could be related with the linker problem?

@bcardosolopes bcardosolopes changed the title [CIR][CIRGen]add setNonAliasAttributes for GlobalOp and FuncOp, call it after FuncOP def generated [CIR][CIRGen] Add setNonAliasAttributes for GlobalOp and FuncOp Jul 2, 2024
@bcardosolopes bcardosolopes merged commit f907c42 into llvm:main Jul 2, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants