Improve management of instructions and basic blocks by having their inclusion
in a container automatically maintain their parent pointers, and change storage
from std::vector to the proper llvm::iplist type.

PiperOrigin-RevId: 202889037
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index 067697c..c1c1d94 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -94,7 +94,7 @@
 private:
   const CFGFunction *function;
   raw_ostream &os;
-  DenseMap<BasicBlock*, unsigned> basicBlockIDs;
+  DenseMap<const BasicBlock*, unsigned> basicBlockIDs;
 };
 } // end anonymous namespace
 
@@ -103,8 +103,8 @@
 
   // Each basic block gets a unique ID per function.
   unsigned blockID = 0;
-  for (auto *block : function->blockList)
-    basicBlockIDs[block] = blockID++;
+  for (auto &block : *function)
+    basicBlockIDs[&block] = blockID++;
 }
 
 void CFGFunctionState::print() {
@@ -112,8 +112,8 @@
   printFunctionSignature(this->getFunction(), os);
   os << " {\n";
 
-  for (auto *block : function->blockList)
-    print(block);
+  for (auto &block : *function)
+    print(&block);
   os << "}\n\n";
 }
 
@@ -121,8 +121,8 @@
   os << "bb" << getBBID(block) << ":\n";
 
   // TODO Print arguments.
-  for (auto inst : block->instList)
-    print(inst);
+  for (auto &inst : block->getOperations())
+    print(&inst);
 
   print(block->getTerminator());
 }