[llvm] [LLVM] Use `std::move` for APInt. NFC. (PR #86257)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 01:54:27 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Yingwei Zheng (dtcxzyw)
<details>
<summary>Changes</summary>
This patch adjusts argument passing for `APInt` to improve the compile-time.
Compile-time impact: https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=ba3e326def3a6e5cd6d72ff5a49c74fba18de1df&stat=instructions:u
---
Full diff: https://github.com/llvm/llvm-project/pull/86257.diff
6 Files Affected:
- (modified) llvm/include/llvm/Analysis/InlineCost.h (+2-1)
- (modified) llvm/include/llvm/Analysis/MemoryBuiltins.h (+4-2)
- (modified) llvm/lib/Analysis/ConstantFolding.cpp (+1-1)
- (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+4-2)
- (modified) llvm/lib/IR/LLVMContextImpl.h (+1-1)
- (modified) llvm/lib/Transforms/Scalar/MergeICmps.cpp (+1-1)
``````````diff
diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h
index 3a760e0a85cecf..c5978ce54fc18b 100644
--- a/llvm/include/llvm/Analysis/InlineCost.h
+++ b/llvm/include/llvm/Analysis/InlineCost.h
@@ -65,7 +65,8 @@ const char MaxInlineStackSizeAttributeName[] = "inline-max-stacksize";
// The cost-benefit pair computed by cost-benefit analysis.
class CostBenefitPair {
public:
- CostBenefitPair(APInt Cost, APInt Benefit) : Cost(Cost), Benefit(Benefit) {}
+ CostBenefitPair(APInt Cost, APInt Benefit)
+ : Cost(std::move(Cost)), Benefit(std::move(Benefit)) {}
const APInt &getCost() const { return Cost; }
diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h b/llvm/include/llvm/Analysis/MemoryBuiltins.h
index 37ce1518f00c08..d69b2f8bed0675 100644
--- a/llvm/include/llvm/Analysis/MemoryBuiltins.h
+++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h
@@ -196,7 +196,8 @@ template <typename T, class C> struct SizeOffsetType {
T Offset;
SizeOffsetType() = default;
- SizeOffsetType(T Size, T Offset) : Size(Size), Offset(Offset) {}
+ SizeOffsetType(T Size, T Offset)
+ : Size(std::move(Size)), Offset(std::move(Offset)) {}
bool knownSize() const { return C::known(Size); }
bool knownOffset() const { return C::known(Offset); }
@@ -215,7 +216,8 @@ template <typename T, class C> struct SizeOffsetType {
/// \p APInts.
struct SizeOffsetAPInt : public SizeOffsetType<APInt, SizeOffsetAPInt> {
SizeOffsetAPInt() = default;
- SizeOffsetAPInt(APInt Size, APInt Offset) : SizeOffsetType(Size, Offset) {}
+ SizeOffsetAPInt(APInt Size, APInt Offset)
+ : SizeOffsetType(std::move(Size), std::move(Offset)) {}
static bool known(APInt V) { return V.getBitWidth() > 1; }
};
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 6139b5be85be34..749374a3aa48af 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -751,7 +751,7 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
const DataLayout &DL) {
APInt Offset(DL.getIndexTypeSizeInBits(C->getType()), 0);
- return ConstantFoldLoadFromConstPtr(C, Ty, Offset, DL);
+ return ConstantFoldLoadFromConstPtr(C, Ty, std::move(Offset), DL);
}
Constant *llvm::ConstantFoldLoadFromUniformValue(Constant *C, Type *Ty,
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 7a37ae86c7f3c0..9ff3faff799027 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6115,7 +6115,8 @@ static Value *simplifyRelativeLoad(Constant *Ptr, Constant *Offset,
if (OffsetInt.srem(4) != 0)
return nullptr;
- Constant *Loaded = ConstantFoldLoadFromConstPtr(Ptr, Int32Ty, OffsetInt, DL);
+ Constant *Loaded =
+ ConstantFoldLoadFromConstPtr(Ptr, Int32Ty, std::move(OffsetInt), DL);
if (!Loaded)
return nullptr;
@@ -6983,7 +6984,8 @@ Value *llvm::simplifyLoadInst(LoadInst *LI, Value *PtrOp,
if (PtrOp == GV) {
// Index size may have changed due to address space casts.
Offset = Offset.sextOrTrunc(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()));
- return ConstantFoldLoadFromConstPtr(GV, LI->getType(), Offset, Q.DL);
+ return ConstantFoldLoadFromConstPtr(GV, LI->getType(), std::move(Offset),
+ Q.DL);
}
return nullptr;
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 58e0f21244f786..7c67e191348eaf 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -441,7 +441,7 @@ template <> struct MDNodeKeyImpl<DIEnumerator> {
bool IsUnsigned;
MDNodeKeyImpl(APInt Value, bool IsUnsigned, MDString *Name)
- : Value(Value), Name(Name), IsUnsigned(IsUnsigned) {}
+ : Value(std::move(Value)), Name(Name), IsUnsigned(IsUnsigned) {}
MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
: Value(APInt(64, Value, !IsUnsigned)), Name(Name),
IsUnsigned(IsUnsigned) {}
diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index 1e09067175499c..2bd13556c69663 100644
--- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -74,7 +74,7 @@ namespace {
struct BCEAtom {
BCEAtom() = default;
BCEAtom(GetElementPtrInst *GEP, LoadInst *LoadI, int BaseId, APInt Offset)
- : GEP(GEP), LoadI(LoadI), BaseId(BaseId), Offset(Offset) {}
+ : GEP(GEP), LoadI(LoadI), BaseId(BaseId), Offset(std::move(Offset)) {}
BCEAtom(const BCEAtom &) = delete;
BCEAtom &operator=(const BCEAtom &) = delete;
``````````
</details>
https://github.com/llvm/llvm-project/pull/86257
More information about the llvm-commits
mailing list