Skip to content

[Metadata] Use const APInt &. NFC #101865

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

Merged
merged 1 commit into from
Aug 4, 2024
Merged

[Metadata] Use const APInt &. NFC #101865

merged 1 commit into from
Aug 4, 2024

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Aug 4, 2024

getValue returns a const APInt &. So using a const APInt & will avoid a copy.

getValue returns a const APInt &. So using a const APInt & will avoid a
copy.
@topperc topperc requested a review from nikic August 4, 2024 05:36
@llvmbot llvmbot added the llvm:ir label Aug 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2024

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

Changes

getValue returns a const APInt &. So using a const APInt & will avoid a copy.


Full diff: https://github.com/llvm/llvm-project/pull/101865.diff

1 Files Affected:

  • (modified) llvm/lib/IR/Metadata.cpp (+2-2)
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index ae5f5de142328..51442b94a6246 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -1250,8 +1250,8 @@ static bool tryMergeRange(SmallVectorImpl<ConstantInt *> &EndPoints,
                           ConstantInt *Low, ConstantInt *High) {
   ConstantRange NewRange(Low->getValue(), High->getValue());
   unsigned Size = EndPoints.size();
-  APInt LB = EndPoints[Size - 2]->getValue();
-  APInt LE = EndPoints[Size - 1]->getValue();
+  const APInt &LB = EndPoints[Size - 2]->getValue();
+  const APInt &LE = EndPoints[Size - 1]->getValue();
   ConstantRange LastRange(LB, LE);
   if (canBeMerged(NewRange, LastRange)) {
     ConstantRange Union = LastRange.unionWith(NewRange);

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

@topperc topperc merged commit d341911 into llvm:main Aug 4, 2024
9 checks passed
@topperc topperc deleted the pr/metadata branch August 4, 2024 21:51
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