diff --git a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td --- a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td +++ b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td @@ -98,7 +98,7 @@ static bool hasNoEffect(Operation *op) { if (auto interface = dyn_cast<}] # name # [{>(op)) return interface.hasNoEffect(); - return op->hasTrait<::mlir::OpTrait::HasRecursiveMemoryEffects>(); + return !op->hasTrait<::mlir::OpTrait::HasRecursiveMemoryEffects>(); } /// Collect all of the effect instances that operate on the provided value diff --git a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp --- a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp @@ -340,13 +340,20 @@ // inserts the necessary synchronization (as gpu.wait ops). Assumes sequential // execution semantics and that no GPU ops are asynchronous yet. void GpuAsyncRegionPass::runOnOperation() { - if (getOperation()->walk(ThreadTokenCallback(getContext())).wasInterrupted()) + auto operation = getOperation(); + if (operation->walk(ThreadTokenCallback(getContext())).wasInterrupted()) return signalPassFailure(); // Collect gpu.wait ops that we can move out of async.execute regions. - getOperation().getRegion().walk(DeferWaitCallback()); - // Makes each !gpu.async.token returned from async.execute op have single use. - getOperation().getRegion().walk(SingleTokenUseCallback()); + if (operation->getNumRegions() != 0) { + Region ®ion = operation.getRegion(); + if (!region.empty()) { + region.walk(DeferWaitCallback()); + // Makes each !gpu.async.token returned from async.execute op have single + // use. + region.walk(SingleTokenUseCallback()); + } + } } std::unique_ptr> mlir::createGpuAsyncRegionPass() {