13 #include "llvm/ADT/SetOperations.h"
14 #include "llvm/ADT/SetVector.h"
28 queue.push_back(rootValue);
29 while (!queue.empty()) {
30 Value currentValue = queue.pop_back_val();
31 if (result.insert(currentValue).second) {
32 auto it = dependencies.find(currentValue);
33 if (it != dependencies.end()) {
34 for (
Value aliasValue : it->second)
35 queue.push_back(aliasValue);
44 for (
auto &entry : dependencies)
45 llvm::set_subtract(entry.second, aliasValues);
49 dependencies[to] = dependencies[from];
50 dependencies.erase(from);
52 for (
auto &[key, value] : dependencies) {
53 if (value.contains(from)) {
65 void BufferViewFlowAnalysis::build(
Operation *op) {
68 for (
auto [value, dep] : llvm::zip(values, dependencies))
69 this->dependencies[value].insert(dep);
77 if (
auto viewInterface = dyn_cast<ViewLikeOpInterface>(op)) {
78 dependencies[viewInterface.getViewSource()].insert(
79 viewInterface->getResult(0));
83 if (
auto branchInterface = dyn_cast<BranchOpInterface>(op)) {
85 Block *parentBlock = branchInterface->getBlock();
89 auto successorOperands =
90 branchInterface.getSuccessorOperands(it.getIndex());
92 registerDependencies(successorOperands.getForwardedOperands(),
93 (*it)->getArguments().drop_front(
94 successorOperands.getProducedOperandCount()));
99 if (
auto regionInterface = dyn_cast<RegionBranchOpInterface>(op)) {
108 registerDependencies(
109 regionInterface.getEntrySuccessorOperands(entrySuccessor),
110 entrySuccessor.getSuccessorInputs());
114 for (
Region ®ion : regionInterface->getRegions()) {
118 regionInterface.getSuccessorRegions(region, successorRegions);
122 for (
Block &block : region)
123 if (
auto terminator = dyn_cast<RegionBranchTerminatorOpInterface>(
124 block.getTerminator()))
125 registerDependencies(
126 terminator.getSuccessorOperands(successorRegion),
127 successorRegion.getSuccessorInputs());
136 if (!isa<BaseMemRefType>(operand.getType()))
139 if (!isa<BaseMemRefType>(result.getType()))
141 registerDependencies({operand}, {result});
Block represents an ordered list of Operations.
succ_iterator succ_begin()
BufferViewFlowAnalysis(Operation *op)
Constructs a new alias analysis using the op provided.
void remove(const SetVector< Value > &aliasValues)
Removes the given values from all alias sets.
ValueSetT resolve(Value value) const
Find all immediate and indirect views upon this value.
void rename(Value from, Value to)
Replaces all occurrences of 'from' in the internal datastructures with 'to'.
Operation is the basic unit of execution within MLIR.
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
operand_range getOperands()
Returns an iterator on the underlying Value's.
result_range getResults()
static constexpr RegionBranchPoint parent()
Returns an instance of RegionBranchPoint representing the parent operation.
This class represents a successor of a region.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
static WalkResult advance()
Include the generated interface declarations.