forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ThinLTO] Drop non-prevailing non-ODR weak to declarations
Summary: Allow non-ODR weak/linkonce non-prevailing copies to be marked as available_externally in the index. Add support for dropping these to declarations in the backend. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28806 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292656 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
7d5b56c
commit 1f32b34
Showing
7 changed files
with
119 additions
and
23 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
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,17 @@ | ||
; ModuleID = 'thinlto_weak_library1.c' | ||
source_filename = "thinlto_weak_library1.c" | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: nounwind uwtable | ||
define weak i32 @f() local_unnamed_addr { | ||
entry: | ||
ret i32 1 | ||
} | ||
|
||
; Function Attrs: norecurse nounwind readnone uwtable | ||
define i32 @test1() local_unnamed_addr { | ||
entry: | ||
%call = tail call i32 @f() | ||
ret i32 %call | ||
} |
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,20 @@ | ||
; ModuleID = 'thinlto_weak_library2.c' | ||
source_filename = "thinlto_weak_library2.c" | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: nounwind uwtable | ||
define weak i32 @f() local_unnamed_addr { | ||
entry: | ||
ret i32 2 | ||
} | ||
|
||
; Function Attrs: nounwind uwtable | ||
define void @test2() local_unnamed_addr { | ||
entry: | ||
tail call i32 (...) @test1() | ||
tail call i32 @f() | ||
ret void | ||
} | ||
|
||
declare i32 @test1(...) local_unnamed_addr |
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,41 @@ | ||
; Test to ensure that ThinLTO sorts the modules before passing to the | ||
; final native link based on the linker's determination of which | ||
; object within a static library contains the prevailing def of a symbol. | ||
|
||
; First generate bitcode with a module summary index for each file | ||
; RUN: opt -module-summary %s -o %t.o | ||
; RUN: opt -module-summary %p/Inputs/thinlto_weak_library1.ll -o %t2.o | ||
; RUN: opt -module-summary %p/Inputs/thinlto_weak_library2.ll -o %t3.o | ||
|
||
; Although the objects are ordered "%t2.o %t3.o" in the library, the | ||
; linker selects %t3.o first since it satisfies a strong reference from | ||
; %t.o. It later selects %t2.o based on the strong ref from %t3.o. | ||
; Therefore, %t3.o's copy of @f is prevailing, and we need to link | ||
; %t3.o before %t2.o in the final native link. | ||
; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ | ||
; RUN: --plugin-opt=thinlto \ | ||
; RUN: --plugin-opt=save-temps \ | ||
; RUN: -m elf_x86_64 \ | ||
; RUN: -o %t4 \ | ||
; RUN: %t.o \ | ||
; RUN: --start-lib %t2.o %t3.o --end-lib | ||
|
||
; Make sure we completely dropped the definition of the non-prevailing | ||
; copy of f() (and didn't simply convert to available_externally, which | ||
; would incorrectly enable inlining). | ||
; RUN: llvm-dis %t2.o.1.promote.bc -o - | FileCheck %s | ||
; CHECK: declare i32 @f() | ||
|
||
; ModuleID = 'thinlto_weak_library.c' | ||
source_filename = "thinlto_weak_library.c" | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: nounwind uwtable | ||
define i32 @main() local_unnamed_addr { | ||
entry: | ||
tail call void (...) @test2() | ||
ret i32 0 | ||
} | ||
|
||
declare void @test2(...) local_unnamed_addr |
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