-
Notifications
You must be signed in to change notification settings - Fork 160
[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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
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()))}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unrelated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Makes sense.
clang/test/CIR/CodeGen/hot-attr.cpp
Outdated
} | ||
|
||
// CIR: #fn_attr = #cir<extra({hot = #cir.hot, nothrow = #cir.nothrow})> | ||
// CIR: cir.func dso_local @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
clang/test/CIR/CodeGen/hot-attr.cpp
Outdated
} | ||
|
||
// CIR: #fn_attr = #cir<extra({hot = #cir.hot, nothrow = #cir.nothrow})> | ||
// CIR: cir.func dso_local @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :^)
Implemented missing feature for issue #1793. Also implemented LLVM lowering for the hot attribute, and added a new test case.