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

[BOLT][RISCV] Carry-over annotations when fixing calls #66763

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

mtvec
Copy link
Contributor

@mtvec mtvec commented Sep 19, 2023

FixRISCVCallsPass changes all different forms of calls to PseudoCALL instructions. However, the original call's annotations were lost in the process.

This patch fixes this by moving all annotations from the old to the new call. MCPlusBuilder::moveAnnotations had to be made public for this.

`FixRISCVCallsPass` changes all different forms of calls to `PseudoCALL`
instructions. However, the original call's annotations were lost in the
process.

This patch fixes this by moving all annotations from the old to the new
call. `MCPlusBuilder::moveAnnotations` had to be made public for this.
Copy link
Member

@yota9 yota9 left a comment

Choose a reason for hiding this comment

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

overall lgtm. I had the same problems with golang, be aware that BF.fixBranches() may replace instructions and not preserve annotations too

@@ -39,8 +41,19 @@ void FixRISCVCallsPass::runOnFunction(BinaryFunction &BF) {
auto *Target = MIB->getTargetSymbol(*II);
assert(Target && "Cannot find call target");

auto OldCall = *NextII;
Copy link
Member

Choose a reason for hiding this comment

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

We've got a policy to not using auto if it is not necessary, please minimise their usage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, up to now my BOLT contributions have been using auto heavily. Is this policy written down somewhere or could you explain when auto is considered ok to use?

Copy link
Member

@yota9 yota9 Sep 19, 2023

Choose a reason for hiding this comment

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

Let the Meta team members to clarify, they even has patches for auto expansion and asked me couple years ago. Maybe the policy changed. At least the LLVM coding standard says:

Don’t “almost always” use auto, but do use auto with initializers like cast(...) or other places where the type is already obvious from the context.

E.g. here it is obviously MCInst or MCSymbol above & etc, so it seems to be fine from this stand point. I don't really insist, but as for me I don't really like autos too except for complex types with smth like returning std::vector with std::pair elements.. Let Meta team members say their opinion, maybe I shall use it more frequently too :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should stick to LLVM policy of only using auto in small number of cases (the type is obvious (casts), the type doesn't matter (lambdas), template type). Making type explicit helps with reviewing where we have limited context window by default.

@aaupov
Copy link
Contributor

aaupov commented Sep 20, 2023

Looks good but please expand the autos before merging.

@mtvec mtvec merged commit dc925be into llvm:main Sep 21, 2023
@mtvec mtvec deleted the bolt-riscv-call-annotations branch September 21, 2023 06:37
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