[llvm] [Metadata] Use const APInt &. NFC (PR #101865)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 3 22:37:09 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

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
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);

``````````

</details>


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


More information about the llvm-commits mailing list