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] Correctly resolve linkonce when importing aliasee
Summary: When we have an aliasee that is linkonce, while we can't convert the non-prevailing copies to available_externally, we still need to convert the prevailing copy to weak. If a reference to the aliasee is exported, not converting a copy to weak will result in undefined references when the linkonce is removed in its original module. Add a new test and update existing tests. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26076 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285512 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
0a87051
commit 39970a7
Showing
6 changed files
with
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-grtev4-linux-gnu" | ||
|
||
define i32 @main() #0 { | ||
entry: | ||
call void @foo() | ||
ret i32 0 | ||
} | ||
|
||
declare void @foo() |
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,50 @@ | ||
; RUN: opt -module-summary %s -o %t1.bc | ||
; RUN: opt -module-summary %p/Inputs/linkonce_aliasee_ref_import.ll -o %t2.bc | ||
|
||
; Import with instr limit to ensure only foo imported. | ||
; RUN: llvm-lto -thinlto-action=run -exported-symbol=main -import-instr-limit=5 %t1.bc %t2.bc | ||
; RUN: llvm-nm -o - < %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM1 | ||
; RUN: llvm-nm -o - < %t2.bc.thinlto.o | FileCheck %s --check-prefix=NM2 | ||
|
||
; Import with instr limit to ensure only foo imported. | ||
; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.o -save-temps \ | ||
; RUN: -r=%t1.bc,foo,pxl \ | ||
; RUN: -r=%t1.bc,baz,pxl \ | ||
; RUN: -r=%t1.bc,baz.clone,pxl \ | ||
; RUN: -r=%t1.bc,bar,pl \ | ||
; RUN: -r=%t2.bc,main,pxl \ | ||
; RUN: -r=%t2.bc,foo,l \ | ||
; RUN: -import-instr-limit=5 | ||
; RUN: llvm-nm -o - < %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM1 | ||
; RUN: llvm-nm -o - < %t2.bc.thinlto.o | FileCheck %s --check-prefix=NM2 | ||
|
||
; Check that we converted baz.clone to a weak | ||
; NM1: W baz.clone | ||
|
||
; Check that we imported a ref (and not def) to baz.clone | ||
; NM2: U baz.clone | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-grtev4-linux-gnu" | ||
|
||
$baz.clone = comdat any | ||
@baz = weak alias void (), void ()* @baz.clone | ||
|
||
define void @foo() #5 align 2 { | ||
tail call void @baz.clone() | ||
ret void | ||
} | ||
define linkonce_odr void @baz.clone() #5 comdat align 2 { | ||
call void @bar() | ||
call void @bar() | ||
call void @bar() | ||
call void @bar() | ||
call void @bar() | ||
call void @bar() | ||
call void @bar() | ||
ret void | ||
} | ||
|
||
define void @bar() { | ||
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
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