Skip to content

[CIR][CodeGen] Attach hot attribute to CIR function #1826

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rafasumi
Copy link

Implemented missing feature for issue #1793. Also implemented LLVM lowering for the hot attribute, and added a new test case.

@rafasumi rafasumi changed the title [CIR] Attach hot attribute to CIR function [CIR][CodeGen] Attach hot attribute to CIR function Aug 15, 2025
Copy link
Contributor

@tommymcm tommymcm left a comment

Choose a reason for hiding this comment

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

LGTM with a few nits

Also, if you didn't already, try using mlir/utils/generate_test_checks.py to generate test checks automatically with a uniform format.

Comment on lines 76 to 79
llvm::ConstantAsMetadata::get(
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMajorVersion())),
llvm::ConstantAsMetadata::get(
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMinorVersion()))};
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
int32Ty, openclVersionAttr.getMajorVersion())),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
int32Ty, openclVersionAttr.getMinorVersion()))};
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks unrelated

Copy link
Author

Choose a reason for hiding this comment

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

This change was made by clang-format when I ran it for this file. I can revert it if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you could revert so blame doesn't get messed up that'd be great.

Copy link
Author

Choose a reason for hiding this comment

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

Sure! Makes sense.

}

// CIR: #fn_attr = #cir<extra({hot = #cir.hot, nothrow = #cir.nothrow})>
// CIR: cir.func dso_local @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you refractor this so that it doesn't include hard coded names like %arg0 and %arg1.

Copy link
Author

Choose a reason for hiding this comment

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

I made some changes to the test to make it depend less on unrelated identifiers. I tried using mlir/utils/generate_test_checks.py, but I think the result was also a bit hard-coded. This is a great script though, thanks for the tip.

Copy link
Contributor

Choose a reason for hiding this comment

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

I usually use generated checks as a starting point, then remove parts and rename variables to reflect the soul of the test.

}

// CIR: #fn_attr = #cir<extra({hot = #cir.hot, nothrow = #cir.nothrow})>
// CIR: cir.func dso_local @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also break it up so that each part of the check is on a different comment line using CIR-SAME

Copy link
Author

Choose a reason for hiding this comment

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

I've removed arguments from the check, so maybe this is less necessary. However, I’ve split it into two checks either way.

Copy link
Contributor

@tommymcm tommymcm left a comment

Choose a reason for hiding this comment

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

lgtm
If you can revert those formatting changes it would be appreciated. I try to only format the code regions that I change to avoid getting myself in the blame chain :^)

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.

3 participants