Skip to content

Commit

Permalink
[LLVM] Use std::move for APInt. NFC. (#86257)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed Mar 23, 2024
1 parent 6c1932f commit 2f1f6b7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion llvm/include/llvm/Analysis/InlineCost.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/Analysis/MemoryBuiltins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -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(const APInt &V) { return V.getBitWidth() > 1; }
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/LLVMContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/MergeICmps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2f1f6b7

Please sign in to comment.