Skip to content

Commit 2f1f6b7

Browse files
authored
[LLVM] Use std::move for APInt. NFC. (#86257)
This patch adjusts argument passing for `APInt` to improve the compile-time. Compile-time improvement: https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=ba3e326def3a6e5cd6d72ff5a49c74fba18de1df&stat=instructions:u
1 parent 6c1932f commit 2f1f6b7

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

llvm/include/llvm/Analysis/InlineCost.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ const char MaxInlineStackSizeAttributeName[] = "inline-max-stacksize";
6565
// The cost-benefit pair computed by cost-benefit analysis.
6666
class CostBenefitPair {
6767
public:
68-
CostBenefitPair(APInt Cost, APInt Benefit) : Cost(Cost), Benefit(Benefit) {}
68+
CostBenefitPair(APInt Cost, APInt Benefit)
69+
: Cost(std::move(Cost)), Benefit(std::move(Benefit)) {}
6970

7071
const APInt &getCost() const { return Cost; }
7172

llvm/include/llvm/Analysis/MemoryBuiltins.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ template <typename T, class C> struct SizeOffsetType {
196196
T Offset;
197197

198198
SizeOffsetType() = default;
199-
SizeOffsetType(T Size, T Offset) : Size(Size), Offset(Offset) {}
199+
SizeOffsetType(T Size, T Offset)
200+
: Size(std::move(Size)), Offset(std::move(Offset)) {}
200201

201202
bool knownSize() const { return C::known(Size); }
202203
bool knownOffset() const { return C::known(Offset); }
@@ -215,7 +216,8 @@ template <typename T, class C> struct SizeOffsetType {
215216
/// \p APInts.
216217
struct SizeOffsetAPInt : public SizeOffsetType<APInt, SizeOffsetAPInt> {
217218
SizeOffsetAPInt() = default;
218-
SizeOffsetAPInt(APInt Size, APInt Offset) : SizeOffsetType(Size, Offset) {}
219+
SizeOffsetAPInt(APInt Size, APInt Offset)
220+
: SizeOffsetType(std::move(Size), std::move(Offset)) {}
219221

220222
static bool known(const APInt &V) { return V.getBitWidth() > 1; }
221223
};

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
751751
Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
752752
const DataLayout &DL) {
753753
APInt Offset(DL.getIndexTypeSizeInBits(C->getType()), 0);
754-
return ConstantFoldLoadFromConstPtr(C, Ty, Offset, DL);
754+
return ConstantFoldLoadFromConstPtr(C, Ty, std::move(Offset), DL);
755755
}
756756

757757
Constant *llvm::ConstantFoldLoadFromUniformValue(Constant *C, Type *Ty,

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6115,7 +6115,8 @@ static Value *simplifyRelativeLoad(Constant *Ptr, Constant *Offset,
61156115
if (OffsetInt.srem(4) != 0)
61166116
return nullptr;
61176117

6118-
Constant *Loaded = ConstantFoldLoadFromConstPtr(Ptr, Int32Ty, OffsetInt, DL);
6118+
Constant *Loaded =
6119+
ConstantFoldLoadFromConstPtr(Ptr, Int32Ty, std::move(OffsetInt), DL);
61196120
if (!Loaded)
61206121
return nullptr;
61216122

@@ -6983,7 +6984,8 @@ Value *llvm::simplifyLoadInst(LoadInst *LI, Value *PtrOp,
69836984
if (PtrOp == GV) {
69846985
// Index size may have changed due to address space casts.
69856986
Offset = Offset.sextOrTrunc(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()));
6986-
return ConstantFoldLoadFromConstPtr(GV, LI->getType(), Offset, Q.DL);
6987+
return ConstantFoldLoadFromConstPtr(GV, LI->getType(), std::move(Offset),
6988+
Q.DL);
69876989
}
69886990

69896991
return nullptr;

llvm/lib/IR/LLVMContextImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ template <> struct MDNodeKeyImpl<DIEnumerator> {
441441
bool IsUnsigned;
442442

443443
MDNodeKeyImpl(APInt Value, bool IsUnsigned, MDString *Name)
444-
: Value(Value), Name(Name), IsUnsigned(IsUnsigned) {}
444+
: Value(std::move(Value)), Name(Name), IsUnsigned(IsUnsigned) {}
445445
MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
446446
: Value(APInt(64, Value, !IsUnsigned)), Name(Name),
447447
IsUnsigned(IsUnsigned) {}

llvm/lib/Transforms/Scalar/MergeICmps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace {
7474
struct BCEAtom {
7575
BCEAtom() = default;
7676
BCEAtom(GetElementPtrInst *GEP, LoadInst *LoadI, int BaseId, APInt Offset)
77-
: GEP(GEP), LoadI(LoadI), BaseId(BaseId), Offset(Offset) {}
77+
: GEP(GEP), LoadI(LoadI), BaseId(BaseId), Offset(std::move(Offset)) {}
7878

7979
BCEAtom(const BCEAtom &) = delete;
8080
BCEAtom &operator=(const BCEAtom &) = delete;

0 commit comments

Comments
 (0)