summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2017-02-03 07:41:43 +0000
committerMehdi Amini <mehdi.amini@apple.com>2017-02-03 07:41:43 +0000
commit1380edf4ef9469e2dda07020436a1b229c1ad804 (patch)
treeeb556ccc87157b8445f7f9c59051e9f1a9f755d7 /llvm/lib/LTO/ThinLTOCodeGenerator.cpp
parente5f2bfaea9d96c93ff0ca8b5c986092a9a488c47 (diff)
downloadbcm5719-llvm-1380edf4ef9469e2dda07020436a1b229c1ad804.tar.gz
bcm5719-llvm-1380edf4ef9469e2dda07020436a1b229c1ad804.zip
Revert "[ThinLTO] Add an auto-hide feature"
This reverts commit r293970. After more discussion, this belongs to the linker side and there is no added value to do it at this level. llvm-svn: 293993
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp60
1 files changed, 26 insertions, 34 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index b62db61f4c4..104fb199da0 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -234,16 +234,16 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM,
// Convert the PreservedSymbols map from "Name" based to "GUID" based.
static DenseSet<GlobalValue::GUID>
-convertSymbolNamesToGUID(const StringSet<> &NamedSymbols,
- const Triple &TheTriple) {
- DenseSet<GlobalValue::GUID> GUIDSymbols(NamedSymbols.size());
- for (auto &Entry : NamedSymbols) {
+computeGUIDPreservedSymbols(const StringSet<> &PreservedSymbols,
+ const Triple &TheTriple) {
+ DenseSet<GlobalValue::GUID> GUIDPreservedSymbols(PreservedSymbols.size());
+ for (auto &Entry : PreservedSymbols) {
StringRef Name = Entry.first();
if (TheTriple.isOSBinFormatMachO() && Name.size() > 0 && Name[0] == '_')
Name = Name.drop_front();
- GUIDSymbols.insert(GlobalValue::getGUID(Name));
+ GUIDPreservedSymbols.insert(GlobalValue::getGUID(Name));
}
- return GUIDSymbols;
+ return GUIDPreservedSymbols;
}
std::unique_ptr<MemoryBuffer> codegenModule(Module &TheModule,
@@ -554,7 +554,10 @@ void ThinLTOCodeGenerator::preserveSymbol(StringRef Name) {
}
void ThinLTOCodeGenerator::crossReferenceSymbol(StringRef Name) {
- CrossReferencedSymbols.insert(Name);
+ // FIXME: At the moment, we don't take advantage of this extra information,
+ // we're conservatively considering cross-references as preserved.
+ // CrossReferencedSymbols.insert(Name);
+ PreservedSymbols.insert(Name);
}
// TargetMachine factory
@@ -617,7 +620,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule,
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
- auto GUIDPreservedSymbols = convertSymbolNamesToGUID(
+ auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
PreservedSymbols, Triple(TheModule.getTargetTriple()));
// Compute "dead" symbols, we don't want to import/export these!
@@ -638,13 +641,11 @@ void ThinLTOCodeGenerator::promote(Module &TheModule,
// Promote the exported values in the index, so that they are promoted
// in the module.
- auto isExported = [&](StringRef ModuleIdentifier,
- GlobalValue::GUID GUID) -> SummaryResolution {
+ auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
const auto &ExportList = ExportLists.find(ModuleIdentifier);
- if ((ExportList != ExportLists.end() && ExportList->second.count(GUID)) ||
- GUIDPreservedSymbols.count(GUID))
- return Exported;
- return Internal;
+ return (ExportList != ExportLists.end() &&
+ ExportList->second.count(GUID)) ||
+ GUIDPreservedSymbols.count(GUID);
};
thinLTOInternalizeAndPromoteInIndex(Index, isExported);
@@ -664,7 +665,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
- auto GUIDPreservedSymbols = convertSymbolNamesToGUID(
+ auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
PreservedSymbols, Triple(TheModule.getTargetTriple()));
// Compute "dead" symbols, we don't want to import/export these!
@@ -738,7 +739,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule,
// Convert the preserved symbols set from string to GUID
auto GUIDPreservedSymbols =
- convertSymbolNamesToGUID(PreservedSymbols, TMBuilder.TheTriple);
+ computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
// Collect for each module the list of function it defines (GUID -> Summary).
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
@@ -760,13 +761,11 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule,
return;
// Internalization
- auto isExported = [&](StringRef ModuleIdentifier,
- GlobalValue::GUID GUID) -> SummaryResolution {
+ auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
const auto &ExportList = ExportLists.find(ModuleIdentifier);
- if ((ExportList != ExportLists.end() && ExportList->second.count(GUID)) ||
- GUIDPreservedSymbols.count(GUID))
- return Exported;
- return Internal;
+ return (ExportList != ExportLists.end() &&
+ ExportList->second.count(GUID)) ||
+ GUIDPreservedSymbols.count(GUID);
};
thinLTOInternalizeAndPromoteInIndex(Index, isExported);
thinLTOInternalizeModule(TheModule,
@@ -895,9 +894,7 @@ void ThinLTOCodeGenerator::run() {
// Convert the preserved symbols set from string to GUID, this is needed for
// computing the caching hash and the internalization.
auto GUIDPreservedSymbols =
- convertSymbolNamesToGUID(PreservedSymbols, TMBuilder.TheTriple);
- auto GUIDCrossRefSymbols =
- convertSymbolNamesToGUID(CrossReferencedSymbols, TMBuilder.TheTriple);
+ computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
// Compute "dead" symbols, we don't want to import/export these!
auto DeadSymbols = computeDeadSymbols(*Index, GUIDPreservedSymbols);
@@ -919,16 +916,11 @@ void ThinLTOCodeGenerator::run() {
// impacts the caching.
resolveWeakForLinkerInIndex(*Index, ResolvedODR);
- auto isExported = [&](StringRef ModuleIdentifier,
- GlobalValue::GUID GUID) -> SummaryResolution {
- if (GUIDPreservedSymbols.count(GUID))
- return Exported;
- if (GUIDCrossRefSymbols.count(GUID))
- return Hidden;
+ auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
const auto &ExportList = ExportLists.find(ModuleIdentifier);
- if (ExportList != ExportLists.end() && ExportList->second.count(GUID))
- return Hidden;
- return Internal;
+ return (ExportList != ExportLists.end() &&
+ ExportList->second.count(GUID)) ||
+ GUIDPreservedSymbols.count(GUID);
};
// Use global summary-based analysis to identify symbols that can be
OpenPOWER on IntegriCloud