forked from OSchip/llvm-project
[ThinLTO] Show preserved symbols in DOT files
Differential revision: https://reviews.llvm.org/D71608
This commit is contained in:
parent
3a779b7dfd
commit
ad364956ed
|
@ -1376,7 +1376,9 @@ public:
|
|||
void dump() const;
|
||||
|
||||
/// Export summary to dot file for GraphViz.
|
||||
void exportToDot(raw_ostream& OS) const;
|
||||
void
|
||||
exportToDot(raw_ostream &OS,
|
||||
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const;
|
||||
|
||||
/// Print out strongly connected components for debugging.
|
||||
void dumpSCCs(raw_ostream &OS);
|
||||
|
|
|
@ -183,8 +183,9 @@ struct Config {
|
|||
///
|
||||
/// It is called regardless of whether the backend is in-process, although it
|
||||
/// is not called from individual backend processes.
|
||||
using CombinedIndexHookFn =
|
||||
std::function<bool(const ModuleSummaryIndex &Index)>;
|
||||
using CombinedIndexHookFn = std::function<bool(
|
||||
const ModuleSummaryIndex &Index,
|
||||
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)>;
|
||||
CombinedIndexHookFn CombinedIndexHook;
|
||||
|
||||
/// This is a convenience function that configures this Config object to write
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
return true;
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
; COMBINED-NEXT: label = "dot-dumper{{.*}}1.bc";
|
||||
; COMBINED-NEXT: node [style=filled,fillcolor=lightblue];
|
||||
; COMBINED-NEXT: M0_[[MAIN_ALIAS:[0-9]+]] [style="dotted,filled",shape="box",label="main_alias",fillcolor="red"]; // alias, dead
|
||||
; COMBINED-NEXT: M0_[[MAIN:[0-9]+]] [shape="record",label="main|extern (inst: 4, ffl: 000000)}"]; // function
|
||||
; COMBINED-NEXT: M0_[[MAIN:[0-9]+]] [shape="record",label="main|extern (inst: 4, ffl: 000000)}"]; // function, preserved
|
||||
; COMBINED-NEXT: // Edges:
|
||||
; COMBINED-NEXT: M0_[[MAIN_ALIAS]] -> M0_[[MAIN]] [style=dotted]; // alias
|
||||
; COMBINED-NEXT: }
|
||||
|
|
Loading…
Reference in New Issue