[pdb] Write the IPI stream.

The IPI stream is structurally identical to the TPI stream, but it
contains different record types.  So we just re-use the TPI writing
code.

llvm-svn: 281638
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
index 40e3c79..165b03c 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
@@ -62,10 +62,16 @@
 
 TpiStreamBuilder &PDBFileBuilder::getTpiBuilder() {
   if (!Tpi)
-    Tpi = llvm::make_unique<TpiStreamBuilder>(*Msf);
+    Tpi = llvm::make_unique<TpiStreamBuilder>(*Msf, StreamTPI);
   return *Tpi;
 }
 
+TpiStreamBuilder &PDBFileBuilder::getIpiBuilder() {
+  if (!Ipi)
+    Ipi = llvm::make_unique<TpiStreamBuilder>(*Msf, StreamIPI);
+  return *Ipi;
+}
+
 Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() const {
   if (Info) {
     if (auto EC = Info->finalizeMsfLayout())
@@ -79,6 +85,10 @@
     if (auto EC = Tpi->finalizeMsfLayout())
       return std::move(EC);
   }
+  if (Ipi) {
+    if (auto EC = Ipi->finalizeMsfLayout())
+      return std::move(EC);
+  }
 
   return Msf->build();
 }
@@ -113,6 +123,13 @@
     File->Tpi = std::move(*ExpectedTpi);
   }
 
+  if (Ipi) {
+    auto ExpectedIpi = Ipi->build(*File, *PdbFileBuffer);
+    if (!ExpectedIpi)
+      return ExpectedIpi.takeError();
+    File->Ipi = std::move(*ExpectedIpi);
+  }
+
   if (File->Info && File->Dbi && File->Info->getAge() != File->Dbi->getAge())
     return llvm::make_error<RawError>(
         raw_error_code::corrupt_file,
@@ -166,5 +183,10 @@
       return EC;
   }
 
+  if (Ipi) {
+    if (auto EC = Ipi->commit(Layout, Buffer))
+      return EC;
+  }
+
   return Buffer.commit();
 }
\ No newline at end of file