Don't create a new node for every reference to a global. This caused a huge
[oota-llvm.git] / lib / Support / Annotation.cpp
index fabf34b2db78da319788a3e1a56e9e096f55d752..e876bf4f38b27ccdf5363897880b835f5218059a 100644 (file)
@@ -6,6 +6,10 @@
 
 #include <map>
 #include "llvm/Annotation.h"
+using std::string;
+using std::map;
+using std::pair;
+using std::make_pair;
 
 typedef map<const string, unsigned> IDMapType;
 static unsigned IDCounter = 0;  // Unique ID counter
@@ -28,6 +32,16 @@ AnnotationID AnnotationManager::getID(const string &Name) {  // Name -> ID
   return I->second;
 }
 
+// getID - Name -> ID + registration of a factory function for demand driven
+// annotation support.
+AnnotationID AnnotationManager::getID(const string &Name, Factory Fact,
+                                     void *Data) {
+  AnnotationID Result(getID(Name));
+  registerAnnotationFactory(Result, Fact, Data);
+  return Result;                     
+}
+
+
 // getName - This function is especially slow, but that's okay because it should
 // only be used for debugging.
 //