[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 18:09:19 PDT 2009


On Wed, Jul 15, 2009 at 10:06 AM, Reid Kleckner<rnk at mit.edu> wrote:
> How does the JIT unittest rely on this?

The setup function is called multiple times, which calls the target
initialization multiple times, which registers the target multiple
times.

> Could we fix that instead, or is it a good idea to support registering multiple targets?

I'm not sure. It doesn't seem like an unreasonable thing to allow, and
it has no penalty, except that if the client explicitly didn't want to
be doing that they wouldn't get an assertion failure. The reason I
went with allowing it is that it if two libraries are sharing LLVM and
both want to make sure things are initialized, its more convenient to
allow them to just call the target initialization function and expect
it to work. I'll add an explicit comment to TargetSelect that this is
legal.

 - Daniel

> Reid
>
> On Wed, Jul 15, 2009 at 3:32 AM, Daniel Dunbar<daniel at zuster.org> wrote:
>> 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;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list