Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld-link] preserve @llvm.used symbols in LTO
Summary: We translate @llvm.used to COFF by generating /include directives in the .drectve section. However, in LTO links, this happens after directives have already been processed, so the new directives do not take effect. This change marks @llvm.used symbols as GCRoots so that they are preserved as intended. Fixes PR40733. Reviewers: rnk, pcc, ruiu Reviewed By: ruiu Subscribers: mehdi_amini, steven_wu, dexonsmith, dang, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58255 llvm-svn: 354410
- Loading branch information
Showing
3 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as -o %t.obj %s | ||
; RUN: lld-link -dll -debug -opt:ref -noentry -out:%t.dll %t.obj | ||
; RUN: llvm-pdbutil dump -publics %t.pdb | FileCheck %s | ||
|
||
; CHECK: S_PUB32 {{.*}} `foo` | ||
|
||
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-pc-windows-msvc" | ||
|
||
@llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @foo to i8*)], section "llvm.metadata" | ||
|
||
define void @foo() { | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters