Use cached subtarget rather than looking it up on the
[oota-llvm.git] / lib / CodeGen / MachinePassRegistry.cpp
index 9f4ef1287803c43d13971f3762736b1c018a57cd..3ee3e40b27e236d5d984c7dc3ed4618555f7834e 100644 (file)
 
 using namespace llvm;
 
+void MachinePassRegistryListener::anchor() { }
+
+/// setDefault - Set the default constructor by name.
+void MachinePassRegistry::setDefault(StringRef Name) {
+  MachinePassCtor Ctor = nullptr;
+  for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) {
+    if (R->getName() == Name) {
+      Ctor = R->getCtor();
+      break;
+    }
+  }
+  assert(Ctor && "Unregistered pass name");
+  setDefault(Ctor);
+}
 
 /// Add - Adds a function pass to the registration list.
 ///