Skip to content

Commit 2bbea54

Browse files
committed
IRGen: Use llvm.compiler.used instead of llvm.used on ELF
As of "ELF: Create unique SHF_GNU_RETAIN sections for llvm.used global objects" (https://reviews.llvm.org/D97448) LLVM will create separate sections for symbols marked as llvm.used. Use llvm.compiler.used instead. rdar://82681143
1 parent 806395d commit 2bbea54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,15 @@ IRGenModule::getAddrOfParentContextDescriptor(DeclContext *from,
886886
///
887887
/// This value must have a definition by the time the module is finalized.
888888
void IRGenModule::addUsedGlobal(llvm::GlobalValue *global) {
889+
890+
// As of reviews.llvm.org/D97448 "ELF: Create unique SHF_GNU_RETAIN sections
891+
// for llvm.used global objects" LLVM creates separate sections for globals in
892+
// llvm.used on ELF. Therefore we use llvm.compiler.used on ELF instead.
893+
if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF) {
894+
addCompilerUsedGlobal(global);
895+
return;
896+
}
897+
889898
LLVMUsed.push_back(global);
890899
}
891900

0 commit comments

Comments
 (0)