[PATCH] D94202: Preserve the lexical order of global variables during llvm-link merge
Jin Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 08:37:50 PDT 2021
jinlin added a comment.
In D94202#2602191 <https://reviews.llvm.org/D94202#2602191>, @jdoerfert wrote:
> In D94202#2597943 <https://reviews.llvm.org/D94202#2597943>, @jinlin wrote:
>
>> In D94202#2597753 <https://reviews.llvm.org/D94202#2597753>, @jdoerfert wrote:
>>
>>> In D94202#2597735 <https://reviews.llvm.org/D94202#2597735>, @jinlin wrote:
>>>
>>>> In D94202#2597644 <https://reviews.llvm.org/D94202#2597644>, @jdoerfert wrote:
>>>>
>>>>> In D94202#2597614 <https://reviews.llvm.org/D94202#2597614>, @jinlin wrote:
>>>>>
>>>>>> In D94202#2597598 <https://reviews.llvm.org/D94202#2597598>, @jdoerfert wrote:
>>>>>>
>>>>>>> This looks brittle and wrong to fiddle with the initializers of the variables and doing some complex logic.
>>>>>>> You want to preserve the order, ok, couldn't we just sort the globals in the resulting module according to the order in the source(s)?
>>>>>>
>>>>>> Sorry I have sent the wrong patch to the review and it causes many lit cases fails.
>>>>>>
>>>>>> The order of the globals is determined when the globals are generated. If you want to sort the order, you have to regenerate the globals and replace the old ones with new ones.
>>>>>
>>>>> Aren't the globals stored in a list that allows to change their order? It has a remove and insert, that should be sufficient.
>>>>
>>>> You can remove, replace or append. However, you cannot insert. Please correct me if I am wrong.
>>>
>>> As far as I can tell the list has insert with a position.
>>
>> The globals are in the SymbolTableList. It does not provide any util for insertion.
>>
>> 94 public:
>> 95 void addNodeToList(ValueSubClass *V);
>> 96 void removeNodeFromList(ValueSubClass *V);
>> 97 void transferNodesFromList(SymbolTableListTraits &L2, iterator first,
>> 98 iterator last);
>> 99 // private:
>> 100 template<typename TPtr>
>> 101 void setSymTabObject(TPtr *, TPtr);
>> 102 static ValueSymbolTable *toPtr(ValueSymbolTable *P) { return P; }
>> 103 static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; }
>> 104 };
>
> Isn't a `SymbolTableList` a `iplist_impl` which has insert and remove? (FWIW, you copied the interface of `SymbolTableListTraits` not `SymbolTableList`)
You are right. So I added post-process code to preserve the lexical order of global variables.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94202/new/
https://reviews.llvm.org/D94202
More information about the llvm-commits
mailing list