Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Scalar/GVNSink.cpp
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | public: | ||||
// resultant order of elements in Blocks needs to be deterministic. | // resultant order of elements in Blocks needs to be deterministic. | ||||
// Using SmallPtrSet instead causes non-deterministic order while | // Using SmallPtrSet instead causes non-deterministic order while | ||||
// copying. And we cannot simply sort Blocks as they need to match the | // copying. And we cannot simply sort Blocks as they need to match the | ||||
// corresponding Values. | // corresponding Values. | ||||
SmallSetVector<BasicBlock *, 4> &getActiveBlocks() { return ActiveBlocks; } | SmallSetVector<BasicBlock *, 4> &getActiveBlocks() { return ActiveBlocks; } | ||||
void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) { | void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) { | ||||
for (auto II = Insts.begin(); II != Insts.end();) { | for (auto II = Insts.begin(); II != Insts.end();) { | ||||
if (!llvm::is_contained(Blocks, (*II)->getParent())) { | if (!Blocks.contains((*II)->getParent())) { | ||||
ActiveBlocks.remove((*II)->getParent()); | ActiveBlocks.remove((*II)->getParent()); | ||||
II = Insts.erase(II); | II = Insts.erase(II); | ||||
} else { | } else { | ||||
++II; | ++II; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | public: | ||||
/// Restrict the PHI's contents down to only \c NewBlocks. | /// Restrict the PHI's contents down to only \c NewBlocks. | ||||
/// \c NewBlocks must be a subset of \c this->Blocks. | /// \c NewBlocks must be a subset of \c this->Blocks. | ||||
void restrictToBlocks(const SmallSetVector<BasicBlock *, 4> &NewBlocks) { | void restrictToBlocks(const SmallSetVector<BasicBlock *, 4> &NewBlocks) { | ||||
auto BI = Blocks.begin(); | auto BI = Blocks.begin(); | ||||
auto VI = Values.begin(); | auto VI = Values.begin(); | ||||
while (BI != Blocks.end()) { | while (BI != Blocks.end()) { | ||||
assert(VI != Values.end()); | assert(VI != Values.end()); | ||||
if (!llvm::is_contained(NewBlocks, *BI)) { | if (!NewBlocks.contains(*BI)) { | ||||
BI = Blocks.erase(BI); | BI = Blocks.erase(BI); | ||||
VI = Values.erase(VI); | VI = Values.erase(VI); | ||||
} else { | } else { | ||||
++BI; | ++BI; | ||||
++VI; | ++VI; | ||||
} | } | ||||
} | } | ||||
assert(Blocks.size() == NewBlocks.size()); | assert(Blocks.size() == NewBlocks.size()); | ||||
▲ Show 20 Lines • Show All 613 Lines • Show Last 20 Lines |