2016-03-15 00:04:37 +00:00
|
|
|
//===-- ModuleSummaryIndex.cpp - Module Summary Index ---------------------===//
|
2016-03-14 21:18:10 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-03-14 21:18:10 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the module index and summary classes for the
|
|
|
|
// IR library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-15 00:04:37 +00:00
|
|
|
#include "llvm/IR/ModuleSummaryIndex.h"
|
2018-02-19 15:14:50 +00:00
|
|
|
#include "llvm/ADT/SCCIterator.h"
|
2018-11-17 20:03:22 +00:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2016-03-14 21:18:10 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2019-12-03 21:56:07 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2018-01-22 13:35:40 +00:00
|
|
|
#include "llvm/Support/Path.h"
|
2018-02-19 15:14:50 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-03-14 21:18:10 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2018-11-17 20:03:22 +00:00
|
|
|
#define DEBUG_TYPE "module-summary-index"
|
|
|
|
|
|
|
|
STATISTIC(ReadOnlyLiveGVars,
|
|
|
|
"Number of live global variables marked read only");
|
2019-07-05 15:25:05 +00:00
|
|
|
STATISTIC(WriteOnlyLiveGVars,
|
|
|
|
"Number of live global variables marked write only");
|
2018-11-17 20:03:22 +00:00
|
|
|
|
2019-12-03 21:56:07 +00:00
|
|
|
static cl::opt<bool> PropagateAttrs("propagate-attrs", cl::init(true),
|
|
|
|
cl::Hidden,
|
|
|
|
cl::desc("Propagate attributes in index"));
|
|
|
|
|
2020-01-30 17:56:43 +00:00
|
|
|
static cl::opt<bool> ImportConstantsWithRefs(
|
2020-02-12 23:17:56 +00:00
|
|
|
"import-constants-with-refs", cl::init(true), cl::Hidden,
|
2020-01-30 17:56:43 +00:00
|
|
|
cl::desc("Import constant global variables with references"));
|
|
|
|
|
2020-07-01 12:41:14 +00:00
|
|
|
constexpr uint32_t FunctionSummary::ParamAccess::RangeWidth;
|
|
|
|
|
2018-02-19 15:14:50 +00:00
|
|
|
FunctionSummary FunctionSummary::ExternalNode =
|
|
|
|
FunctionSummary::makeDummyFunctionSummary({});
|
[ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligible
Summary:
We hit undefined references building with ThinLTO when one source file
contained explicit instantiations of a template method (weak_odr) but
there were also implicit instantiations in another file (linkonce_odr),
and the latter was the prevailing copy. In this case the symbol was
marked hidden when the prevailing linkonce_odr copy was promoted to
weak_odr. It led to unsats when the resulting shared library was linked
with other code that contained a reference (expecting to be resolved due
to the explicit instantiation).
Add a CanAutoHide flag to the GV summary to allow the thin link to
identify when all copies are eligible for auto-hiding (because they were
all originally linkonce_odr global unnamed addr), and only do the
auto-hide in that case.
Most of the changes here are due to plumbing the new flag through the
bitcode and llvm assembly, and resulting test changes. I augmented the
existing auto-hide test to check for this situation.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, dexonsmith, arphaman, dang, llvm-commits, steven_wu, wmi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59709
llvm-svn: 360466
2019-05-10 20:08:24 +00:00
|
|
|
|
2018-02-05 17:17:51 +00:00
|
|
|
bool ValueInfo::isDSOLocal() const {
|
|
|
|
// Need to check all summaries are local in case of hash collisions.
|
|
|
|
return getSummaryList().size() &&
|
|
|
|
llvm::all_of(getSummaryList(),
|
|
|
|
[](const std::unique_ptr<GlobalValueSummary> &Summary) {
|
|
|
|
return Summary->isDSOLocal();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligible
Summary:
We hit undefined references building with ThinLTO when one source file
contained explicit instantiations of a template method (weak_odr) but
there were also implicit instantiations in another file (linkonce_odr),
and the latter was the prevailing copy. In this case the symbol was
marked hidden when the prevailing linkonce_odr copy was promoted to
weak_odr. It led to unsats when the resulting shared library was linked
with other code that contained a reference (expecting to be resolved due
to the explicit instantiation).
Add a CanAutoHide flag to the GV summary to allow the thin link to
identify when all copies are eligible for auto-hiding (because they were
all originally linkonce_odr global unnamed addr), and only do the
auto-hide in that case.
Most of the changes here are due to plumbing the new flag through the
bitcode and llvm assembly, and resulting test changes. I augmented the
existing auto-hide test to check for this situation.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, dexonsmith, arphaman, dang, llvm-commits, steven_wu, wmi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59709
llvm-svn: 360466
2019-05-10 20:08:24 +00:00
|
|
|
bool ValueInfo::canAutoHide() const {
|
|
|
|
// Can only auto hide if all copies are eligible to auto hide.
|
|
|
|
return getSummaryList().size() &&
|
|
|
|
llvm::all_of(getSummaryList(),
|
|
|
|
[](const std::unique_ptr<GlobalValueSummary> &Summary) {
|
|
|
|
return Summary->canAutoHide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-05 15:25:05 +00:00
|
|
|
// Gets the number of readonly and writeonly refs in RefEdgeList
|
|
|
|
std::pair<unsigned, unsigned> FunctionSummary::specialRefCounts() const {
|
|
|
|
// Here we take advantage of having all readonly and writeonly references
|
2018-11-16 07:08:00 +00:00
|
|
|
// located in the end of the RefEdgeList.
|
|
|
|
auto Refs = refs();
|
2019-07-05 15:25:05 +00:00
|
|
|
unsigned RORefCnt = 0, WORefCnt = 0;
|
|
|
|
int I;
|
|
|
|
for (I = Refs.size() - 1; I >= 0 && Refs[I].isWriteOnly(); --I)
|
|
|
|
WORefCnt++;
|
|
|
|
for (; I >= 0 && Refs[I].isReadOnly(); --I)
|
|
|
|
RORefCnt++;
|
|
|
|
return {RORefCnt, WORefCnt};
|
2018-11-16 07:08:00 +00:00
|
|
|
}
|
|
|
|
|
2019-11-18 23:04:56 +00:00
|
|
|
constexpr uint64_t ModuleSummaryIndex::BitcodeSummaryVersion;
|
|
|
|
|
2020-02-18 14:49:54 +00:00
|
|
|
uint64_t ModuleSummaryIndex::getFlags() const {
|
|
|
|
uint64_t Flags = 0;
|
|
|
|
if (withGlobalValueDeadStripping())
|
|
|
|
Flags |= 0x1;
|
|
|
|
if (skipModuleByDistributedBackend())
|
|
|
|
Flags |= 0x2;
|
|
|
|
if (hasSyntheticEntryCounts())
|
|
|
|
Flags |= 0x4;
|
|
|
|
if (enableSplitLTOUnit())
|
|
|
|
Flags |= 0x8;
|
|
|
|
if (partiallySplitLTOUnits())
|
|
|
|
Flags |= 0x10;
|
|
|
|
if (withAttributePropagation())
|
|
|
|
Flags |= 0x20;
|
|
|
|
return Flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModuleSummaryIndex::setFlags(uint64_t Flags) {
|
|
|
|
assert(Flags <= 0x3f && "Unexpected bits in flag");
|
|
|
|
// 1 bit: WithGlobalValueDeadStripping flag.
|
|
|
|
// Set on combined index only.
|
|
|
|
if (Flags & 0x1)
|
|
|
|
setWithGlobalValueDeadStripping();
|
|
|
|
// 1 bit: SkipModuleByDistributedBackend flag.
|
|
|
|
// Set on combined index only.
|
|
|
|
if (Flags & 0x2)
|
|
|
|
setSkipModuleByDistributedBackend();
|
|
|
|
// 1 bit: HasSyntheticEntryCounts flag.
|
|
|
|
// Set on combined index only.
|
|
|
|
if (Flags & 0x4)
|
|
|
|
setHasSyntheticEntryCounts();
|
|
|
|
// 1 bit: DisableSplitLTOUnit flag.
|
|
|
|
// Set on per module indexes. It is up to the client to validate
|
|
|
|
// the consistency of this flag across modules being linked.
|
|
|
|
if (Flags & 0x8)
|
|
|
|
setEnableSplitLTOUnit();
|
|
|
|
// 1 bit: PartiallySplitLTOUnits flag.
|
|
|
|
// Set on combined index only.
|
|
|
|
if (Flags & 0x10)
|
|
|
|
setPartiallySplitLTOUnits();
|
|
|
|
// 1 bit: WithAttributePropagation flag.
|
|
|
|
// Set on combined index only.
|
|
|
|
if (Flags & 0x20)
|
|
|
|
setWithAttributePropagation();
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:13:11 +00:00
|
|
|
// Collect for the given module the list of function it defines
|
|
|
|
// (GUID -> Summary).
|
|
|
|
void ModuleSummaryIndex::collectDefinedFunctionsForModule(
|
2016-04-25 21:09:51 +00:00
|
|
|
StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
|
2016-04-12 21:13:11 +00:00
|
|
|
for (auto &GlobalList : *this) {
|
|
|
|
auto GUID = GlobalList.first;
|
2017-05-04 18:03:25 +00:00
|
|
|
for (auto &GlobSummary : GlobalList.second.SummaryList) {
|
2016-04-24 14:57:11 +00:00
|
|
|
auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobSummary.get());
|
2016-04-12 21:13:11 +00:00
|
|
|
if (!Summary)
|
|
|
|
// Ignore global variable, focus on functions
|
|
|
|
continue;
|
|
|
|
// Ignore summaries from other modules.
|
|
|
|
if (Summary->modulePath() != ModulePath)
|
|
|
|
continue;
|
2016-04-24 14:57:11 +00:00
|
|
|
GVSummaryMap[GUID] = Summary;
|
2016-04-12 21:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-24 14:57:11 +00:00
|
|
|
GlobalValueSummary *
|
|
|
|
ModuleSummaryIndex::getGlobalValueSummary(uint64_t ValueGUID,
|
|
|
|
bool PerModuleIndex) const {
|
2017-05-04 18:03:25 +00:00
|
|
|
auto VI = getValueInfo(ValueGUID);
|
|
|
|
assert(VI && "GlobalValue not found in index");
|
|
|
|
assert((!PerModuleIndex || VI.getSummaryList().size() == 1) &&
|
2016-04-05 09:07:47 +00:00
|
|
|
"Expected a single entry per global value in per-module index");
|
2017-05-04 18:03:25 +00:00
|
|
|
auto &Summary = VI.getSummaryList()[0];
|
2016-04-24 14:57:11 +00:00
|
|
|
return Summary.get();
|
2016-04-05 00:40:16 +00:00
|
|
|
}
|
2017-06-15 17:26:13 +00:00
|
|
|
|
|
|
|
bool ModuleSummaryIndex::isGUIDLive(GlobalValue::GUID GUID) const {
|
|
|
|
auto VI = getValueInfo(GUID);
|
|
|
|
if (!VI)
|
2017-06-16 00:18:29 +00:00
|
|
|
return true;
|
|
|
|
const auto &SummaryList = VI.getSummaryList();
|
|
|
|
if (SummaryList.empty())
|
|
|
|
return true;
|
|
|
|
for (auto &I : SummaryList)
|
2017-06-15 17:26:13 +00:00
|
|
|
if (isGlobalValueLive(I.get()))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-22 13:35:40 +00:00
|
|
|
|
2020-07-30 20:49:49 +00:00
|
|
|
static void
|
|
|
|
propagateAttributesToRefs(GlobalValueSummary *S,
|
|
|
|
DenseSet<ValueInfo> &MarkedNonReadWriteOnly) {
|
2019-07-05 15:25:05 +00:00
|
|
|
// If reference is not readonly or writeonly then referenced summary is not
|
|
|
|
// read/writeonly either. Note that:
|
2018-11-16 07:08:00 +00:00
|
|
|
// - All references from GlobalVarSummary are conservatively considered as
|
2019-07-05 15:25:05 +00:00
|
|
|
// not readonly or writeonly. Tracking them properly requires more complex
|
|
|
|
// analysis then we have now.
|
2018-11-16 07:08:00 +00:00
|
|
|
//
|
|
|
|
// - AliasSummary objects have no refs at all so this function is a no-op
|
|
|
|
// for them.
|
|
|
|
for (auto &VI : S->refs()) {
|
2019-07-05 15:25:05 +00:00
|
|
|
assert(VI.getAccessSpecifier() == 0 || isa<FunctionSummary>(S));
|
2020-07-30 20:49:49 +00:00
|
|
|
if (!VI.getAccessSpecifier()) {
|
|
|
|
if (!MarkedNonReadWriteOnly.insert(VI).second)
|
|
|
|
continue;
|
|
|
|
} else if (MarkedNonReadWriteOnly.find(VI) != MarkedNonReadWriteOnly.end())
|
|
|
|
continue;
|
2018-11-16 07:08:00 +00:00
|
|
|
for (auto &Ref : VI.getSummaryList())
|
2019-07-05 15:25:05 +00:00
|
|
|
// If references to alias is not read/writeonly then aliasee
|
|
|
|
// is not read/writeonly
|
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(Ref->getBaseObject())) {
|
|
|
|
if (!VI.isReadOnly())
|
|
|
|
GVS->setReadOnly(false);
|
|
|
|
if (!VI.isWriteOnly())
|
|
|
|
GVS->setWriteOnly(false);
|
|
|
|
}
|
2018-11-16 07:08:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 15:25:05 +00:00
|
|
|
// Do the access attribute propagation in combined index.
|
|
|
|
// The goal of attribute propagation is internalization of readonly (RO)
|
|
|
|
// or writeonly (WO) variables. To determine which variables are RO or WO
|
|
|
|
// and which are not we take following steps:
|
|
|
|
// - During analysis we speculatively assign readonly and writeonly
|
|
|
|
// attribute to all variables which can be internalized. When computing
|
|
|
|
// function summary we also assign readonly or writeonly attribute to a
|
|
|
|
// reference if function doesn't modify referenced variable (readonly)
|
|
|
|
// or doesn't read it (writeonly).
|
|
|
|
//
|
|
|
|
// - After computing dead symbols in combined index we do the attribute
|
|
|
|
// propagation. During this step we:
|
|
|
|
// a. clear RO and WO attributes from variables which are preserved or
|
|
|
|
// can't be imported
|
|
|
|
// b. clear RO and WO attributes from variables referenced by any global
|
|
|
|
// variable initializer
|
|
|
|
// c. clear RO attribute from variable referenced by a function when
|
|
|
|
// reference is not readonly
|
|
|
|
// d. clear WO attribute from variable referenced by a function when
|
|
|
|
// reference is not writeonly
|
2018-11-16 07:08:00 +00:00
|
|
|
//
|
2019-07-05 15:25:05 +00:00
|
|
|
// Because of (c, d) we don't internalize variables read by function A
|
|
|
|
// and modified by function B.
|
2018-11-16 07:08:00 +00:00
|
|
|
//
|
|
|
|
// Internalization itself happens in the backend after import is finished
|
2019-07-05 15:25:05 +00:00
|
|
|
// See internalizeGVsAfterImport.
|
|
|
|
void ModuleSummaryIndex::propagateAttributes(
|
2018-11-16 07:08:00 +00:00
|
|
|
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
|
2019-12-03 21:56:07 +00:00
|
|
|
if (!PropagateAttrs)
|
|
|
|
return;
|
2020-07-30 20:49:49 +00:00
|
|
|
DenseSet<ValueInfo> MarkedNonReadWriteOnly;
|
2018-11-16 07:08:00 +00:00
|
|
|
for (auto &P : *this)
|
|
|
|
for (auto &S : P.second.SummaryList) {
|
2020-07-30 20:49:49 +00:00
|
|
|
if (!isGlobalValueLive(S.get())) {
|
|
|
|
// computeDeadSymbols should have marked all copies live. Note that
|
|
|
|
// it is possible that there is a GUID collision between internal
|
|
|
|
// symbols with the same name in different files of the same name but
|
|
|
|
// not enough distinguishing path. Because computeDeadSymbols should
|
|
|
|
// conservatively mark all copies live we can assert here that all are
|
|
|
|
// dead if any copy is dead.
|
|
|
|
assert(llvm::none_of(
|
|
|
|
P.second.SummaryList,
|
|
|
|
[&](const std::unique_ptr<GlobalValueSummary> &Summary) {
|
|
|
|
return isGlobalValueLive(Summary.get());
|
|
|
|
}));
|
2018-11-16 07:08:00 +00:00
|
|
|
// We don't examine references from dead objects
|
2020-07-30 20:49:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-11-16 07:08:00 +00:00
|
|
|
|
2019-07-05 15:25:05 +00:00
|
|
|
// Global variable can't be marked read/writeonly if it is not eligible
|
|
|
|
// to import since we need to ensure that all external references get
|
|
|
|
// a local (imported) copy. It also can't be marked read/writeonly if
|
|
|
|
// it or any alias (since alias points to the same memory) are preserved
|
|
|
|
// or notEligibleToImport, since either of those means there could be
|
|
|
|
// writes (or reads in case of writeonly) that are not visible (because
|
|
|
|
// preserved means it could have external to DSO writes or reads, and
|
|
|
|
// notEligibleToImport means it could have writes or reads via inline
|
|
|
|
// assembly leading it to be in the @llvm.*used).
|
2018-11-16 07:08:00 +00:00
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(S->getBaseObject()))
|
|
|
|
// Here we intentionally pass S.get() not GVS, because S could be
|
2019-11-07 12:13:35 +00:00
|
|
|
// an alias. We don't analyze references here, because we have to
|
|
|
|
// know exactly if GV is readonly to do so.
|
|
|
|
if (!canImportGlobalVar(S.get(), /* AnalyzeRefs */ false) ||
|
2019-07-05 15:25:05 +00:00
|
|
|
GUIDPreservedSymbols.count(P.first)) {
|
2018-11-16 07:08:00 +00:00
|
|
|
GVS->setReadOnly(false);
|
2019-07-05 15:25:05 +00:00
|
|
|
GVS->setWriteOnly(false);
|
|
|
|
}
|
2020-07-30 20:49:49 +00:00
|
|
|
propagateAttributesToRefs(S.get(), MarkedNonReadWriteOnly);
|
2018-11-16 07:08:00 +00:00
|
|
|
}
|
2019-12-03 21:56:07 +00:00
|
|
|
setWithAttributePropagation();
|
2018-11-17 20:41:45 +00:00
|
|
|
if (llvm::AreStatisticsEnabled())
|
|
|
|
for (auto &P : *this)
|
|
|
|
if (P.second.SummaryList.size())
|
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(
|
|
|
|
P.second.SummaryList[0]->getBaseObject()))
|
2019-07-05 15:25:05 +00:00
|
|
|
if (isGlobalValueLive(GVS)) {
|
|
|
|
if (GVS->maybeReadOnly())
|
|
|
|
ReadOnlyLiveGVars++;
|
|
|
|
if (GVS->maybeWriteOnly())
|
|
|
|
WriteOnlyLiveGVars++;
|
|
|
|
}
|
2018-11-16 07:08:00 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 12:13:35 +00:00
|
|
|
bool ModuleSummaryIndex::canImportGlobalVar(GlobalValueSummary *S,
|
|
|
|
bool AnalyzeRefs) const {
|
|
|
|
auto HasRefsPreventingImport = [this](const GlobalVarSummary *GVS) {
|
2019-11-08 17:50:34 +00:00
|
|
|
// We don't analyze GV references during attribute propagation, so
|
|
|
|
// GV with non-trivial initializer can be marked either read or
|
|
|
|
// write-only.
|
|
|
|
// Importing definiton of readonly GV with non-trivial initializer
|
|
|
|
// allows us doing some extra optimizations (like converting indirect
|
|
|
|
// calls to direct).
|
|
|
|
// Definition of writeonly GV with non-trivial initializer should also
|
|
|
|
// be imported. Not doing so will result in:
|
|
|
|
// a) GV internalization in source module (because it's writeonly)
|
|
|
|
// b) Importing of GV declaration to destination module as a result
|
|
|
|
// of promotion.
|
|
|
|
// c) Link error (external declaration with internal definition).
|
|
|
|
// However we do not promote objects referenced by writeonly GV
|
|
|
|
// initializer by means of converting it to 'zeroinitializer'
|
2020-01-30 17:56:43 +00:00
|
|
|
return !(ImportConstantsWithRefs && GVS->isConstant()) &&
|
|
|
|
!isReadOnly(GVS) && !isWriteOnly(GVS) && GVS->refs().size();
|
2019-11-07 12:13:35 +00:00
|
|
|
};
|
|
|
|
auto *GVS = cast<GlobalVarSummary>(S->getBaseObject());
|
|
|
|
|
|
|
|
// Global variable with non-trivial initializer can be imported
|
|
|
|
// if it's readonly. This gives us extra opportunities for constant
|
|
|
|
// folding and converting indirect calls to direct calls. We don't
|
|
|
|
// analyze GV references during attribute propagation, because we
|
|
|
|
// don't know yet if it is readonly or not.
|
|
|
|
return !GlobalValue::isInterposableLinkage(S->linkage()) &&
|
|
|
|
!S->notEligibleToImport() &&
|
|
|
|
(!AnalyzeRefs || !HasRefsPreventingImport(GVS));
|
|
|
|
}
|
|
|
|
|
2018-02-19 15:14:50 +00:00
|
|
|
// TODO: write a graphviz dumper for SCCs (see ModuleSummaryIndex::exportToDot)
|
|
|
|
// then delete this function and update its tests
|
|
|
|
LLVM_DUMP_METHOD
|
|
|
|
void ModuleSummaryIndex::dumpSCCs(raw_ostream &O) {
|
|
|
|
for (scc_iterator<ModuleSummaryIndex *> I =
|
|
|
|
scc_begin<ModuleSummaryIndex *>(this);
|
|
|
|
!I.isAtEnd(); ++I) {
|
|
|
|
O << "SCC (" << utostr(I->size()) << " node" << (I->size() == 1 ? "" : "s")
|
|
|
|
<< ") {\n";
|
2019-12-17 20:57:58 +00:00
|
|
|
for (const ValueInfo &V : *I) {
|
2018-02-19 15:14:50 +00:00
|
|
|
FunctionSummary *F = nullptr;
|
|
|
|
if (V.getSummaryList().size())
|
|
|
|
F = cast<FunctionSummary>(V.getSummaryList().front().get());
|
|
|
|
O << " " << (F == nullptr ? "External" : "") << " " << utostr(V.getGUID())
|
2020-03-01 17:17:21 +00:00
|
|
|
<< (I.hasCycle() ? " (has cycle)" : "") << "\n";
|
2018-02-19 15:14:50 +00:00
|
|
|
}
|
|
|
|
O << "}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 13:35:40 +00:00
|
|
|
namespace {
|
|
|
|
struct Attributes {
|
|
|
|
void add(const Twine &Name, const Twine &Value,
|
|
|
|
const Twine &Comment = Twine());
|
2018-11-16 07:08:00 +00:00
|
|
|
void addComment(const Twine &Comment);
|
2018-01-22 13:35:40 +00:00
|
|
|
std::string getAsString() const;
|
|
|
|
|
|
|
|
std::vector<std::string> Attrs;
|
|
|
|
std::string Comments;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Edge {
|
|
|
|
uint64_t SrcMod;
|
|
|
|
int Hotness;
|
|
|
|
GlobalValue::GUID Src;
|
|
|
|
GlobalValue::GUID Dst;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attributes::add(const Twine &Name, const Twine &Value,
|
|
|
|
const Twine &Comment) {
|
|
|
|
std::string A = Name.str();
|
|
|
|
A += "=\"";
|
|
|
|
A += Value.str();
|
|
|
|
A += "\"";
|
|
|
|
Attrs.push_back(A);
|
2018-11-16 07:08:00 +00:00
|
|
|
addComment(Comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attributes::addComment(const Twine &Comment) {
|
2018-01-22 13:35:40 +00:00
|
|
|
if (!Comment.isTriviallyEmpty()) {
|
|
|
|
if (Comments.empty())
|
|
|
|
Comments = " // ";
|
|
|
|
else
|
|
|
|
Comments += ", ";
|
|
|
|
Comments += Comment.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Attributes::getAsString() const {
|
|
|
|
if (Attrs.empty())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
std::string Ret = "[";
|
|
|
|
for (auto &A : Attrs)
|
|
|
|
Ret += A + ",";
|
|
|
|
Ret.pop_back();
|
|
|
|
Ret += "];";
|
|
|
|
Ret += Comments;
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string linkageToString(GlobalValue::LinkageTypes LT) {
|
|
|
|
switch (LT) {
|
|
|
|
case GlobalValue::ExternalLinkage:
|
|
|
|
return "extern";
|
|
|
|
case GlobalValue::AvailableExternallyLinkage:
|
|
|
|
return "av_ext";
|
|
|
|
case GlobalValue::LinkOnceAnyLinkage:
|
|
|
|
return "linkonce";
|
|
|
|
case GlobalValue::LinkOnceODRLinkage:
|
|
|
|
return "linkonce_odr";
|
|
|
|
case GlobalValue::WeakAnyLinkage:
|
|
|
|
return "weak";
|
|
|
|
case GlobalValue::WeakODRLinkage:
|
|
|
|
return "weak_odr";
|
|
|
|
case GlobalValue::AppendingLinkage:
|
|
|
|
return "appending";
|
|
|
|
case GlobalValue::InternalLinkage:
|
|
|
|
return "internal";
|
|
|
|
case GlobalValue::PrivateLinkage:
|
|
|
|
return "private";
|
|
|
|
case GlobalValue::ExternalWeakLinkage:
|
|
|
|
return "extern_weak";
|
|
|
|
case GlobalValue::CommonLinkage:
|
|
|
|
return "common";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "<unknown>";
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string fflagsToString(FunctionSummary::FFlags F) {
|
|
|
|
auto FlagValue = [](unsigned V) { return V ? '1' : '0'; };
|
2018-11-06 19:41:35 +00:00
|
|
|
char FlagRep[] = {FlagValue(F.ReadNone), FlagValue(F.ReadOnly),
|
|
|
|
FlagValue(F.NoRecurse), FlagValue(F.ReturnDoesNotAlias),
|
2019-11-08 23:50:55 +00:00
|
|
|
FlagValue(F.NoInline), FlagValue(F.AlwaysInline), 0};
|
2018-01-22 13:35:40 +00:00
|
|
|
|
|
|
|
return FlagRep;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get string representation of function instruction count and flags.
|
|
|
|
static std::string getSummaryAttributes(GlobalValueSummary* GVS) {
|
|
|
|
auto *FS = dyn_cast_or_null<FunctionSummary>(GVS);
|
|
|
|
if (!FS)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
return std::string("inst: ") + std::to_string(FS->instCount()) +
|
|
|
|
", ffl: " + fflagsToString(FS->fflags());
|
|
|
|
}
|
|
|
|
|
[LTO] Fix a crash caused by accessing an empty ValueInfo
ModuleSummaryIndex::exportToDot crashes when linking the Linux kernel
under ThinLTO using LLVMgold.so. This is due to the exportToDot
function trying to get the GUID of an empty ValueInfo. The root cause
related to the fact that we attempt to get the GUID of an aliasee
via its OriginalGUID recorded in the aliasee summary, and that is not
always possible. Specifically, we cannot do this mapping when the value
is internal linkage and there were other internal linkage symbols with
the same name.
There are 2 fixes for the problem included here.
1) In all cases where we can currently print the dot file from the
command line (which is only via save-temps), we have a valid AliaseeGUID
in the AliasSummary. Use that when it is available, so that we can get
the correct aliasee GUID whenever possible.
2) However, if we were to invoke exportToDot from the debugger right
after it is built during the initial analysis step (i.e. the per-module
summary), we won't have the AliaseeGUID field populated. In that case,
we have a fallback fix that will simply print "@"+GUID when we aren't
able to get the GUID from the OriginalGUID. It simply checks if the VI
is valid or not before attempting to get the name. Additionally, since
getAliaseeGUID will assert that the AliaseeGUID is non-zero, guard the
earlier fix #1 by a new function hasAliaseeGUID().
Reviewers: pcc, tmroeder
Subscribers: evgeny777, mehdi_amini, inglorion, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D53986
llvm-svn: 346055
2018-11-02 23:49:21 +00:00
|
|
|
static std::string getNodeVisualName(GlobalValue::GUID Id) {
|
|
|
|
return std::string("@") + std::to_string(Id);
|
|
|
|
}
|
|
|
|
|
2018-01-22 13:35:40 +00:00
|
|
|
static std::string getNodeVisualName(const ValueInfo &VI) {
|
[LTO] Fix a crash caused by accessing an empty ValueInfo
ModuleSummaryIndex::exportToDot crashes when linking the Linux kernel
under ThinLTO using LLVMgold.so. This is due to the exportToDot
function trying to get the GUID of an empty ValueInfo. The root cause
related to the fact that we attempt to get the GUID of an aliasee
via its OriginalGUID recorded in the aliasee summary, and that is not
always possible. Specifically, we cannot do this mapping when the value
is internal linkage and there were other internal linkage symbols with
the same name.
There are 2 fixes for the problem included here.
1) In all cases where we can currently print the dot file from the
command line (which is only via save-temps), we have a valid AliaseeGUID
in the AliasSummary. Use that when it is available, so that we can get
the correct aliasee GUID whenever possible.
2) However, if we were to invoke exportToDot from the debugger right
after it is built during the initial analysis step (i.e. the per-module
summary), we won't have the AliaseeGUID field populated. In that case,
we have a fallback fix that will simply print "@"+GUID when we aren't
able to get the GUID from the OriginalGUID. It simply checks if the VI
is valid or not before attempting to get the name. Additionally, since
getAliaseeGUID will assert that the AliaseeGUID is non-zero, guard the
earlier fix #1 by a new function hasAliaseeGUID().
Reviewers: pcc, tmroeder
Subscribers: evgeny777, mehdi_amini, inglorion, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D53986
llvm-svn: 346055
2018-11-02 23:49:21 +00:00
|
|
|
return VI.name().empty() ? getNodeVisualName(VI.getGUID()) : VI.name().str();
|
2018-01-22 13:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS) {
|
|
|
|
if (isa<AliasSummary>(GVS))
|
|
|
|
return getNodeVisualName(VI);
|
|
|
|
|
|
|
|
std::string Attrs = getSummaryAttributes(GVS);
|
|
|
|
std::string Label =
|
|
|
|
getNodeVisualName(VI) + "|" + linkageToString(GVS->linkage());
|
|
|
|
if (!Attrs.empty())
|
|
|
|
Label += std::string(" (") + Attrs + ")";
|
|
|
|
Label += "}";
|
|
|
|
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write definition of external node, which doesn't have any
|
|
|
|
// specific module associated with it. Typically this is function
|
|
|
|
// or variable defined in native object or library.
|
|
|
|
static void defineExternalNode(raw_ostream &OS, const char *Pfx,
|
[LTO] Fix a crash caused by accessing an empty ValueInfo
ModuleSummaryIndex::exportToDot crashes when linking the Linux kernel
under ThinLTO using LLVMgold.so. This is due to the exportToDot
function trying to get the GUID of an empty ValueInfo. The root cause
related to the fact that we attempt to get the GUID of an aliasee
via its OriginalGUID recorded in the aliasee summary, and that is not
always possible. Specifically, we cannot do this mapping when the value
is internal linkage and there were other internal linkage symbols with
the same name.
There are 2 fixes for the problem included here.
1) In all cases where we can currently print the dot file from the
command line (which is only via save-temps), we have a valid AliaseeGUID
in the AliasSummary. Use that when it is available, so that we can get
the correct aliasee GUID whenever possible.
2) However, if we were to invoke exportToDot from the debugger right
after it is built during the initial analysis step (i.e. the per-module
summary), we won't have the AliaseeGUID field populated. In that case,
we have a fallback fix that will simply print "@"+GUID when we aren't
able to get the GUID from the OriginalGUID. It simply checks if the VI
is valid or not before attempting to get the name. Additionally, since
getAliaseeGUID will assert that the AliaseeGUID is non-zero, guard the
earlier fix #1 by a new function hasAliaseeGUID().
Reviewers: pcc, tmroeder
Subscribers: evgeny777, mehdi_amini, inglorion, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D53986
llvm-svn: 346055
2018-11-02 23:49:21 +00:00
|
|
|
const ValueInfo &VI, GlobalValue::GUID Id) {
|
|
|
|
auto StrId = std::to_string(Id);
|
|
|
|
OS << " " << StrId << " [label=\"";
|
|
|
|
|
|
|
|
if (VI) {
|
|
|
|
OS << getNodeVisualName(VI);
|
|
|
|
} else {
|
|
|
|
OS << getNodeVisualName(Id);
|
|
|
|
}
|
|
|
|
OS << "\"]; // defined externally\n";
|
2018-01-22 13:35:40 +00:00
|
|
|
}
|
|
|
|
|
2018-11-16 07:08:00 +00:00
|
|
|
static bool hasReadOnlyFlag(const GlobalValueSummary *S) {
|
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
|
2019-07-05 15:25:05 +00:00
|
|
|
return GVS->maybeReadOnly();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool hasWriteOnlyFlag(const GlobalValueSummary *S) {
|
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
|
|
|
|
return GVS->maybeWriteOnly();
|
2018-11-16 07:08:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-15 16:29:01 +00:00
|
|
|
static bool hasConstantFlag(const GlobalValueSummary *S) {
|
|
|
|
if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
|
|
|
|
return GVS->isConstant();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:33:15 +00:00
|
|
|
void ModuleSummaryIndex::exportToDot(
|
|
|
|
raw_ostream &OS,
|
|
|
|
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const {
|
2018-01-22 13:35:40 +00:00
|
|
|
std::vector<Edge> CrossModuleEdges;
|
|
|
|
DenseMap<GlobalValue::GUID, std::vector<uint64_t>> NodeMap;
|
2019-02-26 07:38:21 +00:00
|
|
|
using GVSOrderedMapTy = std::map<GlobalValue::GUID, GlobalValueSummary *>;
|
|
|
|
std::map<StringRef, GVSOrderedMapTy> ModuleToDefinedGVS;
|
2018-01-22 13:35:40 +00:00
|
|
|
collectDefinedGVSummariesPerModule(ModuleToDefinedGVS);
|
|
|
|
|
|
|
|
// Get node identifier in form MXXX_<GUID>. The MXXX prefix is required,
|
|
|
|
// because we may have multiple linkonce functions summaries.
|
|
|
|
auto NodeId = [](uint64_t ModId, GlobalValue::GUID Id) {
|
|
|
|
return ModId == (uint64_t)-1 ? std::to_string(Id)
|
|
|
|
: std::string("M") + std::to_string(ModId) +
|
|
|
|
"_" + std::to_string(Id);
|
|
|
|
};
|
|
|
|
|
2018-10-24 07:48:32 +00:00
|
|
|
auto DrawEdge = [&](const char *Pfx, uint64_t SrcMod, GlobalValue::GUID SrcId,
|
2018-11-16 07:08:00 +00:00
|
|
|
uint64_t DstMod, GlobalValue::GUID DstId,
|
|
|
|
int TypeOrHotness) {
|
|
|
|
// 0 - alias
|
|
|
|
// 1 - reference
|
|
|
|
// 2 - constant reference
|
2019-07-05 15:25:05 +00:00
|
|
|
// 3 - writeonly reference
|
|
|
|
// Other value: (hotness - 4).
|
|
|
|
TypeOrHotness += 4;
|
2018-01-22 13:35:40 +00:00
|
|
|
static const char *EdgeAttrs[] = {
|
|
|
|
" [style=dotted]; // alias",
|
|
|
|
" [style=dashed]; // ref",
|
2018-11-16 07:08:00 +00:00
|
|
|
" [style=dashed,color=forestgreen]; // const-ref",
|
2019-07-05 15:25:05 +00:00
|
|
|
" [style=dashed,color=violetred]; // writeOnly-ref",
|
2018-01-22 13:35:40 +00:00
|
|
|
" // call (hotness : Unknown)",
|
|
|
|
" [color=blue]; // call (hotness : Cold)",
|
|
|
|
" // call (hotness : None)",
|
|
|
|
" [color=brown]; // call (hotness : Hot)",
|
|
|
|
" [style=bold,color=red]; // call (hotness : Critical)"};
|
|
|
|
|
|
|
|
assert(static_cast<size_t>(TypeOrHotness) <
|
|
|
|
sizeof(EdgeAttrs) / sizeof(EdgeAttrs[0]));
|
|
|
|
OS << Pfx << NodeId(SrcMod, SrcId) << " -> " << NodeId(DstMod, DstId)
|
|
|
|
<< EdgeAttrs[TypeOrHotness] << "\n";
|
|
|
|
};
|
|
|
|
|
|
|
|
OS << "digraph Summary {\n";
|
|
|
|
for (auto &ModIt : ModuleToDefinedGVS) {
|
2019-02-26 07:38:21 +00:00
|
|
|
auto ModId = getModuleId(ModIt.first);
|
|
|
|
OS << " // Module: " << ModIt.first << "\n";
|
2018-01-22 13:35:40 +00:00
|
|
|
OS << " subgraph cluster_" << std::to_string(ModId) << " {\n";
|
|
|
|
OS << " style = filled;\n";
|
|
|
|
OS << " color = lightgrey;\n";
|
2019-02-26 07:38:21 +00:00
|
|
|
OS << " label = \"" << sys::path::filename(ModIt.first) << "\";\n";
|
2018-01-22 13:35:40 +00:00
|
|
|
OS << " node [style=filled,fillcolor=lightblue];\n";
|
|
|
|
|
|
|
|
auto &GVSMap = ModIt.second;
|
|
|
|
auto Draw = [&](GlobalValue::GUID IdFrom, GlobalValue::GUID IdTo, int Hotness) {
|
|
|
|
if (!GVSMap.count(IdTo)) {
|
|
|
|
CrossModuleEdges.push_back({ModId, Hotness, IdFrom, IdTo});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DrawEdge(" ", ModId, IdFrom, ModId, IdTo, Hotness);
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto &SummaryIt : GVSMap) {
|
|
|
|
NodeMap[SummaryIt.first].push_back(ModId);
|
|
|
|
auto Flags = SummaryIt.second->flags();
|
|
|
|
Attributes A;
|
|
|
|
if (isa<FunctionSummary>(SummaryIt.second)) {
|
|
|
|
A.add("shape", "record", "function");
|
|
|
|
} else if (isa<AliasSummary>(SummaryIt.second)) {
|
|
|
|
A.add("style", "dotted,filled", "alias");
|
|
|
|
A.add("shape", "box");
|
|
|
|
} else {
|
|
|
|
A.add("shape", "Mrecord", "variable");
|
2018-11-16 07:08:00 +00:00
|
|
|
if (Flags.Live && hasReadOnlyFlag(SummaryIt.second))
|
|
|
|
A.addComment("immutable");
|
2019-07-05 15:25:05 +00:00
|
|
|
if (Flags.Live && hasWriteOnlyFlag(SummaryIt.second))
|
|
|
|
A.addComment("writeOnly");
|
2020-01-15 16:29:01 +00:00
|
|
|
if (Flags.Live && hasConstantFlag(SummaryIt.second))
|
|
|
|
A.addComment("constant");
|
2018-01-22 13:35:40 +00:00
|
|
|
}
|
[ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligible
Summary:
We hit undefined references building with ThinLTO when one source file
contained explicit instantiations of a template method (weak_odr) but
there were also implicit instantiations in another file (linkonce_odr),
and the latter was the prevailing copy. In this case the symbol was
marked hidden when the prevailing linkonce_odr copy was promoted to
weak_odr. It led to unsats when the resulting shared library was linked
with other code that contained a reference (expecting to be resolved due
to the explicit instantiation).
Add a CanAutoHide flag to the GV summary to allow the thin link to
identify when all copies are eligible for auto-hiding (because they were
all originally linkonce_odr global unnamed addr), and only do the
auto-hide in that case.
Most of the changes here are due to plumbing the new flag through the
bitcode and llvm assembly, and resulting test changes. I augmented the
existing auto-hide test to check for this situation.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, dexonsmith, arphaman, dang, llvm-commits, steven_wu, wmi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59709
llvm-svn: 360466
2019-05-10 20:08:24 +00:00
|
|
|
if (Flags.DSOLocal)
|
|
|
|
A.addComment("dsoLocal");
|
|
|
|
if (Flags.CanAutoHide)
|
|
|
|
A.addComment("canAutoHide");
|
2019-12-18 15:33:15 +00:00
|
|
|
if (GUIDPreservedSymbols.count(SummaryIt.first))
|
|
|
|
A.addComment("preserved");
|
2018-01-22 13:35:40 +00:00
|
|
|
|
|
|
|
auto VI = getValueInfo(SummaryIt.first);
|
|
|
|
A.add("label", getNodeLabel(VI, SummaryIt.second));
|
|
|
|
if (!Flags.Live)
|
|
|
|
A.add("fillcolor", "red", "dead");
|
|
|
|
else if (Flags.NotEligibleToImport)
|
|
|
|
A.add("fillcolor", "yellow", "not eligible to import");
|
|
|
|
|
|
|
|
OS << " " << NodeId(ModId, SummaryIt.first) << " " << A.getAsString()
|
|
|
|
<< "\n";
|
|
|
|
}
|
|
|
|
OS << " // Edges:\n";
|
|
|
|
|
|
|
|
for (auto &SummaryIt : GVSMap) {
|
|
|
|
auto *GVS = SummaryIt.second;
|
|
|
|
for (auto &R : GVS->refs())
|
2019-07-05 15:25:05 +00:00
|
|
|
Draw(SummaryIt.first, R.getGUID(),
|
|
|
|
R.isWriteOnly() ? -1 : (R.isReadOnly() ? -2 : -3));
|
2018-01-22 13:35:40 +00:00
|
|
|
|
|
|
|
if (auto *AS = dyn_cast_or_null<AliasSummary>(SummaryIt.second)) {
|
2019-07-05 15:25:05 +00:00
|
|
|
Draw(SummaryIt.first, AS->getAliaseeGUID(), -4);
|
2018-01-22 13:35:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto *FS = dyn_cast_or_null<FunctionSummary>(SummaryIt.second))
|
|
|
|
for (auto &CGEdge : FS->calls())
|
|
|
|
Draw(SummaryIt.first, CGEdge.first.getGUID(),
|
|
|
|
static_cast<int>(CGEdge.second.Hotness));
|
|
|
|
}
|
|
|
|
OS << " }\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << " // Cross-module edges:\n";
|
|
|
|
for (auto &E : CrossModuleEdges) {
|
|
|
|
auto &ModList = NodeMap[E.Dst];
|
|
|
|
if (ModList.empty()) {
|
[LTO] Fix a crash caused by accessing an empty ValueInfo
ModuleSummaryIndex::exportToDot crashes when linking the Linux kernel
under ThinLTO using LLVMgold.so. This is due to the exportToDot
function trying to get the GUID of an empty ValueInfo. The root cause
related to the fact that we attempt to get the GUID of an aliasee
via its OriginalGUID recorded in the aliasee summary, and that is not
always possible. Specifically, we cannot do this mapping when the value
is internal linkage and there were other internal linkage symbols with
the same name.
There are 2 fixes for the problem included here.
1) In all cases where we can currently print the dot file from the
command line (which is only via save-temps), we have a valid AliaseeGUID
in the AliasSummary. Use that when it is available, so that we can get
the correct aliasee GUID whenever possible.
2) However, if we were to invoke exportToDot from the debugger right
after it is built during the initial analysis step (i.e. the per-module
summary), we won't have the AliaseeGUID field populated. In that case,
we have a fallback fix that will simply print "@"+GUID when we aren't
able to get the GUID from the OriginalGUID. It simply checks if the VI
is valid or not before attempting to get the name. Additionally, since
getAliaseeGUID will assert that the AliaseeGUID is non-zero, guard the
earlier fix #1 by a new function hasAliaseeGUID().
Reviewers: pcc, tmroeder
Subscribers: evgeny777, mehdi_amini, inglorion, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D53986
llvm-svn: 346055
2018-11-02 23:49:21 +00:00
|
|
|
defineExternalNode(OS, " ", getValueInfo(E.Dst), E.Dst);
|
2018-01-22 13:35:40 +00:00
|
|
|
// Add fake module to the list to draw an edge to an external node
|
|
|
|
// in the loop below.
|
|
|
|
ModList.push_back(-1);
|
|
|
|
}
|
|
|
|
for (auto DstMod : ModList)
|
|
|
|
// The edge representing call or ref is drawn to every module where target
|
|
|
|
// symbol is defined. When target is a linkonce symbol there can be
|
|
|
|
// multiple edges representing a single call or ref, both intra-module and
|
|
|
|
// cross-module. As we've already drawn all intra-module edges before we
|
|
|
|
// skip it here.
|
|
|
|
if (DstMod != E.SrcMod)
|
|
|
|
DrawEdge(" ", E.SrcMod, E.Src, DstMod, E.Dst, E.Hotness);
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << "}";
|
|
|
|
}
|