From d067c8ed59ccd8a74f266c9fd06c9cfbdef834a1 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 13 Sep 2017 17:09:20 +0000 Subject: ThinLTO: Correctly follow aliasee references when dead stripping. We were previously handling aliases during dead stripping by adding the aliased global's "original name" GUID to the worklist. This will lead to incorrect behaviour if the global has local linkage because the original name GUID will not correspond to the global's GUID in the summary. Because an alias is just another name for the global that it references, there is no need to mark the referenced global as used, or to follow references from any other copies of the global. So all we need to do is to follow references from the aliasee's summary instead of the alias. Differential Revision: https://reviews.llvm.org/D37789 llvm-svn: 313157 --- llvm/lib/Transforms/IPO/FunctionImport.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index da763b18d4d..b043687f898 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -488,17 +488,14 @@ void llvm::computeDeadSymbols( while (!Worklist.empty()) { auto VI = Worklist.pop_back_val(); for (auto &Summary : VI.getSummaryList()) { - for (auto Ref : Summary->refs()) + GlobalValueSummary *Base = Summary.get(); + if (auto *AS = dyn_cast(Base)) + Base = &AS->getAliasee(); + for (auto Ref : Base->refs()) visit(Ref); - if (auto *FS = dyn_cast(Summary.get())) + if (auto *FS = dyn_cast(Base)) for (auto Call : FS->calls()) visit(Call.first); - if (auto *AS = dyn_cast(Summary.get())) { - auto AliaseeGUID = AS->getAliasee().getOriginalName(); - ValueInfo AliaseeVI = Index.getValueInfo(AliaseeGUID); - if (AliaseeVI) - visit(AliaseeVI); - } } } Index.setWithGlobalValueDeadStripping(); -- cgit v1.2.3