[cfe-commits] r106485 - in /cfe/trunk/lib/CodeGen: CGDeclCXX.cpp CodeGenModule.h

Fariborz Jahanian fjahanian at apple.com
Mon Jun 21 16:33:35 PDT 2010


On Jun 21, 2010, at 3:57 PM, Chris Lattner wrote:

> On Jun 21, 2010, at 2:27 PM, Fariborz Jahanian wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=106485&view=rev
>> Log:
>> In supporting init-priority, globals with the same init_priority  
>> must be
>> emitted in the order in which they are seen (still radar 8076356).
>
> Thanks Fariborz, one more tweak :)
>
>>
>>  if (D->hasAttr<InitPriorityAttr>()) {
>> +    static unsigned lix = 0; // to keep the lexical order of equal  
>> priority
>> +                             // objects intact;
>>    unsigned int order = D->getAttr<InitPriorityAttr>()- 
>> >getPriority();
>> -    PrioritizedCXXGlobalInits.push_back(std::make_pair(order,Fn));
>> +    OrderGlobalInitsType Key(order, lix++);
>> +    PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
>
> Using a static here will interact poorly with threading.  You  
> already have the order because of the position in the list.  How  
> about using something like:
>
> OrderGlobalInitsType Key(PrioritizedCXXGlobalInits.size(), lix++);

In http://llvm.org/viewvc/llvm-project?view=rev&revision=106503 (a  
modified version).

- fariborz




More information about the cfe-commits mailing list