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

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 4 14:51:30 PDT 2024


Author: Craig Topper
Date: 2024-08-04T14:51:27-07:00
New Revision: d34191102ae84352b047498825ab9dd9c8777f98

URL: https://github.com/llvm/llvm-project/commit/d34191102ae84352b047498825ab9dd9c8777f98
DIFF: https://github.com/llvm/llvm-project/commit/d34191102ae84352b047498825ab9dd9c8777f98.diff

LOG: [Metadata] Use const APInt &. NFC (#101865)

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

Added: 
    

Modified: 
    llvm/lib/IR/Metadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index fd2f4d184162f..8669825749d83 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);


        


More information about the llvm-commits mailing list