2016-04-02 05:53:50 +08:00
|
|
|
; Do setup work for all below tests: generate bitcode and combined index
|
2016-04-13 05:35:18 +08:00
|
|
|
; RUN: opt -module-summary %s -o %t.bc
|
2016-05-26 22:16:52 +08:00
|
|
|
; RUN: opt -module-summary %p/Inputs/weak_resolution.ll -o %t2.bc
|
2016-04-02 05:53:50 +08:00
|
|
|
; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
|
|
|
|
|
2016-05-26 22:16:52 +08:00
|
|
|
; Verify that prevailing weak for linker symbol is selected across modules,
|
|
|
|
; non-prevailing ODR are not kept when possible, but non-ODR non-prevailing
|
|
|
|
; are not affected.
|
2016-04-02 05:53:50 +08:00
|
|
|
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1
|
[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols
Summary:
Reapply r357931 with fixes to ThinLTO testcases and llvm-lto tool.
ThinLTOCodeGenerator currently does not preserve llvm.used symbols and
it can internalize them. In order to pass the necessary information to the
legacy ThinLTOCodeGenerator, the input to the code generator is
rewritten to be based on lto::InputFile.
Now ThinLTO using the legacy LTO API will requires data layout in
Module.
"internalize" thinlto action in llvm-lto is updated to run both
"promote" and "internalize" with the same configuration as
ThinLTOCodeGenerator. The old "promote" + "internalize" option does not
produce the same output as ThinLTOCodeGenerator.
This fixes: PR41236
rdar://problem/49293439
Reviewers: tejohnson, pcc, kromanova, dexonsmith
Reviewed By: tejohnson
Subscribers: ormris, bd1976llvm, mehdi_amini, inglorion, eraman, hiraditya, jkorous, dexonsmith, arphaman, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60421
llvm-svn: 358601
2019-04-18 01:38:09 +08:00
|
|
|
; RUN: llvm-lto -thinlto-action=internalize %t.bc -thinlto-index=%t3.bc -exported-symbol=linkoncefunc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1-INT
|
2016-04-02 05:53:50 +08:00
|
|
|
; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD2
|
2016-04-26 18:35:01 +08:00
|
|
|
; When exported, we always preserve a linkonce
|
|
|
|
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - --exported-symbol=linkonceodrfuncInSingleModule | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTED
|
2016-04-02 05:53:50 +08:00
|
|
|
|
2019-09-11 07:15:38 +08:00
|
|
|
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
2016-04-02 05:53:50 +08:00
|
|
|
target triple = "x86_64-apple-macosx10.11.0"
|
|
|
|
|
2016-04-21 13:47:17 +08:00
|
|
|
; Alias are resolved, but can't be turned into "available_externally"
|
2016-05-26 22:16:52 +08:00
|
|
|
; MOD1: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
|
|
|
|
; MOD2: @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
|
|
|
@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
|
|
|
|
|
|
|
; Alias are resolved, but can't be turned into "available_externally"
|
|
|
|
; MOD1: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
|
|
|
|
; MOD2: @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
|
|
|
|
@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
|
2016-04-02 05:53:50 +08:00
|
|
|
|
2016-10-30 13:15:23 +08:00
|
|
|
; Function with an alias are resolved to weak_odr in prevailing module, but
|
|
|
|
; not optimized in non-prevailing module (illegal to have an
|
|
|
|
; available_externally aliasee).
|
|
|
|
; MOD1: define weak_odr void @linkonceodrfuncwithalias()
|
2016-04-02 05:53:50 +08:00
|
|
|
; MOD2: define linkonce_odr void @linkonceodrfuncwithalias()
|
|
|
|
define linkonce_odr void @linkonceodrfuncwithalias() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-10-30 13:15:23 +08:00
|
|
|
; Function with an alias are resolved to weak in prevailing module, but
|
|
|
|
; not optimized in non-prevailing module (illegal to have an
|
|
|
|
; available_externally aliasee).
|
|
|
|
; MOD1: define weak void @linkoncefuncwithalias()
|
2016-05-26 22:16:52 +08:00
|
|
|
; MOD2: define linkonce void @linkoncefuncwithalias()
|
|
|
|
define linkonce void @linkoncefuncwithalias() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-04-02 05:53:50 +08:00
|
|
|
; MOD1: define weak_odr void @linkonceodrfunc()
|
|
|
|
; MOD2: define available_externally void @linkonceodrfunc()
|
|
|
|
define linkonce_odr void @linkonceodrfunc() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
2016-05-26 22:16:52 +08:00
|
|
|
; MOD1: define weak void @linkoncefunc()
|
2016-07-07 06:53:02 +08:00
|
|
|
; MOD1-INT: define weak void @linkoncefunc()
|
2017-01-21 05:54:58 +08:00
|
|
|
; MOD2: declare void @linkoncefunc()
|
2016-04-02 05:53:50 +08:00
|
|
|
define linkonce void @linkoncefunc() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; MOD1: define weak_odr void @weakodrfunc()
|
|
|
|
; MOD2: define available_externally void @weakodrfunc()
|
|
|
|
define weak_odr void @weakodrfunc() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; MOD1: define weak void @weakfunc()
|
2017-01-21 05:54:58 +08:00
|
|
|
; MOD2: declare void @weakfunc()
|
2016-04-02 05:53:50 +08:00
|
|
|
define weak void @weakfunc() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-08 02:31:51 +08:00
|
|
|
; MOD1: define weak_odr void @linkonceodrfuncInSingleModule()
|
2016-07-07 06:53:02 +08:00
|
|
|
; MOD1-INT: define internal void @linkonceodrfuncInSingleModule()
|
2016-04-26 18:35:01 +08:00
|
|
|
; EXPORTED: define weak_odr void @linkonceodrfuncInSingleModule()
|
|
|
|
define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|