Preserve the lexical order for global variables during llvm-link merge
authorJin Lin <jinl@uber.com>
Sat, 24 Apr 2021 05:37:08 +0000 (22:37 -0700)
committerJin Lin <jinl@uber.com>
Mon, 26 Apr 2021 17:11:34 +0000 (10:11 -0700)
commitcedfa38fc46d7531c44ea230b767d8286767f350
treeda89f79beb7efca899ea234c33aa595cef140322
parent9579af2bd7f39b2118039b66b1a762cf05e7b102
Preserve the lexical order for global variables during llvm-link merge

The order of global variables is generated in the order of recursively materializing variables if the global variable has the attribute of hasLocalLinkage or hasLinkOnceLinkage during the module merging. In practice, it is often the exact reverse of source order. This new order may cause performance regression.

The change is to preserve the original lexical order for global variables.

Reviewed By: jdoerfert, dexonsmith

Differential Revision: https://reviews.llvm.org/D94202
16 files changed:
llvm/lib/Linker/IRMover.cpp
llvm/test/Linker/Inputs/globalorder-2.ll [new file with mode: 0644]
llvm/test/Linker/comdat.ll
llvm/test/Linker/comdat14.ll
llvm/test/Linker/ctors.ll
llvm/test/Linker/ctors2.ll
llvm/test/Linker/ctors3.ll
llvm/test/Linker/globalorder.ll [new file with mode: 0644]
llvm/test/Linker/link-flags.ll
llvm/test/Linker/metadata-attach.ll
llvm/test/Linker/testlink.ll
llvm/test/ThinLTO/X86/import-constant.ll
llvm/test/ThinLTO/X86/index-const-prop.ll
llvm/test/ThinLTO/X86/index-const-prop2.ll
llvm/test/ThinLTO/X86/writeonly.ll
llvm/test/ThinLTO/X86/writeonly2.ll