-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[TargetLibraryInfo] Use std::move (NFC) #95671
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
[TargetLibraryInfo] Use std::move (NFC) #95671
Conversation
The std::move here saves 0.11% of heap allocations during the compilation of a large preprocessed file, namely X86ISelLowering.cpp, for the X86 target.
@llvm/pr-subscribers-llvm-analysis Author: Kazu Hirata (kazutakahirata) ChangesThe std::move here saves 0.11% of heap allocations during the Full diff: https://github.com/llvm/llvm-project/pull/95671.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index f5da222d11f55..b29046a969448 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -316,7 +316,8 @@ class TargetLibraryInfo {
// Provide value semantics.
TargetLibraryInfo(const TargetLibraryInfo &TLI) = default;
TargetLibraryInfo(TargetLibraryInfo &&TLI)
- : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
+ : Impl(TLI.Impl),
+ OverrideAsUnavailable(std::move(TLI.OverrideAsUnavailable)) {}
TargetLibraryInfo &operator=(const TargetLibraryInfo &TLI) = default;
TargetLibraryInfo &operator=(TargetLibraryInfo &&TLI) {
Impl = TLI.Impl;
|
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.
Could you please make the same change in the move assignment operator as well?
Fixed in the latest iteration. Thanks! |
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
Looking at this again, you could probably also use |
Great idea! We have one user-declared constructor a few lines above, so I would have to use |
I just posted #95685 as a follow-up for this PR. |
The std::move here saves 0.11% of heap allocations during the
compilation of a large preprocessed file, namely X86ISelLowering.cpp,
for the X86 target.