BCEAtom(GetElementPtrInst *GEP, LoadInst *LoadI, int BaseId, APInt Offset)
: GEP(GEP), LoadI(LoadI), BaseId(BaseId), Offset(Offset) {}
+ BCEAtom(const BCEAtom &) = delete;
+ BCEAtom &operator=(const BCEAtom &) = delete;
+
+ BCEAtom(BCEAtom &&that) = default;
+ BCEAtom &operator=(BCEAtom &&that) {
+ if (this == &that)
+ return *this;
+ GEP = that.GEP;
+ LoadI = that.LoadI;
+ BaseId = that.BaseId;
+ Offset = std::move(that.Offset);
+ return *this;
+ }
+
// We want to order BCEAtoms by (Base, Offset). However we cannot use
// the pointer values for Base because these are non-deterministic.
// To make sure that the sort order is stable, we first assign to each atom
BCECmpBlock() {}
BCECmpBlock(BCEAtom L, BCEAtom R, int SizeBits)
- : Lhs_(L), Rhs_(R), SizeBits_(SizeBits) {
+ : Lhs_(std::move(L)), Rhs_(std::move(R)), SizeBits_(SizeBits) {
if (Rhs_ < Lhs_) std::swap(Rhs_, Lhs_);
}
}
static inline void enqueueBlock(std::vector<BCECmpBlock> &Comparisons,
- BCECmpBlock &Comparison) {
+ BCECmpBlock &&Comparison) {
LLVM_DEBUG(dbgs() << "Block '" << Comparison.BB->getName()
<< "': Found cmp of " << Comparison.SizeBits()
<< " bits between " << Comparison.Lhs().BaseId << " + "
<< Comparison.Rhs().BaseId << " + "
<< Comparison.Rhs().Offset << "\n");
LLVM_DEBUG(dbgs() << "\n");
- Comparisons.push_back(Comparison);
+ Comparisons.push_back(std::move(Comparison));
}
// A chain of comparisons.
<< "Split initial block '" << Comparison.BB->getName()
<< "' that does extra work besides compare\n");
Comparison.RequireSplit = true;
- enqueueBlock(Comparisons, Comparison);
+ enqueueBlock(Comparisons, std::move(Comparison));
} else {
LLVM_DEBUG(dbgs()
<< "ignoring initial block '" << Comparison.BB->getName()
// We could still merge bb1 and bb2 though.
return;
}
- enqueueBlock(Comparisons, Comparison);
+ enqueueBlock(Comparisons, std::move(Comparison));
}
// It is possible we have no suitable comparison to merge.