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

Douglas Gregor dgregor at apple.com
Mon Jun 21 13:03:52 PDT 2010


On Jun 21, 2010, at 12:51 PM, Chris Lattner wrote:

> 
> On Jun 21, 2010, at 12:44 PM, Douglas Gregor wrote:
> 
>> 
>> On Jun 21, 2010, at 12:40 PM, Chris Lattner wrote:
>> 
>>> 
>>> On Jun 21, 2010, at 11:45 AM, Fariborz Jahanian wrote:
>>> 
>>>> Author: fjahanian
>>>> Date: Mon Jun 21 13:45:05 2010
>>>> New Revision: 106441
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=106441&view=rev
>>>> Log:
>>>> IRGen for implementation of init-priority attribute.
>>>> Test case will be checked in llvm test suite.
>>>> (finishes off radar 8076356).
>>> 
>>> Nice!
>>> 
>>>> +  if (!PrioritizedCXXGlobalInits.empty()) {
>>>> +    std::vector<llvm::Constant*> LocalCXXGlobalInits;
>>>> +    std::sort(PrioritizedCXXGlobalInits.begin(), 
>>>> +              PrioritizedCXXGlobalInits.end());
>>> 
>>> Please use SmallVector and array_pod_sort (from llvm/ADT/STLExtras.h).  Smallvector saves a bit of time.  std::sort is generally bad because it instantiates into a ton of code.
>> 
>> 
>> Shouldn't this be a stable_sort, so that globals with the same init_priority are emitted in the order in which they are seen?
> 
> Ah, good point.  This could be handled by adding making PrioritizedCXXGlobalInits be a 3 element tuple, which has the original index as the middle value?

Yep, that would work.

	- Doug



More information about the cfe-commits mailing list