Push location information more tightly into the IR, providing space for every
operation and statement to have a location, and make it so a location is
required to be specified whenever you make one (though a null location is still
allowed). This is to encourage compiler authors to propagate loc info
properly, allowing our failability story to work well.
This is still a WIP - it isn't clear if we want to continue abusing Attribute
for location information, or whether we should introduce a new class heirarchy
to do so. This is good step along the way, and unblocks some of the tf/xla
work that builds upon it.
PiperOrigin-RevId: 210001406
diff --git a/lib/Transforms/LoopUnroll.cpp b/lib/Transforms/LoopUnroll.cpp
index a4a11a7..ffb2947 100644
--- a/lib/Transforms/LoopUnroll.cpp
+++ b/lib/Transforms/LoopUnroll.cpp
@@ -196,7 +196,8 @@
// value and add an operand mapping for it.
if (!forStmt->use_empty()) {
auto *ivConst =
- funcTopBuilder.create<ConstantAffineIntOp>(i)->getResult();
+ funcTopBuilder.create<ConstantAffineIntOp>(forStmt->getLoc(), i)
+ ->getResult();
operandMapping[forStmt] = cast<MLValue>(ivConst);
}
@@ -261,7 +262,8 @@
builder.getConstantExpr(i * step));
auto *bumpMap = builder.getAffineMap(1, 0, {bumpExpr}, {});
auto *ivUnroll =
- builder.create<AffineApplyOp>(bumpMap, forStmt)->getResult(0);
+ builder.create<AffineApplyOp>(forStmt->getLoc(), bumpMap, forStmt)
+ ->getResult(0);
operandMapping[forStmt] = cast<MLValue>(ivUnroll);
}