Skip to content

Commit

Permalink
IRGen: Use llvm.compiler.used instead of llvm.used on ELF
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aschwaighofer committed Sep 3, 2021
1 parent 806395d commit 2bbea54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,15 @@ IRGenModule::getAddrOfParentContextDescriptor(DeclContext *from,
///
/// This value must have a definition by the time the module is finalized.
void IRGenModule::addUsedGlobal(llvm::GlobalValue *global) {

// As of reviews.llvm.org/D97448 "ELF: Create unique SHF_GNU_RETAIN sections
// for llvm.used global objects" LLVM creates separate sections for globals in
// llvm.used on ELF. Therefore we use llvm.compiler.used on ELF instead.
if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF) {
addCompilerUsedGlobal(global);
return;
}

LLVMUsed.push_back(global);
}

Expand Down

0 comments on commit 2bbea54

Please sign in to comment.