summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionImport.cpp
diff options
context:
space:
mode:
authorVlad Tsyrklevich <vlad@tsyrklevich.net>2018-03-13 05:08:48 +0000
committerVlad Tsyrklevich <vlad@tsyrklevich.net>2018-03-13 05:08:48 +0000
commitaab60006842d6172ca7963e4d96540bad33ebe3d (patch)
treeb1b3d0e5c94b8cc3f635b13c3e3a28e66974f363 /llvm/lib/Transforms/IPO/FunctionImport.cpp
parentade40dd3c8f25b243a55cb9d1960efd7ca9e25a3 (diff)
downloadbcm5719-llvm-aab60006842d6172ca7963e4d96540bad33ebe3d.tar.gz
bcm5719-llvm-aab60006842d6172ca7963e4d96540bad33ebe3d.zip
Reland r327041: [ThinLTO] Keep available_externally symbols live
Summary: This change fixes PR36483. The bug was originally introduced by a change that marked non-prevailing symbols dead. This broke LowerTypeTests handling of available_externally functions, which are non-prevailing. LowerTypeTests uses liveness information to avoid emitting thunks for unused functions. Marking available_externally functions dead is incorrect, the functions are used though the function definitions are not. This change keeps them live, and lets the EliminateAvailableExternally/GlobalDCE passes remove them later instead. (Reland with a suspected fix for a unit test failure I haven't been able to reproduce locally) Reviewers: pcc, tejohnson Reviewed By: tejohnson Subscribers: grimar, mehdi_amini, inglorion, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D43690 llvm-svn: 327360
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index f759474e40f..d021b4a59a8 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -610,9 +610,26 @@ void llvm::computeDeadSymbols(
if (S->isLive())
return;
- // We do not keep live symbols that are known to be non-prevailing.
- if (isPrevailing(VI.getGUID()) == PrevailingType::No)
- return;
+ // We only keep live symbols that are known to be non-prevailing if any are
+ // available_externally. Those symbols are discarded later in the
+ // EliminateAvailableExternally pass and setting them to not-live breaks
+ // downstreams users of liveness information (PR36483).
+ if (isPrevailing(VI.getGUID()) == PrevailingType::No) {
+ bool AvailableExternally = false;
+ bool Interposable = false;
+ for (auto &S : VI.getSummaryList()) {
+ if (S->linkage() == GlobalValue::AvailableExternallyLinkage)
+ AvailableExternally = true;
+ else if (GlobalValue::isInterposableLinkage(S->linkage()))
+ Interposable = true;
+ }
+
+ if (!AvailableExternally)
+ return;
+
+ if (Interposable)
+ report_fatal_error("Interposable and available_externally symbol");
+ }
for (auto &S : VI.getSummaryList())
S->setLive(true);
OpenPOWER on IntegriCloud