2017-11-05 01:04:39 +08:00
|
|
|
; RUN: opt -module-summary %s -o %t1.bc
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; RUN: opt -module-summary %p/Inputs/internalize.ll -o %t2.bc
|
|
|
|
; Link in %t2.bc first to force its copy of @weak_func_nonprevailing as
|
|
|
|
; prevailing the %t1.bc copy as non-prevailing.
|
|
|
|
; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t2.bc %t1.bc
|
2016-04-24 11:18:01 +08:00
|
|
|
; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=REGULAR
|
|
|
|
; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc -o - --exported-symbol=foo | llvm-dis -o - | FileCheck %s --check-prefix=INTERNALIZE
|
|
|
|
|
2018-11-05 23:49:46 +08:00
|
|
|
; Test the enable-lto-internalization option by setting it to false.
|
|
|
|
; This makes sure indices are not marked as internallinkage and therefore
|
|
|
|
; internalization does not happen.
|
|
|
|
; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc \
|
|
|
|
; RUN: -enable-lto-internalization=false --exported-symbol=foo
|
|
|
|
; RUN: llvm-dis < %t1.bc.thinlto.internalized.bc | FileCheck %s --check-prefix=INTERNALIZE-OPTION-DISABLE
|
|
|
|
|
2017-04-12 02:12:00 +08:00
|
|
|
; RUN: llvm-lto2 run %t1.bc -o %t.o -save-temps \
|
2016-08-18 08:59:24 +08:00
|
|
|
; RUN: -r=%t1.bc,_foo,pxl \
|
|
|
|
; RUN: -r=%t1.bc,_bar,pl \
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; RUN: -r=%t1.bc,_linkonce_func,pl \
|
|
|
|
; RUN: -r=%t1.bc,_weak_func_prevailing,pl \
|
|
|
|
; RUN: -r=%t1.bc,_alias1,plx \
|
|
|
|
; RUN: -r=%t1.bc,_weak_func_nonprevailing,l
|
2017-12-16 10:10:00 +08:00
|
|
|
; RUN: llvm-dis < %t.o.1.2.internalize.bc | FileCheck %s --check-prefix=INTERNALIZE2
|
2016-08-18 08:59:24 +08:00
|
|
|
|
2018-11-05 23:49:46 +08:00
|
|
|
; Test the enable-lto-internalization option by setting it to false.
|
|
|
|
; This makes sure indices are not marked as internallinkage and therefore
|
|
|
|
; internalization does not happen.
|
|
|
|
; RUN: llvm-lto2 run %t1.bc -o %t.o -save-temps -enable-lto-internalization=false \
|
|
|
|
; RUN: -r=%t1.bc,_foo,pxl \
|
|
|
|
; RUN: -r=%t1.bc,_bar,pl \
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; RUN: -r=%t1.bc,_linkonce_func,pl \
|
|
|
|
; RUN: -r=%t1.bc,_weak_func_prevailing,pl \
|
|
|
|
; RUN: -r=%t1.bc,_alias1,plx \
|
|
|
|
; RUN: -r=%t1.bc,_weak_func_nonprevailing,l
|
2018-11-05 23:49:46 +08:00
|
|
|
; RUN: llvm-dis < %t.o.1.2.internalize.bc | FileCheck %s --check-prefix=INTERNALIZE2-OPTION-DISABLE
|
2016-08-18 08:59:24 +08:00
|
|
|
|
2016-04-24 11:18:01 +08:00
|
|
|
; REGULAR: define void @foo
|
|
|
|
; REGULAR: define void @bar
|
2016-08-18 08:59:24 +08:00
|
|
|
; REGULAR: define linkonce void @linkonce_func()
|
2016-04-24 11:18:01 +08:00
|
|
|
; INTERNALIZE: define void @foo
|
|
|
|
; INTERNALIZE: define internal void @bar
|
2016-08-18 08:59:24 +08:00
|
|
|
; INTERNALIZE: define internal void @linkonce_func()
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; INTERNALIZE: define internal void @weak_func_prevailing()
|
|
|
|
; INTERNALIZE: define weak void @weak_func_nonprevailing()
|
2018-11-05 23:49:46 +08:00
|
|
|
; INTERNALIZE-OPTION-DISABLE: define void @foo
|
|
|
|
; INTERNALIZE-OPTION-DISABLE: define void @bar
|
[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
|
|
|
; INTERNALIZE-OPTION-DISABLE: define weak void @linkonce_func()
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; INTERNALIZE-OPTION-DISABLE: define weak void @weak_func_prevailing()
|
|
|
|
; INTERNALIZE-OPTION-DISABLE: define weak void @weak_func_nonprevailing()
|
2017-11-05 01:04:39 +08:00
|
|
|
; INTERNALIZE2: define dso_local void @foo
|
2018-01-12 06:15:05 +08:00
|
|
|
; INTERNALIZE2: define internal void @bar
|
|
|
|
; INTERNALIZE2: define internal void @linkonce_func()
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; INTERNALIZE2: define internal void @weak_func_prevailing()
|
|
|
|
; INTERNALIZE2: define weak dso_local void @weak_func_nonprevailing()
|
2018-11-05 23:49:46 +08:00
|
|
|
; INTERNALIZE2-OPTION-DISABLE: define dso_local void @foo
|
|
|
|
; INTERNALIZE2-OPTION-DISABLE: define dso_local void @bar
|
|
|
|
; INTERNALIZE2-OPTION-DISABLE: define weak dso_local void @linkonce_func()
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
; INTERNALIZE2-OPTION-DISABLE: define weak dso_local void @weak_func_prevailing()
|
|
|
|
; INTERNALIZE2-OPTION-DISABLE: define weak dso_local void @weak_func_nonprevailing()
|
2016-04-24 11:18:01 +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-24 11:18:01 +08:00
|
|
|
target triple = "x86_64-apple-macosx10.11.0"
|
|
|
|
|
|
|
|
define void @foo() {
|
2018-01-29 16:03:30 +08:00
|
|
|
call void @bar()
|
2016-04-24 11:18:01 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
define void @bar() {
|
2016-08-18 08:59:24 +08:00
|
|
|
call void @linkonce_func()
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
call void @weak_func_prevailing()
|
|
|
|
call void @weak_func_nonprevailing()
|
2016-08-18 08:59:24 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
define linkonce void @linkonce_func() {
|
2016-04-24 11:18:01 +08:00
|
|
|
ret void
|
2017-11-05 01:04:39 +08:00
|
|
|
}
|
[ThinLTO] Fix handling of weak interposable symbols
Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.
This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.
Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.
Fixes PR42542.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66264
llvm-svn: 369766
2019-08-23 23:18:58 +08:00
|
|
|
define weak void @weak_func_prevailing() {
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; Make @weak_func_nonprevailing an aliasee to ensure it is still marked
|
|
|
|
; live and kept as a definition even when non-prevailing. We want to ensure
|
|
|
|
; this definition is not internalized.
|
|
|
|
@alias1 = hidden alias void (), void ()* @weak_func_nonprevailing
|
|
|
|
define weak void @weak_func_nonprevailing() {
|
|
|
|
ret void
|
|
|
|
}
|