Skip to content

Commit

Permalink
Revert r361257 "[MergeICmps][NFC] Make BCEAtom move-only."
Browse files Browse the repository at this point in the history
Broke some bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361263 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
legrosbuffle committed May 21, 2019
1 parent 850411b commit 1551f6f
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions lib/Transforms/Scalar/MergeICmps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,6 @@ struct BCEAtom {
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
Expand Down Expand Up @@ -189,7 +175,7 @@ class BCECmpBlock {
BCECmpBlock() {}

BCECmpBlock(BCEAtom L, BCEAtom R, int SizeBits)
: Lhs_(std::move(L)), Rhs_(std::move(R)), SizeBits_(SizeBits) {
: Lhs_(L), Rhs_(R), SizeBits_(SizeBits) {
if (Rhs_ < Lhs_) std::swap(Rhs_, Lhs_);
}

Expand Down Expand Up @@ -390,15 +376,15 @@ BCECmpBlock visitCmpBlock(Value *const Val, BasicBlock *const Block,
}

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.Lhs().Offset << " and "
<< Comparison.Rhs().BaseId << " + "
<< Comparison.Rhs().Offset << "\n");
LLVM_DEBUG(dbgs() << "\n");
Comparisons.push_back(std::move(Comparison));
Comparisons.push_back(Comparison);
}

// A chain of comparisons.
Expand Down Expand Up @@ -470,7 +456,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi,
<< "Split initial block '" << Comparison.BB->getName()
<< "' that does extra work besides compare\n");
Comparison.RequireSplit = true;
enqueueBlock(Comparisons, std::move(Comparison));
enqueueBlock(Comparisons, Comparison);
} else {
LLVM_DEBUG(dbgs()
<< "ignoring initial block '" << Comparison.BB->getName()
Expand Down Expand Up @@ -503,7 +489,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi,
// We could still merge bb1 and bb2 though.
return;
}
enqueueBlock(Comparisons, std::move(Comparison));
enqueueBlock(Comparisons, Comparison);
}

// It is possible we have no suitable comparison to merge.
Expand All @@ -521,7 +507,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi,
// semantics because we are only accessing dereferencable memory.
llvm::sort(Comparisons_,
[](const BCECmpBlock &LhsBlock, const BCECmpBlock &RhsBlock) {
return LhsBlock.Rhs() < RhsBlock.Lhs();
return LhsBlock.Lhs() < RhsBlock.Lhs();
});
#ifdef MERGEICMPS_DOT_ON
errs() << "AFTER REORDERING:\n\n";
Expand Down

0 comments on commit 1551f6f

Please sign in to comment.