Adding a collector name attribute to Function in the IR. These
[oota-llvm.git] / lib / Bitcode / Reader / BitcodeReader.cpp
index c405feb898da64f0552829a2af69f80a475ff323..fd3ec9e69855e2fb13fd9a41d3425e40efe3b10b 100644 (file)
@@ -849,6 +849,7 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
   
   SmallVector<uint64_t, 64> Record;
   std::vector<std::string> SectionTable;
+  std::vector<std::string> CollectorTable;
 
   // Read all the records for this module.
   while (!Stream.AtEndOfStream()) {
@@ -974,6 +975,13 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
       SectionTable.push_back(S);
       break;
     }
+    case bitc::MODULE_CODE_COLLECTORNAME: {  // SECTIONNAME: [strchr x N]
+      std::string S;
+      if (ConvertToString(Record, 0, S))
+        return Error("Invalid MODULE_CODE_COLLECTORNAME record");
+      CollectorTable.push_back(S);
+      break;
+    }
     // GLOBALVAR: [type, isconst, initid, 
     //             linkage, alignment, section, visibility, threadlocal]
     case bitc::MODULE_CODE_GLOBALVAR: {
@@ -1016,7 +1024,7 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
       break;
     }
     // FUNCTION:  [type, callingconv, isproto, linkage, paramattr,
-    //             alignment, section, visibility]
+    //             alignment, section, visibility, collector]
     case bitc::MODULE_CODE_FUNCTION: {
       if (Record.size() < 8)
         return Error("Invalid MODULE_CODE_FUNCTION record");
@@ -1044,6 +1052,11 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
         Func->setSection(SectionTable[Record[6]-1]);
       }
       Func->setVisibility(GetDecodedVisibility(Record[7]));
+      if (Record.size() > 8 && Record[8]) {
+        if (Record[8]-1 > CollectorTable.size())
+          return Error("Invalid collector ID");
+        Func->setCollector(CollectorTable[Record[8]-1].c_str());
+      }
       
       ValueList.push_back(Func);