MC: Explicity track section and fragment ordinals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99500 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 8efc78c..5190239 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -568,6 +568,18 @@
       llvm::errs() << "assembler backend - pre-layout\n--\n";
       dump(); });
 
+  // Assign section and fragment ordinals, all subsequent backend code is
+  // responsible for updating these in place.
+  unsigned SectionIndex = 0;
+  unsigned FragmentIndex = 0;
+  for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
+    it->setOrdinal(SectionIndex++);
+
+    for (MCSectionData::iterator it2 = it->begin(),
+           ie2 = it->end(); it2 != ie2; ++it2)
+      it2->setOrdinal(FragmentIndex++);
+  }
+
   // Layout until everything fits.
   MCAsmLayout Layout(*this);
   while (LayoutOnce(Layout))
@@ -781,6 +793,7 @@
       //
       // FIXME: Add MCAsmLayout utility for this.
       DF->setParent(IF->getParent());
+      DF->setOrdinal(IF->getOrdinal());
       Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF));
       Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF));