LLVM  14.0.0git
ModuleSummaryIndex.cpp
Go to the documentation of this file.
1 //===-- ModuleSummaryIndex.cpp - Module Summary Index ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the module index and summary classes for the
10 // IR library.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/SCCIterator.h"
16 #include "llvm/ADT/Statistic.h"
17 #include "llvm/ADT/StringMap.h"
19 #include "llvm/Support/Path.h"
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "module-summary-index"
24 
25 STATISTIC(ReadOnlyLiveGVars,
26  "Number of live global variables marked read only");
27 STATISTIC(WriteOnlyLiveGVars,
28  "Number of live global variables marked write only");
29 
30 static cl::opt<bool> PropagateAttrs("propagate-attrs", cl::init(true),
31  cl::Hidden,
32  cl::desc("Propagate attributes in index"));
33 
35  "import-constants-with-refs", cl::init(true), cl::Hidden,
36  cl::desc("Import constant global variables with references"));
37 
39 
42 
44  bool HasProtected = false;
45  for (const auto &S : make_pointee_range(getSummaryList())) {
46  if (S.getVisibility() == GlobalValue::HiddenVisibility)
48  if (S.getVisibility() == GlobalValue::ProtectedVisibility)
49  HasProtected = true;
50  }
51  return HasProtected ? GlobalValue::ProtectedVisibility
53 }
54 
55 bool ValueInfo::isDSOLocal(bool WithDSOLocalPropagation) const {
56  // With DSOLocal propagation done, the flag in evey summary is the same.
57  // Check the first one is enough.
58  return WithDSOLocalPropagation
59  ? getSummaryList().size() && getSummaryList()[0]->isDSOLocal()
60  : getSummaryList().size() &&
63  [](const std::unique_ptr<GlobalValueSummary> &Summary) {
64  return Summary->isDSOLocal();
65  });
66 }
67 
68 bool ValueInfo::canAutoHide() const {
69  // Can only auto hide if all copies are eligible to auto hide.
70  return getSummaryList().size() &&
72  [](const std::unique_ptr<GlobalValueSummary> &Summary) {
73  return Summary->canAutoHide();
74  });
75 }
76 
77 // Gets the number of readonly and writeonly refs in RefEdgeList
78 std::pair<unsigned, unsigned> FunctionSummary::specialRefCounts() const {
79  // Here we take advantage of having all readonly and writeonly references
80  // located in the end of the RefEdgeList.
81  auto Refs = refs();
82  unsigned RORefCnt = 0, WORefCnt = 0;
83  int I;
84  for (I = Refs.size() - 1; I >= 0 && Refs[I].isWriteOnly(); --I)
85  WORefCnt++;
86  for (; I >= 0 && Refs[I].isReadOnly(); --I)
87  RORefCnt++;
88  return {RORefCnt, WORefCnt};
89 }
90 
92 
94  uint64_t Flags = 0;
96  Flags |= 0x1;
98  Flags |= 0x2;
100  Flags |= 0x4;
101  if (enableSplitLTOUnit())
102  Flags |= 0x8;
104  Flags |= 0x10;
106  Flags |= 0x20;
108  Flags |= 0x40;
109  return Flags;
110 }
111 
113  assert(Flags <= 0x7f && "Unexpected bits in flag");
114  // 1 bit: WithGlobalValueDeadStripping flag.
115  // Set on combined index only.
116  if (Flags & 0x1)
118  // 1 bit: SkipModuleByDistributedBackend flag.
119  // Set on combined index only.
120  if (Flags & 0x2)
122  // 1 bit: HasSyntheticEntryCounts flag.
123  // Set on combined index only.
124  if (Flags & 0x4)
126  // 1 bit: DisableSplitLTOUnit flag.
127  // Set on per module indexes. It is up to the client to validate
128  // the consistency of this flag across modules being linked.
129  if (Flags & 0x8)
131  // 1 bit: PartiallySplitLTOUnits flag.
132  // Set on combined index only.
133  if (Flags & 0x10)
135  // 1 bit: WithAttributePropagation flag.
136  // Set on combined index only.
137  if (Flags & 0x20)
139  // 1 bit: WithDSOLocalPropagation flag.
140  // Set on combined index only.
141  if (Flags & 0x40)
143 }
144 
145 // Collect for the given module the list of function it defines
146 // (GUID -> Summary).
148  StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
149  for (auto &GlobalList : *this) {
150  auto GUID = GlobalList.first;
151  for (auto &GlobSummary : GlobalList.second.SummaryList) {
152  auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobSummary.get());
153  if (!Summary)
154  // Ignore global variable, focus on functions
155  continue;
156  // Ignore summaries from other modules.
157  if (Summary->modulePath() != ModulePath)
158  continue;
159  GVSummaryMap[GUID] = Summary;
160  }
161  }
162 }
163 
166  bool PerModuleIndex) const {
167  auto VI = getValueInfo(ValueGUID);
168  assert(VI && "GlobalValue not found in index");
169  assert((!PerModuleIndex || VI.getSummaryList().size() == 1) &&
170  "Expected a single entry per global value in per-module index");
171  auto &Summary = VI.getSummaryList()[0];
172  return Summary.get();
173 }
174 
176  auto VI = getValueInfo(GUID);
177  if (!VI)
178  return true;
179  const auto &SummaryList = VI.getSummaryList();
180  if (SummaryList.empty())
181  return true;
182  for (auto &I : SummaryList)
183  if (isGlobalValueLive(I.get()))
184  return true;
185  return false;
186 }
187 
188 static void
190  DenseSet<ValueInfo> &MarkedNonReadWriteOnly) {
191  // If reference is not readonly or writeonly then referenced summary is not
192  // read/writeonly either. Note that:
193  // - All references from GlobalVarSummary are conservatively considered as
194  // not readonly or writeonly. Tracking them properly requires more complex
195  // analysis then we have now.
196  //
197  // - AliasSummary objects have no refs at all so this function is a no-op
198  // for them.
199  for (auto &VI : S->refs()) {
200  assert(VI.getAccessSpecifier() == 0 || isa<FunctionSummary>(S));
201  if (!VI.getAccessSpecifier()) {
202  if (!MarkedNonReadWriteOnly.insert(VI).second)
203  continue;
204  } else if (MarkedNonReadWriteOnly.contains(VI))
205  continue;
206  for (auto &Ref : VI.getSummaryList())
207  // If references to alias is not read/writeonly then aliasee
208  // is not read/writeonly
209  if (auto *GVS = dyn_cast<GlobalVarSummary>(Ref->getBaseObject())) {
210  if (!VI.isReadOnly())
211  GVS->setReadOnly(false);
212  if (!VI.isWriteOnly())
213  GVS->setWriteOnly(false);
214  }
215  }
216 }
217 
218 // Do the access attribute and DSOLocal propagation in combined index.
219 // The goal of attribute propagation is internalization of readonly (RO)
220 // or writeonly (WO) variables. To determine which variables are RO or WO
221 // and which are not we take following steps:
222 // - During analysis we speculatively assign readonly and writeonly
223 // attribute to all variables which can be internalized. When computing
224 // function summary we also assign readonly or writeonly attribute to a
225 // reference if function doesn't modify referenced variable (readonly)
226 // or doesn't read it (writeonly).
227 //
228 // - After computing dead symbols in combined index we do the attribute
229 // and DSOLocal propagation. During this step we:
230 // a. clear RO and WO attributes from variables which are preserved or
231 // can't be imported
232 // b. clear RO and WO attributes from variables referenced by any global
233 // variable initializer
234 // c. clear RO attribute from variable referenced by a function when
235 // reference is not readonly
236 // d. clear WO attribute from variable referenced by a function when
237 // reference is not writeonly
238 // e. clear IsDSOLocal flag in every summary if any of them is false.
239 //
240 // Because of (c, d) we don't internalize variables read by function A
241 // and modified by function B.
242 //
243 // Internalization itself happens in the backend after import is finished
244 // See internalizeGVsAfterImport.
246  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
247  if (!PropagateAttrs)
248  return;
249  DenseSet<ValueInfo> MarkedNonReadWriteOnly;
250  for (auto &P : *this) {
251  bool IsDSOLocal = true;
252  for (auto &S : P.second.SummaryList) {
253  if (!isGlobalValueLive(S.get())) {
254  // computeDeadSymbolsAndUpdateIndirectCalls should have marked all
255  // copies live. Note that it is possible that there is a GUID collision
256  // between internal symbols with the same name in different files of the
257  // same name but not enough distinguishing path. Because
258  // computeDeadSymbolsAndUpdateIndirectCalls should conservatively mark
259  // all copies live we can assert here that all are dead if any copy is
260  // dead.
262  P.second.SummaryList,
263  [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
264  return isGlobalValueLive(Summary.get());
265  }));
266  // We don't examine references from dead objects
267  break;
268  }
269 
270  // Global variable can't be marked read/writeonly if it is not eligible
271  // to import since we need to ensure that all external references get
272  // a local (imported) copy. It also can't be marked read/writeonly if
273  // it or any alias (since alias points to the same memory) are preserved
274  // or notEligibleToImport, since either of those means there could be
275  // writes (or reads in case of writeonly) that are not visible (because
276  // preserved means it could have external to DSO writes or reads, and
277  // notEligibleToImport means it could have writes or reads via inline
278  // assembly leading it to be in the @llvm.*used).
279  if (auto *GVS = dyn_cast<GlobalVarSummary>(S->getBaseObject()))
280  // Here we intentionally pass S.get() not GVS, because S could be
281  // an alias. We don't analyze references here, because we have to
282  // know exactly if GV is readonly to do so.
283  if (!canImportGlobalVar(S.get(), /* AnalyzeRefs */ false) ||
284  GUIDPreservedSymbols.count(P.first)) {
285  GVS->setReadOnly(false);
286  GVS->setWriteOnly(false);
287  }
288  propagateAttributesToRefs(S.get(), MarkedNonReadWriteOnly);
289 
290  // If the flag from any summary is false, the GV is not DSOLocal.
291  IsDSOLocal &= S->isDSOLocal();
292  }
293  if (!IsDSOLocal)
294  // Mark the flag in all summaries false so that we can do quick check
295  // without going through the whole list.
296  for (const std::unique_ptr<GlobalValueSummary> &Summary :
297  P.second.SummaryList)
298  Summary->setDSOLocal(false);
299  }
303  for (auto &P : *this)
304  if (P.second.SummaryList.size())
305  if (auto *GVS = dyn_cast<GlobalVarSummary>(
306  P.second.SummaryList[0]->getBaseObject()))
307  if (isGlobalValueLive(GVS)) {
308  if (GVS->maybeReadOnly())
309  ReadOnlyLiveGVars++;
310  if (GVS->maybeWriteOnly())
311  WriteOnlyLiveGVars++;
312  }
313 }
314 
316  bool AnalyzeRefs) const {
317  auto HasRefsPreventingImport = [this](const GlobalVarSummary *GVS) {
318  // We don't analyze GV references during attribute propagation, so
319  // GV with non-trivial initializer can be marked either read or
320  // write-only.
321  // Importing definiton of readonly GV with non-trivial initializer
322  // allows us doing some extra optimizations (like converting indirect
323  // calls to direct).
324  // Definition of writeonly GV with non-trivial initializer should also
325  // be imported. Not doing so will result in:
326  // a) GV internalization in source module (because it's writeonly)
327  // b) Importing of GV declaration to destination module as a result
328  // of promotion.
329  // c) Link error (external declaration with internal definition).
330  // However we do not promote objects referenced by writeonly GV
331  // initializer by means of converting it to 'zeroinitializer'
332  return !(ImportConstantsWithRefs && GVS->isConstant()) &&
333  !isReadOnly(GVS) && !isWriteOnly(GVS) && GVS->refs().size();
334  };
335  auto *GVS = cast<GlobalVarSummary>(S->getBaseObject());
336 
337  // Global variable with non-trivial initializer can be imported
338  // if it's readonly. This gives us extra opportunities for constant
339  // folding and converting indirect calls to direct calls. We don't
340  // analyze GV references during attribute propagation, because we
341  // don't know yet if it is readonly or not.
342  return !GlobalValue::isInterposableLinkage(S->linkage()) &&
343  !S->notEligibleToImport() &&
344  (!AnalyzeRefs || !HasRefsPreventingImport(GVS));
345 }
346 
347 // TODO: write a graphviz dumper for SCCs (see ModuleSummaryIndex::exportToDot)
348 // then delete this function and update its tests
352  scc_begin<ModuleSummaryIndex *>(this);
353  !I.isAtEnd(); ++I) {
354  O << "SCC (" << utostr(I->size()) << " node" << (I->size() == 1 ? "" : "s")
355  << ") {\n";
356  for (const ValueInfo &V : *I) {
357  FunctionSummary *F = nullptr;
358  if (V.getSummaryList().size())
359  F = cast<FunctionSummary>(V.getSummaryList().front().get());
360  O << " " << (F == nullptr ? "External" : "") << " " << utostr(V.getGUID())
361  << (I.hasCycle() ? " (has cycle)" : "") << "\n";
362  }
363  O << "}\n";
364  }
365 }
366 
367 namespace {
368 struct Attributes {
369  void add(const Twine &Name, const Twine &Value,
370  const Twine &Comment = Twine());
371  void addComment(const Twine &Comment);
372  std::string getAsString() const;
373 
374  std::vector<std::string> Attrs;
375  std::string Comments;
376 };
377 
378 struct Edge {
379  uint64_t SrcMod;
380  int Hotness;
381  GlobalValue::GUID Src;
382  GlobalValue::GUID Dst;
383 };
384 }
385 
386 void Attributes::add(const Twine &Name, const Twine &Value,
387  const Twine &Comment) {
388  std::string A = Name.str();
389  A += "=\"";
390  A += Value.str();
391  A += "\"";
392  Attrs.push_back(A);
393  addComment(Comment);
394 }
395 
396 void Attributes::addComment(const Twine &Comment) {
397  if (!Comment.isTriviallyEmpty()) {
398  if (Comments.empty())
399  Comments = " // ";
400  else
401  Comments += ", ";
402  Comments += Comment.str();
403  }
404 }
405 
406 std::string Attributes::getAsString() const {
407  if (Attrs.empty())
408  return "";
409 
410  std::string Ret = "[";
411  for (auto &A : Attrs)
412  Ret += A + ",";
413  Ret.pop_back();
414  Ret += "];";
415  Ret += Comments;
416  return Ret;
417 }
418 
420  switch (LT) {
422  return "extern";
424  return "av_ext";
426  return "linkonce";
428  return "linkonce_odr";
430  return "weak";
432  return "weak_odr";
434  return "appending";
436  return "internal";
438  return "private";
440  return "extern_weak";
442  return "common";
443  }
444 
445  return "<unknown>";
446 }
447 
449  auto FlagValue = [](unsigned V) { return V ? '1' : '0'; };
450  char FlagRep[] = {FlagValue(F.ReadNone),
451  FlagValue(F.ReadOnly),
452  FlagValue(F.NoRecurse),
453  FlagValue(F.ReturnDoesNotAlias),
454  FlagValue(F.NoInline),
455  FlagValue(F.AlwaysInline),
456  FlagValue(F.NoUnwind),
457  FlagValue(F.MayThrow),
458  FlagValue(F.HasUnknownCall),
459  FlagValue(F.MustBeUnreachable),
460  0};
461 
462  return FlagRep;
463 }
464 
465 // Get string representation of function instruction count and flags.
466 static std::string getSummaryAttributes(GlobalValueSummary* GVS) {
467  auto *FS = dyn_cast_or_null<FunctionSummary>(GVS);
468  if (!FS)
469  return "";
470 
471  return std::string("inst: ") + std::to_string(FS->instCount()) +
472  ", ffl: " + fflagsToString(FS->fflags());
473 }
474 
476  return std::string("@") + std::to_string(Id);
477 }
478 
479 static std::string getNodeVisualName(const ValueInfo &VI) {
480  return VI.name().empty() ? getNodeVisualName(VI.getGUID()) : VI.name().str();
481 }
482 
483 static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS) {
484  if (isa<AliasSummary>(GVS))
485  return getNodeVisualName(VI);
486 
487  std::string Attrs = getSummaryAttributes(GVS);
488  std::string Label =
489  getNodeVisualName(VI) + "|" + linkageToString(GVS->linkage());
490  if (!Attrs.empty())
491  Label += std::string(" (") + Attrs + ")";
492  Label += "}";
493 
494  return Label;
495 }
496 
497 // Write definition of external node, which doesn't have any
498 // specific module associated with it. Typically this is function
499 // or variable defined in native object or library.
500 static void defineExternalNode(raw_ostream &OS, const char *Pfx,
501  const ValueInfo &VI, GlobalValue::GUID Id) {
502  auto StrId = std::to_string(Id);
503  OS << " " << StrId << " [label=\"";
504 
505  if (VI) {
506  OS << getNodeVisualName(VI);
507  } else {
508  OS << getNodeVisualName(Id);
509  }
510  OS << "\"]; // defined externally\n";
511 }
512 
513 static bool hasReadOnlyFlag(const GlobalValueSummary *S) {
514  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
515  return GVS->maybeReadOnly();
516  return false;
517 }
518 
519 static bool hasWriteOnlyFlag(const GlobalValueSummary *S) {
520  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
521  return GVS->maybeWriteOnly();
522  return false;
523 }
524 
525 static bool hasConstantFlag(const GlobalValueSummary *S) {
526  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
527  return GVS->isConstant();
528  return false;
529 }
530 
532  raw_ostream &OS,
533  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const {
534  std::vector<Edge> CrossModuleEdges;
536  using GVSOrderedMapTy = std::map<GlobalValue::GUID, GlobalValueSummary *>;
537  std::map<StringRef, GVSOrderedMapTy> ModuleToDefinedGVS;
538  collectDefinedGVSummariesPerModule(ModuleToDefinedGVS);
539 
540  // Get node identifier in form MXXX_<GUID>. The MXXX prefix is required,
541  // because we may have multiple linkonce functions summaries.
542  auto NodeId = [](uint64_t ModId, GlobalValue::GUID Id) {
543  return ModId == (uint64_t)-1 ? std::to_string(Id)
544  : std::string("M") + std::to_string(ModId) +
545  "_" + std::to_string(Id);
546  };
547 
548  auto DrawEdge = [&](const char *Pfx, uint64_t SrcMod, GlobalValue::GUID SrcId,
549  uint64_t DstMod, GlobalValue::GUID DstId,
550  int TypeOrHotness) {
551  // 0 - alias
552  // 1 - reference
553  // 2 - constant reference
554  // 3 - writeonly reference
555  // Other value: (hotness - 4).
556  TypeOrHotness += 4;
557  static const char *EdgeAttrs[] = {
558  " [style=dotted]; // alias",
559  " [style=dashed]; // ref",
560  " [style=dashed,color=forestgreen]; // const-ref",
561  " [style=dashed,color=violetred]; // writeOnly-ref",
562  " // call (hotness : Unknown)",
563  " [color=blue]; // call (hotness : Cold)",
564  " // call (hotness : None)",
565  " [color=brown]; // call (hotness : Hot)",
566  " [style=bold,color=red]; // call (hotness : Critical)"};
567 
568  assert(static_cast<size_t>(TypeOrHotness) <
569  sizeof(EdgeAttrs) / sizeof(EdgeAttrs[0]));
570  OS << Pfx << NodeId(SrcMod, SrcId) << " -> " << NodeId(DstMod, DstId)
571  << EdgeAttrs[TypeOrHotness] << "\n";
572  };
573 
574  OS << "digraph Summary {\n";
575  for (auto &ModIt : ModuleToDefinedGVS) {
576  auto ModId = getModuleId(ModIt.first);
577  OS << " // Module: " << ModIt.first << "\n";
578  OS << " subgraph cluster_" << std::to_string(ModId) << " {\n";
579  OS << " style = filled;\n";
580  OS << " color = lightgrey;\n";
581  OS << " label = \"" << sys::path::filename(ModIt.first) << "\";\n";
582  OS << " node [style=filled,fillcolor=lightblue];\n";
583 
584  auto &GVSMap = ModIt.second;
585  auto Draw = [&](GlobalValue::GUID IdFrom, GlobalValue::GUID IdTo, int Hotness) {
586  if (!GVSMap.count(IdTo)) {
587  CrossModuleEdges.push_back({ModId, Hotness, IdFrom, IdTo});
588  return;
589  }
590  DrawEdge(" ", ModId, IdFrom, ModId, IdTo, Hotness);
591  };
592 
593  for (auto &SummaryIt : GVSMap) {
594  NodeMap[SummaryIt.first].push_back(ModId);
595  auto Flags = SummaryIt.second->flags();
596  Attributes A;
597  if (isa<FunctionSummary>(SummaryIt.second)) {
598  A.add("shape", "record", "function");
599  } else if (isa<AliasSummary>(SummaryIt.second)) {
600  A.add("style", "dotted,filled", "alias");
601  A.add("shape", "box");
602  } else {
603  A.add("shape", "Mrecord", "variable");
604  if (Flags.Live && hasReadOnlyFlag(SummaryIt.second))
605  A.addComment("immutable");
606  if (Flags.Live && hasWriteOnlyFlag(SummaryIt.second))
607  A.addComment("writeOnly");
608  if (Flags.Live && hasConstantFlag(SummaryIt.second))
609  A.addComment("constant");
610  }
611  if (Flags.Visibility)
612  A.addComment("visibility");
613  if (Flags.DSOLocal)
614  A.addComment("dsoLocal");
615  if (Flags.CanAutoHide)
616  A.addComment("canAutoHide");
617  if (GUIDPreservedSymbols.count(SummaryIt.first))
618  A.addComment("preserved");
619 
620  auto VI = getValueInfo(SummaryIt.first);
621  A.add("label", getNodeLabel(VI, SummaryIt.second));
622  if (!Flags.Live)
623  A.add("fillcolor", "red", "dead");
624  else if (Flags.NotEligibleToImport)
625  A.add("fillcolor", "yellow", "not eligible to import");
626 
627  OS << " " << NodeId(ModId, SummaryIt.first) << " " << A.getAsString()
628  << "\n";
629  }
630  OS << " // Edges:\n";
631 
632  for (auto &SummaryIt : GVSMap) {
633  auto *GVS = SummaryIt.second;
634  for (auto &R : GVS->refs())
635  Draw(SummaryIt.first, R.getGUID(),
636  R.isWriteOnly() ? -1 : (R.isReadOnly() ? -2 : -3));
637 
638  if (auto *AS = dyn_cast_or_null<AliasSummary>(SummaryIt.second)) {
639  Draw(SummaryIt.first, AS->getAliaseeGUID(), -4);
640  continue;
641  }
642 
643  if (auto *FS = dyn_cast_or_null<FunctionSummary>(SummaryIt.second))
644  for (auto &CGEdge : FS->calls())
645  Draw(SummaryIt.first, CGEdge.first.getGUID(),
646  static_cast<int>(CGEdge.second.Hotness));
647  }
648  OS << " }\n";
649  }
650 
651  OS << " // Cross-module edges:\n";
652  for (auto &E : CrossModuleEdges) {
653  auto &ModList = NodeMap[E.Dst];
654  if (ModList.empty()) {
655  defineExternalNode(OS, " ", getValueInfo(E.Dst), E.Dst);
656  // Add fake module to the list to draw an edge to an external node
657  // in the loop below.
658  ModList.push_back(-1);
659  }
660  for (auto DstMod : ModList)
661  // The edge representing call or ref is drawn to every module where target
662  // symbol is defined. When target is a linkonce symbol there can be
663  // multiple edges representing a single call or ref, both intra-module and
664  // cross-module. As we've already drawn all intra-module edges before we
665  // skip it here.
666  if (DstMod != E.SrcMod)
667  DrawEdge(" ", E.SrcMod, E.Src, DstMod, E.Dst, E.Hotness);
668  }
669 
670  OS << "}";
671 }
llvm::GlobalValue::GUID
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:509
llvm::ValueInfo::getSummaryList
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
Definition: ModuleSummaryIndex.h:187
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::ModuleSummaryIndex::hasSyntheticEntryCounts
bool hasSyntheticEntryCounts() const
Definition: ModuleSummaryIndex.h:1291
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:510
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::none_of
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1663
llvm::GlobalValue::LinkOnceAnyLinkage
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:50
llvm::ModuleSummaryIndex::setPartiallySplitLTOUnits
void setPartiallySplitLTOUnits()
Definition: ModuleSummaryIndex.h:1305
llvm::ModuleSummaryIndex::isReadOnly
bool isReadOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1284
SCCIterator.h
llvm::Function::empty
bool empty() const
Definition: Function.h:729
llvm::ModuleSummaryIndex::setEnableSplitLTOUnit
void setEnableSplitLTOUnit()
Definition: ModuleSummaryIndex.h:1302
llvm::GlobalValue::HiddenVisibility
@ HiddenVisibility
The GV is hidden.
Definition: GlobalValue.h:64
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::GlobalVarSummary
Global variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:894
Statistic.h
Path.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::Twine::isTriviallyEmpty
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
Definition: Twine.h:421
PropagateAttrs
static cl::opt< bool > PropagateAttrs("propagate-attrs", cl::init(true), cl::Hidden, cl::desc("Propagate attributes in index"))
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition: GlobalValue.h:63
llvm::ModuleSummaryIndex::isGlobalValueLive
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
Definition: ModuleSummaryIndex.h:1309
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::ModuleSummaryIndex::propagateAttributes
void propagateAttributes(const DenseSet< GlobalValue::GUID > &PreservedSymbols)
Do the access attribute and DSOLocal propagation in combined index.
Definition: ModuleSummaryIndex.cpp:245
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::count
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:97
llvm::ModuleSummaryIndex::getModuleId
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
Definition: ModuleSummaryIndex.h:1449
ModuleSummaryIndex.h
llvm::ValueInfo::isDSOLocal
bool isDSOLocal(bool WithDSOLocalPropagation=false) const
Checks if all summaries are DSO local (have the flag set).
Definition: ModuleSummaryIndex.cpp:55
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::GlobalValueSummary::refs
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
Definition: ModuleSummaryIndex.h:438
getSummaryAttributes
static std::string getSummaryAttributes(GlobalValueSummary *GVS)
Definition: ModuleSummaryIndex.cpp:466
llvm::ModuleSummaryIndex::withDSOLocalPropagation
bool withDSOLocalPropagation() const
Definition: ModuleSummaryIndex.h:1281
llvm::AArch64CC::LT
@ LT
Definition: AArch64BaseInfo.h:266
CommandLine.h
llvm::ModuleSummaryIndex::setWithAttributePropagation
void setWithAttributePropagation()
Definition: ModuleSummaryIndex.h:1277
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:290
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1649
hasReadOnlyFlag
static bool hasReadOnlyFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:513
llvm::AreStatisticsEnabled
bool AreStatisticsEnabled()
Check if statistics are enabled.
Definition: Statistic.cpp:138
llvm::GlobalValue::VisibilityTypes
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:62
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ModuleSummaryIndex::enableSplitLTOUnit
bool enableSplitLTOUnit() const
Definition: ModuleSummaryIndex.h:1301
fflagsToString
static std::string fflagsToString(FunctionSummary::FFlags F)
Definition: ModuleSummaryIndex.cpp:448
llvm::ARM_PROC::A
@ A
Definition: ARMBaseInfo.h:34
llvm::rdf::NodeId
uint32_t NodeId
Definition: RDFGraph.h:260
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::ModuleSummaryIndex::getFlags
uint64_t getFlags() const
Definition: ModuleSummaryIndex.cpp:93
StringMap.h
llvm::ModuleSummaryIndex::withGlobalValueDeadStripping
bool withGlobalValueDeadStripping() const
Definition: ModuleSummaryIndex.h:1269
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::ValueInfo::getELFVisibility
GlobalValue::VisibilityTypes getELFVisibility() const
Returns the most constraining visibility among summaries.
Definition: ModuleSummaryIndex.cpp:43
llvm::ModuleSummaryIndex::setHasSyntheticEntryCounts
void setHasSyntheticEntryCounts()
Definition: ModuleSummaryIndex.h:1292
hasConstantFlag
static bool hasConstantFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:525
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:168
llvm::ValueInfo::canAutoHide
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
Definition: ModuleSummaryIndex.cpp:68
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::Twine::str
std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::ModuleSummaryIndex::isGUIDLive
bool isGUIDLive(GlobalValue::GUID GUID) const
Definition: ModuleSummaryIndex.cpp:175
llvm::cl::opt< bool >
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
x2
gcc mainline compiles it x2(%rip)
VI
@ VI
Definition: SIInstrInfo.cpp:7685
llvm::GlobalValueSummary::linkage
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
Definition: ModuleSummaryIndex.h:402
uint64_t
llvm::ModuleSummaryIndex::dumpSCCs
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
Definition: ModuleSummaryIndex.cpp:350
llvm::scc_iterator
Enumerate the SCCs of a directed graph in reverse topological order of the SCC DAG.
Definition: SCCIterator.h:46
llvm::ARM_AM::add
@ add
Definition: ARMAddressingModes.h:39
llvm::GlobalValue::WeakAnyLinkage
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:52
llvm::ModuleSummaryIndex::getValueInfo
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
Definition: ModuleSummaryIndex.h:1316
hasWriteOnlyFlag
static bool hasWriteOnlyFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:519
llvm::DenseMap
Definition: DenseMap.h:714
I
#define I(x, y, z)
Definition: MD5.cpp:58
Attributes
AMDGPU Kernel Attributes
Definition: AMDGPULowerKernelAttributes.cpp:254
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:441
llvm::ModuleSummaryIndex::skipModuleByDistributedBackend
bool skipModuleByDistributedBackend() const
Definition: ModuleSummaryIndex.h:1294
llvm::FunctionSummary::makeDummyFunctionSummary
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
Definition: ModuleSummaryIndex.h:668
llvm::make_pointee_range
iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)
Definition: iterator.h:336
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ModuleSummaryIndex::setWithDSOLocalPropagation
void setWithDSOLocalPropagation()
Definition: ModuleSummaryIndex.h:1282
llvm::FunctionSummary::FFlags
Flags specific to function summaries.
Definition: ModuleSummaryIndex.h:563
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
llvm::ModuleSummaryIndex::partiallySplitLTOUnits
bool partiallySplitLTOUnits() const
Definition: ModuleSummaryIndex.h:1304
llvm::ModuleSummaryIndex::exportToDot
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
Definition: ModuleSummaryIndex.cpp:531
llvm::ModuleSummaryIndex::setFlags
void setFlags(uint64_t Flags)
Definition: ModuleSummaryIndex.cpp:112
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
ImportConstantsWithRefs
static cl::opt< bool > ImportConstantsWithRefs("import-constants-with-refs", cl::init(true), cl::Hidden, cl::desc("Import constant global variables with references"))
llvm::GlobalValue::WeakODRLinkage
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:53
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::contains
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
Definition: DenseSet.h:185
uint32_t
llvm::ModuleSummaryIndex::collectDefinedGVSummariesPerModule
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
Definition: ModuleSummaryIndex.h:1564
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:49
llvm::GlobalValue::CommonLinkage
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:58
defineExternalNode
static void defineExternalNode(raw_ostream &OS, const char *Pfx, const ValueInfo &VI, GlobalValue::GUID Id)
Definition: ModuleSummaryIndex.cpp:500
llvm::ModuleSummaryIndex::canImportGlobalVar
bool canImportGlobalVar(GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
Definition: ModuleSummaryIndex.cpp:315
llvm::FunctionSummary::ExternalNode
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
Definition: ModuleSummaryIndex.h:686
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::FunctionSummary
Function summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:513
llvm::ModuleSummaryIndex::setWithGlobalValueDeadStripping
void setWithGlobalValueDeadStripping()
Definition: ModuleSummaryIndex.h:1272
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::GlobalValue::isInterposableLinkage
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
Definition: GlobalValue.h:348
llvm::FunctionSummary::ParamAccess::RangeWidth
static constexpr uint32_t RangeWidth
Definition: ModuleSummaryIndex.h:633
linkageToString
static std::string linkageToString(GlobalValue::LinkageTypes LT)
Definition: ModuleSummaryIndex.cpp:419
llvm::ModuleSummaryIndex::getGlobalValueSummary
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
Definition: ModuleSummaryIndex.h:1426
llvm::GlobalValue::ProtectedVisibility
@ ProtectedVisibility
The GV is protected.
Definition: GlobalValue.h:65
llvm::FunctionSummary::specialRefCounts
std::pair< unsigned, unsigned > specialRefCounts() const
Definition: ModuleSummaryIndex.cpp:78
llvm::ModuleSummaryIndex::BitcodeSummaryVersion
static constexpr uint64_t BitcodeSummaryVersion
Definition: ModuleSummaryIndex.h:1184
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::ModuleSummaryIndex::isWriteOnly
bool isWriteOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1287
llvm::ModuleSummaryIndex::setSkipModuleByDistributedBackend
void setSkipModuleByDistributedBackend()
Definition: ModuleSummaryIndex.h:1297
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::sys::path::filename
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:578
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:87
getNodeLabel
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
Definition: ModuleSummaryIndex.cpp:483
getNodeVisualName
static std::string getNodeVisualName(GlobalValue::GUID Id)
Definition: ModuleSummaryIndex.cpp:475
llvm::ModuleSummaryIndex::collectDefinedFunctionsForModule
void collectDefinedFunctionsForModule(StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
Collect for the given module the list of functions it defines (GUID -> Summary).
Definition: ModuleSummaryIndex.cpp:147
llvm::ModuleSummaryIndex::withAttributePropagation
bool withAttributePropagation() const
Definition: ModuleSummaryIndex.h:1276
propagateAttributesToRefs
static void propagateAttributesToRefs(GlobalValueSummary *S, DenseSet< ValueInfo > &MarkedNonReadWriteOnly)
Definition: ModuleSummaryIndex.cpp:189
llvm::cl::desc
Definition: CommandLine.h:412
llvm::GlobalValue::ExternalWeakLinkage
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition: GlobalValue.h:57
raw_ostream.h
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:232
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
llvm::Value
LLVM Value Representation.
Definition: Value.h:74