Preserve the address space for llvm.used and llvm.compiler.used global variables...
authorNawal Copty <nawal.copty@intel.com>
Tue, 25 Apr 2023 19:45:33 +0000 (12:45 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 25 Apr 2023 20:07:01 +0000 (13:07 -0700)
commit6e54a57c61af6a959210f3628df9e21e3d7033f5
treed7c2cff3562765dfb58424fb9d402de333b8e7da
parentbab6cfede92830bb38d08282c62144df79b13600
Preserve the address space for llvm.used and llvm.compiler.used global variables in GlobalOpt pass.

The llvm.used (or llvm.compiler.used) global variable is an array that contains a list of pointers to global variables and functions.

The GlobalOpt (Global Variable Optimizer) pass is not preserving the address space for llvm.used and llvm.compiler.used global variables.This patch updates the setUsedInitializer() function in GlobalOpt.cpp, so the address space is preserved.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D144518
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/global-opt-addrspace.ll [new file with mode: 0644]