MLStmt cloning and IV replacement for loop unrolling, add constant pool to
MLFunctions.

- MLStmt cloning and IV replacement
- While at this, fix the innermostLoopGatherer to actually gather all the
  innermost loops (it was stopping its walk at the first innermost loop it
  found)
- Improve comments for MLFunction statement classes, fix inheritance order.

- Fixed StmtBlock destructor.

PiperOrigin-RevId: 207049173
diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp
index a10cb3a..847907b 100644
--- a/lib/IR/Instructions.cpp
+++ b/lib/IR/Instructions.cpp
@@ -145,6 +145,21 @@
   return inst;
 }
 
+OperationInst *OperationInst::clone() const {
+  SmallVector<CFGValue *, 8> operands;
+  SmallVector<Type *, 8> resultTypes;
+
+  // TODO(clattner): switch to iterator logic.
+  // Put together the operands and results.
+  for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
+    operands.push_back(getInstOperand(i).get());
+
+  for (unsigned i = 0, e = getNumResults(); i != e; ++i)
+    resultTypes.push_back(getInstResult(i).getType());
+
+  return create(getName(), operands, resultTypes, getAttrs(), getContext());
+}
+
 OperationInst::OperationInst(Identifier name, unsigned numOperands,
                              unsigned numResults,
                              ArrayRef<NamedAttribute> attributes,