[llvm-commits] [llvm] r75769 - in /llvm/trunk: include/llvm/Target/TargetRegistry.h lib/Support/TargetRegistry.cpp

Daniel Dunbar daniel at zuster.org
Wed Jul 15 03:32:46 PDT 2009


Author: ddunbar
Date: Wed Jul 15 05:32:44 2009
New Revision: 75769

URL: http://llvm.org/viewvc/llvm-project?rev=75769&view=rev
Log:
Allow multiple registrations of the same target.
 - This doesn't necessarily seem like a good idea, but the JIT unittest
   currently relies on it.

Modified:
    llvm/trunk/include/llvm/Target/TargetRegistry.h
    llvm/trunk/lib/Support/TargetRegistry.cpp

Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=75769&r1=75768&r2=75769&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegistry.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegistry.h Wed Jul 15 05:32:44 2009
@@ -137,7 +137,8 @@
     /// @name Target Registration
     /// @{
 
-    /// RegisterTarget - Register the given target.
+    /// RegisterTarget - Register the given target. Attempts to register a
+    /// target which has already been registered will be ignored.
     /// 
     /// Clients are responsible for ensuring that registration doesn't occur
     /// while another thread is attempting to access the registry. Typically

Modified: llvm/trunk/lib/Support/TargetRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetRegistry.cpp?rev=75769&r1=75768&r2=75769&view=diff

==============================================================================
--- llvm/trunk/lib/Support/TargetRegistry.cpp (original)
+++ llvm/trunk/lib/Support/TargetRegistry.cpp Wed Jul 15 05:32:44 2009
@@ -111,15 +111,13 @@
                                     Target::TripleMatchQualityFnTy TQualityFn,
                                     Target::ModuleMatchQualityFnTy MQualityFn,
                                     Target::JITMatchQualityFnTy JITQualityFn) {
-  // Note that we don't require the constructor functions already be defined, in
-  // case a module happens to initialize the optional functionality before the
-  // target.
-  assert(!T.Next && !T.Name && !T.ShortDesc && !T.TripleMatchQualityFn &&
-         !T.ModuleMatchQualityFn && !T.JITMatchQualityFn && 
-         "This Target already registered!");
-
   assert(Name && ShortDesc && TQualityFn && MQualityFn && JITQualityFn &&
          "Missing required target information!");
+
+  // Check if this target has already been initialized, we allow this as a
+  // convenience to some clients.
+  if (T.Name)
+    return;
          
   // Add to the list of targets.
   T.Next = FirstTarget;





More information about the llvm-commits mailing list