File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
mlir/lib/Target/LLVMIR/Dialect/OpenMP Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1718,10 +1718,18 @@ static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) {
1718
1718
llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(teamsOp.getOperation ());
1719
1719
// Check that all uses of the reduction block arg has the same distribute op
1720
1720
// parent.
1721
+ llvm::SmallVector<mlir::Operation *> debugUses;
1721
1722
Operation *distOp = nullptr ;
1722
1723
for (auto ra : iface.getReductionBlockArgs ())
1723
1724
for (auto &use : ra.getUses ()) {
1724
1725
auto *useOp = use.getOwner ();
1726
+ // Ignore debug uses.
1727
+ if (mlir::isa<LLVM::DbgDeclareOp>(useOp) ||
1728
+ mlir::isa<LLVM::DbgValueOp>(useOp)) {
1729
+ debugUses.push_back (useOp);
1730
+ continue ;
1731
+ }
1732
+
1725
1733
auto currentDistOp = useOp->getParentOfType <omp::DistributeOp>();
1726
1734
// Use is not inside a distribute op - return false
1727
1735
if (!currentDistOp)
@@ -1733,6 +1741,12 @@ static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) {
1733
1741
1734
1742
distOp = currentOp;
1735
1743
}
1744
+
1745
+ // If we are going to use distribute reduction then remove any debug uses of
1746
+ // the reduction parameters in teamsOp. Otherwise they will be left without
1747
+ // any mapped value in moduleTranslation and will eventually error out.
1748
+ for (auto use : debugUses)
1749
+ use->erase ();
1736
1750
return true ;
1737
1751
}
1738
1752
You can’t perform that action at this time.
0 commit comments