LLVM  16.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"
18 #include "llvm/Support/Path.h"
20 using namespace llvm;
21 
22 #define DEBUG_TYPE "module-summary-index"
23 
24 STATISTIC(ReadOnlyLiveGVars,
25  "Number of live global variables marked read only");
26 STATISTIC(WriteOnlyLiveGVars,
27  "Number of live global variables marked write only");
28 
29 static cl::opt<bool> PropagateAttrs("propagate-attrs", cl::init(true),
30  cl::Hidden,
31  cl::desc("Propagate attributes in index"));
32 
34  "import-constants-with-refs", cl::init(true), cl::Hidden,
35  cl::desc("Import constant global variables with references"));
36 
38 
41 
43  bool HasProtected = false;
44  for (const auto &S : make_pointee_range(getSummaryList())) {
45  if (S.getVisibility() == GlobalValue::HiddenVisibility)
47  if (S.getVisibility() == GlobalValue::ProtectedVisibility)
48  HasProtected = true;
49  }
50  return HasProtected ? GlobalValue::ProtectedVisibility
52 }
53 
54 bool ValueInfo::isDSOLocal(bool WithDSOLocalPropagation) const {
55  // With DSOLocal propagation done, the flag in evey summary is the same.
56  // Check the first one is enough.
57  return WithDSOLocalPropagation
58  ? getSummaryList().size() && getSummaryList()[0]->isDSOLocal()
59  : getSummaryList().size() &&
62  [](const std::unique_ptr<GlobalValueSummary> &Summary) {
63  return Summary->isDSOLocal();
64  });
65 }
66 
67 bool ValueInfo::canAutoHide() const {
68  // Can only auto hide if all copies are eligible to auto hide.
69  return getSummaryList().size() &&
71  [](const std::unique_ptr<GlobalValueSummary> &Summary) {
72  return Summary->canAutoHide();
73  });
74 }
75 
76 // Gets the number of readonly and writeonly refs in RefEdgeList
77 std::pair<unsigned, unsigned> FunctionSummary::specialRefCounts() const {
78  // Here we take advantage of having all readonly and writeonly references
79  // located in the end of the RefEdgeList.
80  auto Refs = refs();
81  unsigned RORefCnt = 0, WORefCnt = 0;
82  int I;
83  for (I = Refs.size() - 1; I >= 0 && Refs[I].isWriteOnly(); --I)
84  WORefCnt++;
85  for (; I >= 0 && Refs[I].isReadOnly(); --I)
86  RORefCnt++;
87  return {RORefCnt, WORefCnt};
88 }
89 
91 
93  uint64_t Flags = 0;
95  Flags |= 0x1;
97  Flags |= 0x2;
99  Flags |= 0x4;
100  if (enableSplitLTOUnit())
101  Flags |= 0x8;
103  Flags |= 0x10;
105  Flags |= 0x20;
107  Flags |= 0x40;
109  Flags |= 0x80;
110  return Flags;
111 }
112 
114  assert(Flags <= 0xff && "Unexpected bits in flag");
115  // 1 bit: WithGlobalValueDeadStripping flag.
116  // Set on combined index only.
117  if (Flags & 0x1)
119  // 1 bit: SkipModuleByDistributedBackend flag.
120  // Set on combined index only.
121  if (Flags & 0x2)
123  // 1 bit: HasSyntheticEntryCounts flag.
124  // Set on combined index only.
125  if (Flags & 0x4)
127  // 1 bit: DisableSplitLTOUnit flag.
128  // Set on per module indexes. It is up to the client to validate
129  // the consistency of this flag across modules being linked.
130  if (Flags & 0x8)
132  // 1 bit: PartiallySplitLTOUnits flag.
133  // Set on combined index only.
134  if (Flags & 0x10)
136  // 1 bit: WithAttributePropagation flag.
137  // Set on combined index only.
138  if (Flags & 0x20)
140  // 1 bit: WithDSOLocalPropagation flag.
141  // Set on combined index only.
142  if (Flags & 0x40)
144  // 1 bit: WithWholeProgramVisibility flag.
145  // Set on combined index only.
146  if (Flags & 0x80)
148 }
149 
150 // Collect for the given module the list of function it defines
151 // (GUID -> Summary).
153  StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
154  for (auto &GlobalList : *this) {
155  auto GUID = GlobalList.first;
156  for (auto &GlobSummary : GlobalList.second.SummaryList) {
157  auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobSummary.get());
158  if (!Summary)
159  // Ignore global variable, focus on functions
160  continue;
161  // Ignore summaries from other modules.
162  if (Summary->modulePath() != ModulePath)
163  continue;
164  GVSummaryMap[GUID] = Summary;
165  }
166  }
167 }
168 
171  bool PerModuleIndex) const {
172  auto VI = getValueInfo(ValueGUID);
173  assert(VI && "GlobalValue not found in index");
174  assert((!PerModuleIndex || VI.getSummaryList().size() == 1) &&
175  "Expected a single entry per global value in per-module index");
176  auto &Summary = VI.getSummaryList()[0];
177  return Summary.get();
178 }
179 
181  auto VI = getValueInfo(GUID);
182  if (!VI)
183  return true;
184  const auto &SummaryList = VI.getSummaryList();
185  if (SummaryList.empty())
186  return true;
187  for (auto &I : SummaryList)
188  if (isGlobalValueLive(I.get()))
189  return true;
190  return false;
191 }
192 
193 static void
195  DenseSet<ValueInfo> &MarkedNonReadWriteOnly) {
196  // If reference is not readonly or writeonly then referenced summary is not
197  // read/writeonly either. Note that:
198  // - All references from GlobalVarSummary are conservatively considered as
199  // not readonly or writeonly. Tracking them properly requires more complex
200  // analysis then we have now.
201  //
202  // - AliasSummary objects have no refs at all so this function is a no-op
203  // for them.
204  for (auto &VI : S->refs()) {
205  assert(VI.getAccessSpecifier() == 0 || isa<FunctionSummary>(S));
206  if (!VI.getAccessSpecifier()) {
207  if (!MarkedNonReadWriteOnly.insert(VI).second)
208  continue;
209  } else if (MarkedNonReadWriteOnly.contains(VI))
210  continue;
211  for (auto &Ref : VI.getSummaryList())
212  // If references to alias is not read/writeonly then aliasee
213  // is not read/writeonly
214  if (auto *GVS = dyn_cast<GlobalVarSummary>(Ref->getBaseObject())) {
215  if (!VI.isReadOnly())
216  GVS->setReadOnly(false);
217  if (!VI.isWriteOnly())
218  GVS->setWriteOnly(false);
219  }
220  }
221 }
222 
223 // Do the access attribute and DSOLocal propagation in combined index.
224 // The goal of attribute propagation is internalization of readonly (RO)
225 // or writeonly (WO) variables. To determine which variables are RO or WO
226 // and which are not we take following steps:
227 // - During analysis we speculatively assign readonly and writeonly
228 // attribute to all variables which can be internalized. When computing
229 // function summary we also assign readonly or writeonly attribute to a
230 // reference if function doesn't modify referenced variable (readonly)
231 // or doesn't read it (writeonly).
232 //
233 // - After computing dead symbols in combined index we do the attribute
234 // and DSOLocal propagation. During this step we:
235 // a. clear RO and WO attributes from variables which are preserved or
236 // can't be imported
237 // b. clear RO and WO attributes from variables referenced by any global
238 // variable initializer
239 // c. clear RO attribute from variable referenced by a function when
240 // reference is not readonly
241 // d. clear WO attribute from variable referenced by a function when
242 // reference is not writeonly
243 // e. clear IsDSOLocal flag in every summary if any of them is false.
244 //
245 // Because of (c, d) we don't internalize variables read by function A
246 // and modified by function B.
247 //
248 // Internalization itself happens in the backend after import is finished
249 // See internalizeGVsAfterImport.
251  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
252  if (!PropagateAttrs)
253  return;
254  DenseSet<ValueInfo> MarkedNonReadWriteOnly;
255  for (auto &P : *this) {
256  bool IsDSOLocal = true;
257  for (auto &S : P.second.SummaryList) {
258  if (!isGlobalValueLive(S.get())) {
259  // computeDeadSymbolsAndUpdateIndirectCalls should have marked all
260  // copies live. Note that it is possible that there is a GUID collision
261  // between internal symbols with the same name in different files of the
262  // same name but not enough distinguishing path. Because
263  // computeDeadSymbolsAndUpdateIndirectCalls should conservatively mark
264  // all copies live we can assert here that all are dead if any copy is
265  // dead.
267  P.second.SummaryList,
268  [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
269  return isGlobalValueLive(Summary.get());
270  }));
271  // We don't examine references from dead objects
272  break;
273  }
274 
275  // Global variable can't be marked read/writeonly if it is not eligible
276  // to import since we need to ensure that all external references get
277  // a local (imported) copy. It also can't be marked read/writeonly if
278  // it or any alias (since alias points to the same memory) are preserved
279  // or notEligibleToImport, since either of those means there could be
280  // writes (or reads in case of writeonly) that are not visible (because
281  // preserved means it could have external to DSO writes or reads, and
282  // notEligibleToImport means it could have writes or reads via inline
283  // assembly leading it to be in the @llvm.*used).
284  if (auto *GVS = dyn_cast<GlobalVarSummary>(S->getBaseObject()))
285  // Here we intentionally pass S.get() not GVS, because S could be
286  // an alias. We don't analyze references here, because we have to
287  // know exactly if GV is readonly to do so.
288  if (!canImportGlobalVar(S.get(), /* AnalyzeRefs */ false) ||
289  GUIDPreservedSymbols.count(P.first)) {
290  GVS->setReadOnly(false);
291  GVS->setWriteOnly(false);
292  }
293  propagateAttributesToRefs(S.get(), MarkedNonReadWriteOnly);
294 
295  // If the flag from any summary is false, the GV is not DSOLocal.
296  IsDSOLocal &= S->isDSOLocal();
297  }
298  if (!IsDSOLocal)
299  // Mark the flag in all summaries false so that we can do quick check
300  // without going through the whole list.
301  for (const std::unique_ptr<GlobalValueSummary> &Summary :
302  P.second.SummaryList)
303  Summary->setDSOLocal(false);
304  }
308  for (auto &P : *this)
309  if (P.second.SummaryList.size())
310  if (auto *GVS = dyn_cast<GlobalVarSummary>(
311  P.second.SummaryList[0]->getBaseObject()))
312  if (isGlobalValueLive(GVS)) {
313  if (GVS->maybeReadOnly())
314  ReadOnlyLiveGVars++;
315  if (GVS->maybeWriteOnly())
316  WriteOnlyLiveGVars++;
317  }
318 }
319 
321  bool AnalyzeRefs) const {
322  auto HasRefsPreventingImport = [this](const GlobalVarSummary *GVS) {
323  // We don't analyze GV references during attribute propagation, so
324  // GV with non-trivial initializer can be marked either read or
325  // write-only.
326  // Importing definiton of readonly GV with non-trivial initializer
327  // allows us doing some extra optimizations (like converting indirect
328  // calls to direct).
329  // Definition of writeonly GV with non-trivial initializer should also
330  // be imported. Not doing so will result in:
331  // a) GV internalization in source module (because it's writeonly)
332  // b) Importing of GV declaration to destination module as a result
333  // of promotion.
334  // c) Link error (external declaration with internal definition).
335  // However we do not promote objects referenced by writeonly GV
336  // initializer by means of converting it to 'zeroinitializer'
337  return !(ImportConstantsWithRefs && GVS->isConstant()) &&
338  !isReadOnly(GVS) && !isWriteOnly(GVS) && GVS->refs().size();
339  };
340  auto *GVS = cast<GlobalVarSummary>(S->getBaseObject());
341 
342  // Global variable with non-trivial initializer can be imported
343  // if it's readonly. This gives us extra opportunities for constant
344  // folding and converting indirect calls to direct calls. We don't
345  // analyze GV references during attribute propagation, because we
346  // don't know yet if it is readonly or not.
347  return !GlobalValue::isInterposableLinkage(S->linkage()) &&
348  !S->notEligibleToImport() &&
349  (!AnalyzeRefs || !HasRefsPreventingImport(GVS));
350 }
351 
352 // TODO: write a graphviz dumper for SCCs (see ModuleSummaryIndex::exportToDot)
353 // then delete this function and update its tests
357  scc_begin<ModuleSummaryIndex *>(this);
358  !I.isAtEnd(); ++I) {
359  O << "SCC (" << utostr(I->size()) << " node" << (I->size() == 1 ? "" : "s")
360  << ") {\n";
361  for (const ValueInfo &V : *I) {
362  FunctionSummary *F = nullptr;
363  if (V.getSummaryList().size())
364  F = cast<FunctionSummary>(V.getSummaryList().front().get());
365  O << " " << (F == nullptr ? "External" : "") << " " << utostr(V.getGUID())
366  << (I.hasCycle() ? " (has cycle)" : "") << "\n";
367  }
368  O << "}\n";
369  }
370 }
371 
372 namespace {
373 struct Attributes {
374  void add(const Twine &Name, const Twine &Value,
375  const Twine &Comment = Twine());
376  void addComment(const Twine &Comment);
377  std::string getAsString() const;
378 
379  std::vector<std::string> Attrs;
380  std::string Comments;
381 };
382 
383 struct Edge {
384  uint64_t SrcMod;
385  int Hotness;
386  GlobalValue::GUID Src;
387  GlobalValue::GUID Dst;
388 };
389 }
390 
391 void Attributes::add(const Twine &Name, const Twine &Value,
392  const Twine &Comment) {
393  std::string A = Name.str();
394  A += "=\"";
395  A += Value.str();
396  A += "\"";
397  Attrs.push_back(A);
398  addComment(Comment);
399 }
400 
401 void Attributes::addComment(const Twine &Comment) {
402  if (!Comment.isTriviallyEmpty()) {
403  if (Comments.empty())
404  Comments = " // ";
405  else
406  Comments += ", ";
407  Comments += Comment.str();
408  }
409 }
410 
411 std::string Attributes::getAsString() const {
412  if (Attrs.empty())
413  return "";
414 
415  std::string Ret = "[";
416  for (auto &A : Attrs)
417  Ret += A + ",";
418  Ret.pop_back();
419  Ret += "];";
420  Ret += Comments;
421  return Ret;
422 }
423 
425  switch (LT) {
427  return "extern";
429  return "av_ext";
431  return "linkonce";
433  return "linkonce_odr";
435  return "weak";
437  return "weak_odr";
439  return "appending";
441  return "internal";
443  return "private";
445  return "extern_weak";
447  return "common";
448  }
449 
450  return "<unknown>";
451 }
452 
454  auto FlagValue = [](unsigned V) { return V ? '1' : '0'; };
455  char FlagRep[] = {FlagValue(F.ReadNone),
456  FlagValue(F.ReadOnly),
457  FlagValue(F.NoRecurse),
458  FlagValue(F.ReturnDoesNotAlias),
459  FlagValue(F.NoInline),
460  FlagValue(F.AlwaysInline),
461  FlagValue(F.NoUnwind),
462  FlagValue(F.MayThrow),
463  FlagValue(F.HasUnknownCall),
464  FlagValue(F.MustBeUnreachable),
465  0};
466 
467  return FlagRep;
468 }
469 
470 // Get string representation of function instruction count and flags.
471 static std::string getSummaryAttributes(GlobalValueSummary* GVS) {
472  auto *FS = dyn_cast_or_null<FunctionSummary>(GVS);
473  if (!FS)
474  return "";
475 
476  return std::string("inst: ") + std::to_string(FS->instCount()) +
477  ", ffl: " + fflagsToString(FS->fflags());
478 }
479 
481  return std::string("@") + std::to_string(Id);
482 }
483 
484 static std::string getNodeVisualName(const ValueInfo &VI) {
485  return VI.name().empty() ? getNodeVisualName(VI.getGUID()) : VI.name().str();
486 }
487 
488 static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS) {
489  if (isa<AliasSummary>(GVS))
490  return getNodeVisualName(VI);
491 
492  std::string Attrs = getSummaryAttributes(GVS);
493  std::string Label =
494  getNodeVisualName(VI) + "|" + linkageToString(GVS->linkage());
495  if (!Attrs.empty())
496  Label += std::string(" (") + Attrs + ")";
497  Label += "}";
498 
499  return Label;
500 }
501 
502 // Write definition of external node, which doesn't have any
503 // specific module associated with it. Typically this is function
504 // or variable defined in native object or library.
505 static void defineExternalNode(raw_ostream &OS, const char *Pfx,
506  const ValueInfo &VI, GlobalValue::GUID Id) {
507  auto StrId = std::to_string(Id);
508  OS << " " << StrId << " [label=\"";
509 
510  if (VI) {
511  OS << getNodeVisualName(VI);
512  } else {
513  OS << getNodeVisualName(Id);
514  }
515  OS << "\"]; // defined externally\n";
516 }
517 
518 static bool hasReadOnlyFlag(const GlobalValueSummary *S) {
519  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
520  return GVS->maybeReadOnly();
521  return false;
522 }
523 
524 static bool hasWriteOnlyFlag(const GlobalValueSummary *S) {
525  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
526  return GVS->maybeWriteOnly();
527  return false;
528 }
529 
530 static bool hasConstantFlag(const GlobalValueSummary *S) {
531  if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
532  return GVS->isConstant();
533  return false;
534 }
535 
537  raw_ostream &OS,
538  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const {
539  std::vector<Edge> CrossModuleEdges;
541  using GVSOrderedMapTy = std::map<GlobalValue::GUID, GlobalValueSummary *>;
542  std::map<StringRef, GVSOrderedMapTy> ModuleToDefinedGVS;
543  collectDefinedGVSummariesPerModule(ModuleToDefinedGVS);
544 
545  // Get node identifier in form MXXX_<GUID>. The MXXX prefix is required,
546  // because we may have multiple linkonce functions summaries.
547  auto NodeId = [](uint64_t ModId, GlobalValue::GUID Id) {
548  return ModId == (uint64_t)-1 ? std::to_string(Id)
549  : std::string("M") + std::to_string(ModId) +
550  "_" + std::to_string(Id);
551  };
552 
553  auto DrawEdge = [&](const char *Pfx, uint64_t SrcMod, GlobalValue::GUID SrcId,
554  uint64_t DstMod, GlobalValue::GUID DstId,
555  int TypeOrHotness) {
556  // 0 - alias
557  // 1 - reference
558  // 2 - constant reference
559  // 3 - writeonly reference
560  // Other value: (hotness - 4).
561  TypeOrHotness += 4;
562  static const char *EdgeAttrs[] = {
563  " [style=dotted]; // alias",
564  " [style=dashed]; // ref",
565  " [style=dashed,color=forestgreen]; // const-ref",
566  " [style=dashed,color=violetred]; // writeOnly-ref",
567  " // call (hotness : Unknown)",
568  " [color=blue]; // call (hotness : Cold)",
569  " // call (hotness : None)",
570  " [color=brown]; // call (hotness : Hot)",
571  " [style=bold,color=red]; // call (hotness : Critical)"};
572 
573  assert(static_cast<size_t>(TypeOrHotness) < std::size(EdgeAttrs));
574  OS << Pfx << NodeId(SrcMod, SrcId) << " -> " << NodeId(DstMod, DstId)
575  << EdgeAttrs[TypeOrHotness] << "\n";
576  };
577 
578  OS << "digraph Summary {\n";
579  for (auto &ModIt : ModuleToDefinedGVS) {
580  auto ModId = getModuleId(ModIt.first);
581  OS << " // Module: " << ModIt.first << "\n";
582  OS << " subgraph cluster_" << std::to_string(ModId) << " {\n";
583  OS << " style = filled;\n";
584  OS << " color = lightgrey;\n";
585  OS << " label = \"" << sys::path::filename(ModIt.first) << "\";\n";
586  OS << " node [style=filled,fillcolor=lightblue];\n";
587 
588  auto &GVSMap = ModIt.second;
589  auto Draw = [&](GlobalValue::GUID IdFrom, GlobalValue::GUID IdTo, int Hotness) {
590  if (!GVSMap.count(IdTo)) {
591  CrossModuleEdges.push_back({ModId, Hotness, IdFrom, IdTo});
592  return;
593  }
594  DrawEdge(" ", ModId, IdFrom, ModId, IdTo, Hotness);
595  };
596 
597  for (auto &SummaryIt : GVSMap) {
598  NodeMap[SummaryIt.first].push_back(ModId);
599  auto Flags = SummaryIt.second->flags();
600  Attributes A;
601  if (isa<FunctionSummary>(SummaryIt.second)) {
602  A.add("shape", "record", "function");
603  } else if (isa<AliasSummary>(SummaryIt.second)) {
604  A.add("style", "dotted,filled", "alias");
605  A.add("shape", "box");
606  } else {
607  A.add("shape", "Mrecord", "variable");
608  if (Flags.Live && hasReadOnlyFlag(SummaryIt.second))
609  A.addComment("immutable");
610  if (Flags.Live && hasWriteOnlyFlag(SummaryIt.second))
611  A.addComment("writeOnly");
612  if (Flags.Live && hasConstantFlag(SummaryIt.second))
613  A.addComment("constant");
614  }
615  if (Flags.Visibility)
616  A.addComment("visibility");
617  if (Flags.DSOLocal)
618  A.addComment("dsoLocal");
619  if (Flags.CanAutoHide)
620  A.addComment("canAutoHide");
621  if (GUIDPreservedSymbols.count(SummaryIt.first))
622  A.addComment("preserved");
623 
624  auto VI = getValueInfo(SummaryIt.first);
625  A.add("label", getNodeLabel(VI, SummaryIt.second));
626  if (!Flags.Live)
627  A.add("fillcolor", "red", "dead");
628  else if (Flags.NotEligibleToImport)
629  A.add("fillcolor", "yellow", "not eligible to import");
630 
631  OS << " " << NodeId(ModId, SummaryIt.first) << " " << A.getAsString()
632  << "\n";
633  }
634  OS << " // Edges:\n";
635 
636  for (auto &SummaryIt : GVSMap) {
637  auto *GVS = SummaryIt.second;
638  for (auto &R : GVS->refs())
639  Draw(SummaryIt.first, R.getGUID(),
640  R.isWriteOnly() ? -1 : (R.isReadOnly() ? -2 : -3));
641 
642  if (auto *AS = dyn_cast_or_null<AliasSummary>(SummaryIt.second)) {
643  Draw(SummaryIt.first, AS->getAliaseeGUID(), -4);
644  continue;
645  }
646 
647  if (auto *FS = dyn_cast_or_null<FunctionSummary>(SummaryIt.second))
648  for (auto &CGEdge : FS->calls())
649  Draw(SummaryIt.first, CGEdge.first.getGUID(),
650  static_cast<int>(CGEdge.second.Hotness));
651  }
652  OS << " }\n";
653  }
654 
655  OS << " // Cross-module edges:\n";
656  for (auto &E : CrossModuleEdges) {
657  auto &ModList = NodeMap[E.Dst];
658  if (ModList.empty()) {
659  defineExternalNode(OS, " ", getValueInfo(E.Dst), E.Dst);
660  // Add fake module to the list to draw an edge to an external node
661  // in the loop below.
662  ModList.push_back(-1);
663  }
664  for (auto DstMod : ModList)
665  // The edge representing call or ref is drawn to every module where target
666  // symbol is defined. When target is a linkonce symbol there can be
667  // multiple edges representing a single call or ref, both intra-module and
668  // cross-module. As we've already drawn all intra-module edges before we
669  // skip it here.
670  if (DstMod != E.SrcMod)
671  DrawEdge(" ", E.SrcMod, E.Src, DstMod, E.Dst, E.Hotness);
672  }
673 
674  OS << "}";
675 }
llvm::GlobalValue::GUID
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:583
llvm::ValueInfo::getSummaryList
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
Definition: ModuleSummaryIndex.h:188
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::ModuleSummaryIndex::hasSyntheticEntryCounts
bool hasSyntheticEntryCounts() const
Definition: ModuleSummaryIndex.h:1443
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:492
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:1748
llvm::GlobalValue::LinkOnceAnyLinkage
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:50
llvm::ModuleSummaryIndex::setPartiallySplitLTOUnits
void setPartiallySplitLTOUnits()
Definition: ModuleSummaryIndex.h:1457
llvm::ModuleSummaryIndex::isReadOnly
bool isReadOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1436
SCCIterator.h
llvm::Function::empty
bool empty() const
Definition: Function.h:713
llvm::ModuleSummaryIndex::setEnableSplitLTOUnit
void setEnableSplitLTOUnit()
Definition: ModuleSummaryIndex.h:1454
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:1005
Statistic.h
Path.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::pdb::PDB_ColorItem::Comment
@ Comment
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:1461
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
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:250
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:1601
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:54
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:512
getSummaryAttributes
static std::string getSummaryAttributes(GlobalValueSummary *GVS)
Definition: ModuleSummaryIndex.cpp:471
llvm::ModuleSummaryIndex::withDSOLocalPropagation
bool withDSOLocalPropagation() const
Definition: ModuleSummaryIndex.h:1430
llvm::AArch64CC::LT
@ LT
Definition: AArch64BaseInfo.h:266
CommandLine.h
llvm::ModuleSummaryIndex::setWithAttributePropagation
void setWithAttributePropagation()
Definition: ModuleSummaryIndex.h:1426
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:364
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:1734
hasReadOnlyFlag
static bool hasReadOnlyFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:518
llvm::AreStatisticsEnabled
bool AreStatisticsEnabled()
Check if statistics are enabled.
Definition: Statistic.cpp:139
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:1453
fflagsToString
static std::string fflagsToString(FunctionSummary::FFlags F)
Definition: ModuleSummaryIndex.cpp:453
llvm::ARM_PROC::A
@ A
Definition: ARMBaseInfo.h:34
llvm::rdf::NodeId
uint32_t NodeId
Definition: RDFGraph.h:261
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:92
llvm::ModuleSummaryIndex::withGlobalValueDeadStripping
bool withGlobalValueDeadStripping() const
Definition: ModuleSummaryIndex.h:1418
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:42
llvm::ModuleSummaryIndex::setHasSyntheticEntryCounts
void setHasSyntheticEntryCounts()
Definition: ModuleSummaryIndex.h:1444
hasConstantFlag
static bool hasConstantFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:530
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:169
llvm::ValueInfo::canAutoHide
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
Definition: ModuleSummaryIndex.cpp:67
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:180
llvm::cl::opt< bool >
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
x2
gcc mainline compiles it x2(%rip)
VI
@ VI
Definition: SIInstrInfo.cpp:7986
llvm::GlobalValueSummary::linkage
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
Definition: ModuleSummaryIndex.h:476
uint64_t
llvm::ModuleSummaryIndex::dumpSCCs
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
Definition: ModuleSummaryIndex.cpp:355
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:1468
hasWriteOnlyFlag
static bool hasWriteOnlyFlag(const GlobalValueSummary *S)
Definition: ModuleSummaryIndex.cpp:524
llvm::DenseMap
Definition: DenseMap.h:714
I
#define I(x, y, z)
Definition: MD5.cpp:58
Attributes
AMDGPU Kernel Attributes
Definition: AMDGPULowerKernelAttributes.cpp:347
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:446
size
i< reg-> size
Definition: README.txt:166
llvm::ModuleSummaryIndex::skipModuleByDistributedBackend
bool skipModuleByDistributedBackend() const
Definition: ModuleSummaryIndex.h:1446
llvm::FunctionSummary::makeDummyFunctionSummary
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
Definition: ModuleSummaryIndex.h:742
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::X86AS::FS
@ FS
Definition: X86.h:200
llvm::ModuleSummaryIndex::setWithDSOLocalPropagation
void setWithDSOLocalPropagation()
Definition: ModuleSummaryIndex.h:1431
llvm::FunctionSummary::FFlags
Flags specific to function summaries.
Definition: ModuleSummaryIndex.h:637
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
llvm::ModuleSummaryIndex::partiallySplitLTOUnits
bool partiallySplitLTOUnits() const
Definition: ModuleSummaryIndex.h:1456
llvm::ModuleSummaryIndex::exportToDot
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
Definition: ModuleSummaryIndex.cpp:536
llvm::ModuleSummaryIndex::setFlags
void setFlags(uint64_t Flags)
Definition: ModuleSummaryIndex.cpp:113
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::ModuleSummaryIndex::setWithWholeProgramVisibility
void setWithWholeProgramVisibility()
Definition: ModuleSummaryIndex.h:1434
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:1721
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:505
llvm::ModuleSummaryIndex::canImportGlobalVar
bool canImportGlobalVar(GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
Definition: ModuleSummaryIndex.cpp:320
llvm::FunctionSummary::ExternalNode
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
Definition: ModuleSummaryIndex.h:761
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::FunctionSummary
Function summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:587
llvm::ModuleSummaryIndex::setWithGlobalValueDeadStripping
void setWithGlobalValueDeadStripping()
Definition: ModuleSummaryIndex.h:1421
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
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:420
llvm::FunctionSummary::ParamAccess::RangeWidth
static constexpr uint32_t RangeWidth
Definition: ModuleSummaryIndex.h:707
linkageToString
static std::string linkageToString(GlobalValue::LinkageTypes LT)
Definition: ModuleSummaryIndex.cpp:424
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:1578
llvm::GlobalValue::ProtectedVisibility
@ ProtectedVisibility
The GV is protected.
Definition: GlobalValue.h:65
llvm::FunctionSummary::specialRefCounts
std::pair< unsigned, unsigned > specialRefCounts() const
Definition: ModuleSummaryIndex.cpp:77
llvm::ModuleSummaryIndex::BitcodeSummaryVersion
static constexpr uint64_t BitcodeSummaryVersion
Definition: ModuleSummaryIndex.h:1308
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::ModuleSummaryIndex::isWriteOnly
bool isWriteOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1439
llvm::ModuleSummaryIndex::setSkipModuleByDistributedBackend
void setSkipModuleByDistributedBackend()
Definition: ModuleSummaryIndex.h:1449
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:577
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:85
getNodeLabel
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
Definition: ModuleSummaryIndex.cpp:488
getNodeVisualName
static std::string getNodeVisualName(GlobalValue::GUID Id)
Definition: ModuleSummaryIndex.cpp:480
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:152
llvm::ModuleSummaryIndex::withAttributePropagation
bool withAttributePropagation() const
Definition: ModuleSummaryIndex.h:1425
propagateAttributesToRefs
static void propagateAttributesToRefs(GlobalValueSummary *S, DenseSet< ValueInfo > &MarkedNonReadWriteOnly)
Definition: ModuleSummaryIndex.cpp:194
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:244
llvm::ModuleSummaryIndex::withWholeProgramVisibility
bool withWholeProgramVisibility() const
Definition: ModuleSummaryIndex.h:1433
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
llvm::Value
LLVM Value Representation.
Definition: Value.h:74