[PATCH] D94202: Preserve the lexical order for global variables during llvm-link merge
Jin Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 20:21:03 PDT 2021
jinlin added a comment.
In D94202#2696207 <https://reviews.llvm.org/D94202#2696207>, @dexonsmith wrote:
> Or, maybe you can just splice as you go during your first iteration, and you don't need to sort at all or build up any maps...
>
> // Reorder the new globals to match the old order.
> for (GlobalVariable &GV : SrcM->globals()) {
> if (GV.hasAppendingLinkage())
> continue;
> auto NewValue = Mapper.mapValue(GV);
> if (!NewValue)
> continue;
> auto *NewGV = dyn_cast<GlobalVariable>(NewValue->stripPointerCasts());
> if (!NewGV)
> continue;
> Globals.splice(Globals.end(), Globals, NewGV->getIterator());
> }
Great! Many thanks for your suggestions.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94202/new/
https://reviews.llvm.org/D94202
More information about the llvm-commits
mailing list