Skip to content

Commit a24d399

Browse files
committed
Fix dependence on TransformUtils
This commit fixes the failure when building with shared lib. `visitUsedValuesDefinedAbove` is defined in `MLIRTransformUtils` but that depends on this lib (`MLIRAnalysis`). The fix is to drop the use of `visitUsedValuesDefinedAbove` and use `Region::walk` to traverse values defined above.
1 parent 27a1914 commit a24d399

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

mlir/lib/Analysis/SliceAnalysis.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "mlir/IR/Operation.h"
1717
#include "mlir/Interfaces/SideEffectInterfaces.h"
1818
#include "mlir/Support/LLVM.h"
19-
#include "mlir/Transforms/RegionUtils.h"
2019
#include "llvm/ADT/STLExtras.h"
2120
#include "llvm/ADT/SetVector.h"
2221
#include "llvm/ADT/SmallPtrSet.h"
@@ -117,8 +116,18 @@ static void getBackwardSliceImpl(Operation *op,
117116
};
118117

119118
if (!options.omitUsesFromAbove) {
120-
visitUsedValuesDefinedAbove(op->getRegions(), [&](OpOperand *operand) {
121-
processValue(operand->get());
119+
llvm::for_each(op->getRegions(), [&](Region &region) {
120+
// Walk this region recursively to collect the regions that descend from
121+
// this op's nested regions (inclusive).
122+
SmallPtrSet<Region *, 4> descendents;
123+
region.walk(
124+
[&](Region *childRegion) { descendents.insert(childRegion); });
125+
region.walk([&](Operation *op) {
126+
for (OpOperand &operand : op->getOpOperands()) {
127+
if (!descendents.contains(operand.get().getParentRegion()))
128+
processValue(operand.get());
129+
}
130+
});
122131
});
123132
}
124133
llvm::for_each(op->getOperands(), processValue);

0 commit comments

Comments
 (0)