summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorevgeny <eleviant@accesssoftek.com>2019-12-18 18:33:15 +0300
committerevgeny <eleviant@accesssoftek.com>2019-12-18 18:33:15 +0300
commitad364956edb7f06e0064e90e7c37d13b3cccd1cf (patch)
tree9d180ba44edd7947fdf1a25fb55c3fc70c23216b /llvm/lib
parent3a779b7dfd8ee2924997dbed7f6c43d7989895f6 (diff)
downloadbcm5719-llvm-ad364956edb7f06e0064e90e7c37d13b3cccd1cf.tar.gz
bcm5719-llvm-ad364956edb7f06e0064e90e7c37d13b3cccd1cf.zip
[ThinLTO] Show preserved symbols in DOT files
Differential revision: https://reviews.llvm.org/D71608
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp2
-rw-r--r--llvm/lib/IR/ModuleSummaryIndex.cpp6
-rw-r--r--llvm/lib/LTO/LTO.cpp3
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp36
4 files changed, 27 insertions, 20 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 58e583d5d3a..8a1206f49c2 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -820,7 +820,7 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
if (EC)
report_fatal_error(Twine("Failed to open dot file ") +
ModuleSummaryDotFile + ": " + EC.message() + "\n");
- Index.exportToDot(OSDot);
+ Index.exportToDot(OSDot, {});
}
return Index;
diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index 5d35dbe06f2..180f96269a1 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -405,7 +405,9 @@ static bool hasWriteOnlyFlag(const GlobalValueSummary *S) {
return false;
}
-void ModuleSummaryIndex::exportToDot(raw_ostream &OS) const {
+void ModuleSummaryIndex::exportToDot(
+ raw_ostream &OS,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const {
std::vector<Edge> CrossModuleEdges;
DenseMap<GlobalValue::GUID, std::vector<uint64_t>> NodeMap;
using GVSOrderedMapTy = std::map<GlobalValue::GUID, GlobalValueSummary *>;
@@ -485,6 +487,8 @@ void ModuleSummaryIndex::exportToDot(raw_ostream &OS) const {
A.addComment("dsoLocal");
if (Flags.CanAutoHide)
A.addComment("canAutoHide");
+ if (GUIDPreservedSymbols.count(SummaryIt.first))
+ A.addComment("preserved");
auto VI = getValueInfo(SummaryIt.first);
A.add("label", getNodeLabel(VI, SummaryIt.second));
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 0d48090e426..950315fc2ed 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1264,7 +1264,8 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
if (ThinLTO.ModuleMap.empty())
return Error::success();
- if (Conf.CombinedIndexHook && !Conf.CombinedIndexHook(ThinLTO.CombinedIndex))
+ if (Conf.CombinedIndexHook &&
+ !Conf.CombinedIndexHook(ThinLTO.CombinedIndex, GUIDPreservedSymbols))
return Error::success();
// Collect for each module the list of function it defines (GUID ->
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index e437b4457d4..4c5302d15f0 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -102,23 +102,25 @@ Error Config::addSaveTemps(std::string OutputFileName,
setHook("4.opt", PostOptModuleHook);
setHook("5.precodegen", PreCodeGenModuleHook);
- CombinedIndexHook = [=](const ModuleSummaryIndex &Index) {
- std::string Path = OutputFileName + "index.bc";
- std::error_code EC;
- raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::OF_None);
- // Because -save-temps is a debugging feature, we report the error
- // directly and exit.
- if (EC)
- reportOpenError(Path, EC.message());
- WriteIndexToFile(Index, OS);
-
- Path = OutputFileName + "index.dot";
- raw_fd_ostream OSDot(Path, EC, sys::fs::OpenFlags::OF_None);
- if (EC)
- reportOpenError(Path, EC.message());
- Index.exportToDot(OSDot);
- return true;
- };
+ CombinedIndexHook =
+ [=](const ModuleSummaryIndex &Index,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
+ std::string Path = OutputFileName + "index.bc";
+ std::error_code EC;
+ raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::OF_None);
+ // Because -save-temps is a debugging feature, we report the error
+ // directly and exit.
+ if (EC)
+ reportOpenError(Path, EC.message());
+ WriteIndexToFile(Index, OS);
+
+ Path = OutputFileName + "index.dot";
+ raw_fd_ostream OSDot(Path, EC, sys::fs::OpenFlags::OF_None);
+ if (EC)
+ reportOpenError(Path, EC.message());
+ Index.exportToDot(OSDot, GUIDPreservedSymbols);
+ return true;
+ };
return Error::success();
}
OpenPOWER on IntegriCloud