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/IR/Builders.cpp b/lib/IR/Builders.cpp
index 73beea6..bd78929 100644
--- a/lib/IR/Builders.cpp
+++ b/lib/IR/Builders.cpp
@@ -182,8 +182,8 @@
   for (auto elt : state.operands)
     operands.push_back(cast<CFGValue>(elt));
 
-  auto *op = OperationInst::create(state.name, operands, state.types,
-                                   state.attributes, context);
+  auto *op = OperationInst::create(state.location, state.name, operands,
+                                   state.types, state.attributes, context);
   block->getOperations().insert(insertPoint, op);
   return op;
 }
@@ -199,16 +199,23 @@
   for (auto elt : state.operands)
     operands.push_back(cast<MLValue>(elt));
 
-  auto *op = OperationStmt::create(state.name, operands, state.types,
-                                   state.attributes, context);
+  auto *op = OperationStmt::create(state.location, state.name, operands,
+                                   state.types, state.attributes, context);
   block->getStatements().insert(insertPoint, op);
   return op;
 }
 
-ForStmt *MLFuncBuilder::createFor(AffineConstantExpr *lowerBound,
+ForStmt *MLFuncBuilder::createFor(Attribute *location,
+                                  AffineConstantExpr *lowerBound,
                                   AffineConstantExpr *upperBound,
                                   int64_t step) {
-  auto *stmt = new ForStmt(lowerBound, upperBound, step, context);
+  auto *stmt = new ForStmt(location, lowerBound, upperBound, step, context);
+  block->getStatements().insert(insertPoint, stmt);
+  return stmt;
+}
+
+IfStmt *MLFuncBuilder::createIf(Attribute *location, IntegerSet *condition) {
+  auto *stmt = new IfStmt(location, condition);
   block->getStatements().insert(insertPoint, stmt);
   return stmt;
 }