LLVM  16.0.0git
ModuleSummaryAnalysis.cpp
Go to the documentation of this file.
1 //===- ModuleSummaryAnalysis.cpp - Module summary index builder -----------===//
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 pass builds a ModuleSummaryIndex object for the module, to be written
10 // to bitcode or LLVM assembly.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SetVector.h"
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
26 #include "llvm/Analysis/LoopInfo.h"
31 #include "llvm/IR/Attributes.h"
32 #include "llvm/IR/BasicBlock.h"
33 #include "llvm/IR/Constant.h"
34 #include "llvm/IR/Constants.h"
35 #include "llvm/IR/Dominators.h"
36 #include "llvm/IR/Function.h"
37 #include "llvm/IR/GlobalAlias.h"
38 #include "llvm/IR/GlobalValue.h"
39 #include "llvm/IR/GlobalVariable.h"
40 #include "llvm/IR/Instructions.h"
41 #include "llvm/IR/IntrinsicInst.h"
42 #include "llvm/IR/Metadata.h"
43 #include "llvm/IR/Module.h"
45 #include "llvm/IR/Use.h"
46 #include "llvm/IR/User.h"
47 #include "llvm/InitializePasses.h"
50 #include "llvm/Pass.h"
51 #include "llvm/Support/Casting.h"
54 #include <algorithm>
55 #include <cassert>
56 #include <cstdint>
57 #include <vector>
58 
59 using namespace llvm;
60 using namespace llvm::memprof;
61 
62 #define DEBUG_TYPE "module-summary-analysis"
63 
64 // Option to force edges cold which will block importing when the
65 // -import-cold-multiplier is set to 0. Useful for debugging.
66 namespace llvm {
69 } // namespace llvm
70 
72  "force-summary-edges-cold", cl::Hidden, cl::location(ForceSummaryEdgesCold),
73  cl::desc("Force all edges in the function summary to cold"),
76  "all-non-critical", "All non-critical edges."),
77  clEnumValN(FunctionSummary::FSHT_All, "all", "All edges.")));
78 
80  "module-summary-dot-file", cl::Hidden, cl::value_desc("filename"),
81  cl::desc("File to emit dot graph of new summary into"));
82 
83 // Walk through the operands of a given User via worklist iteration and populate
84 // the set of GlobalValue references encountered. Invoked either on an
85 // Instruction or a GlobalVariable (which walks its initializer).
86 // Return true if any of the operands contains blockaddress. This is important
87 // to know when computing summary for global var, because if global variable
88 // references basic block address we can't import it separately from function
89 // containing that basic block. For simplicity we currently don't import such
90 // global vars at all. When importing function we aren't interested if any
91 // instruction in it takes an address of any basic block, because instruction
92 // can only take an address of basic block located in the same function.
93 static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
94  SetVector<ValueInfo> &RefEdges,
96  bool HasBlockAddress = false;
98  if (Visited.insert(CurUser).second)
99  Worklist.push_back(CurUser);
100 
101  while (!Worklist.empty()) {
102  const User *U = Worklist.pop_back_val();
103  const auto *CB = dyn_cast<CallBase>(U);
104 
105  for (const auto &OI : U->operands()) {
106  const User *Operand = dyn_cast<User>(OI);
107  if (!Operand)
108  continue;
109  if (isa<BlockAddress>(Operand)) {
110  HasBlockAddress = true;
111  continue;
112  }
113  if (auto *GV = dyn_cast<GlobalValue>(Operand)) {
114  // We have a reference to a global value. This should be added to
115  // the reference set unless it is a callee. Callees are handled
116  // specially by WriteFunction and are added to a separate list.
117  if (!(CB && CB->isCallee(&OI)))
118  RefEdges.insert(Index.getOrInsertValueInfo(GV));
119  continue;
120  }
121  if (Visited.insert(Operand).second)
122  Worklist.push_back(Operand);
123  }
124  }
125  return HasBlockAddress;
126 }
127 
129  ProfileSummaryInfo *PSI) {
130  if (!PSI)
132  if (PSI->isHotCount(ProfileCount))
134  if (PSI->isColdCount(ProfileCount))
137 }
138 
139 static bool isNonRenamableLocal(const GlobalValue &GV) {
140  return GV.hasSection() && GV.hasLocalLinkage();
141 }
142 
143 /// Determine whether this call has all constant integer arguments (excluding
144 /// "this") and summarize it to VCalls or ConstVCalls as appropriate.
148  std::vector<uint64_t> Args;
149  // Start from the second argument to skip the "this" pointer.
150  for (auto &Arg : drop_begin(Call.CB.args())) {
151  auto *CI = dyn_cast<ConstantInt>(Arg);
152  if (!CI || CI->getBitWidth() > 64) {
153  VCalls.insert({Guid, Call.Offset});
154  return;
155  }
156  Args.push_back(CI->getZExtValue());
157  }
158  ConstVCalls.insert({{Guid, Call.Offset}, std::move(Args)});
159 }
160 
161 /// If this intrinsic call requires that we add information to the function
162 /// summary, do so via the non-constant reference arguments.
164  const CallInst *CI, SetVector<GlobalValue::GUID> &TypeTests,
165  SetVector<FunctionSummary::VFuncId> &TypeTestAssumeVCalls,
166  SetVector<FunctionSummary::VFuncId> &TypeCheckedLoadVCalls,
167  SetVector<FunctionSummary::ConstVCall> &TypeTestAssumeConstVCalls,
168  SetVector<FunctionSummary::ConstVCall> &TypeCheckedLoadConstVCalls,
169  DominatorTree &DT) {
170  switch (CI->getCalledFunction()->getIntrinsicID()) {
171  case Intrinsic::type_test:
172  case Intrinsic::public_type_test: {
173  auto *TypeMDVal = cast<MetadataAsValue>(CI->getArgOperand(1));
174  auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
175  if (!TypeId)
176  break;
177  GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
178 
179  // Produce a summary from type.test intrinsics. We only summarize type.test
180  // intrinsics that are used other than by an llvm.assume intrinsic.
181  // Intrinsics that are assumed are relevant only to the devirtualization
182  // pass, not the type test lowering pass.
183  bool HasNonAssumeUses = llvm::any_of(CI->uses(), [](const Use &CIU) {
184  return !isa<AssumeInst>(CIU.getUser());
185  });
186  if (HasNonAssumeUses)
187  TypeTests.insert(Guid);
188 
189  SmallVector<DevirtCallSite, 4> DevirtCalls;
191  findDevirtualizableCallsForTypeTest(DevirtCalls, Assumes, CI, DT);
192  for (auto &Call : DevirtCalls)
193  addVCallToSet(Call, Guid, TypeTestAssumeVCalls,
194  TypeTestAssumeConstVCalls);
195 
196  break;
197  }
198 
199  case Intrinsic::type_checked_load: {
200  auto *TypeMDVal = cast<MetadataAsValue>(CI->getArgOperand(2));
201  auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
202  if (!TypeId)
203  break;
204  GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
205 
206  SmallVector<DevirtCallSite, 4> DevirtCalls;
209  bool HasNonCallUses = false;
210  findDevirtualizableCallsForTypeCheckedLoad(DevirtCalls, LoadedPtrs, Preds,
211  HasNonCallUses, CI, DT);
212  // Any non-call uses of the result of llvm.type.checked.load will
213  // prevent us from optimizing away the llvm.type.test.
214  if (HasNonCallUses)
215  TypeTests.insert(Guid);
216  for (auto &Call : DevirtCalls)
217  addVCallToSet(Call, Guid, TypeCheckedLoadVCalls,
218  TypeCheckedLoadConstVCalls);
219 
220  break;
221  }
222  default:
223  break;
224  }
225 }
226 
227 static bool isNonVolatileLoad(const Instruction *I) {
228  if (const auto *LI = dyn_cast<LoadInst>(I))
229  return !LI->isVolatile();
230 
231  return false;
232 }
233 
234 static bool isNonVolatileStore(const Instruction *I) {
235  if (const auto *SI = dyn_cast<StoreInst>(I))
236  return !SI->isVolatile();
237 
238  return false;
239 }
240 
241 // Returns true if the function definition must be unreachable.
242 //
243 // Note if this helper function returns true, `F` is guaranteed
244 // to be unreachable; if it returns false, `F` might still
245 // be unreachable but not covered by this helper function.
246 static bool mustBeUnreachableFunction(const Function &F) {
247  // A function must be unreachable if its entry block ends with an
248  // 'unreachable'.
249  assert(!F.isDeclaration());
250  return isa<UnreachableInst>(F.getEntryBlock().getTerminator());
251 }
252 
254  ModuleSummaryIndex &Index, const Module &M, const Function &F,
256  bool HasLocalsInUsedOrAsm, DenseSet<GlobalValue::GUID> &CantBePromoted,
257  bool IsThinLTO,
258  std::function<const StackSafetyInfo *(const Function &F)> GetSSICallback) {
259  // Summary not currently supported for anonymous functions, they should
260  // have been named.
261  assert(F.hasName());
262 
263  unsigned NumInsts = 0;
264  // Map from callee ValueId to profile count. Used to accumulate profile
265  // counts for all static calls to a given callee.
266  MapVector<ValueInfo, CalleeInfo> CallGraphEdges;
267  SetVector<ValueInfo> RefEdges, LoadRefEdges, StoreRefEdges;
269  SetVector<FunctionSummary::VFuncId> TypeTestAssumeVCalls,
270  TypeCheckedLoadVCalls;
271  SetVector<FunctionSummary::ConstVCall> TypeTestAssumeConstVCalls,
272  TypeCheckedLoadConstVCalls;
273  ICallPromotionAnalysis ICallAnalysis;
275 
276  // Add personality function, prefix data and prologue data to function's ref
277  // list.
278  findRefEdges(Index, &F, RefEdges, Visited);
279  std::vector<const Instruction *> NonVolatileLoads;
280  std::vector<const Instruction *> NonVolatileStores;
281 
282  std::vector<CallsiteInfo> Callsites;
283  std::vector<AllocInfo> Allocs;
284 
285  bool HasInlineAsmMaybeReferencingInternal = false;
286  bool HasIndirBranchToBlockAddress = false;
287  bool HasUnknownCall = false;
288  bool MayThrow = false;
289  for (const BasicBlock &BB : F) {
290  // We don't allow inlining of function with indirect branch to blockaddress.
291  // If the blockaddress escapes the function, e.g., via a global variable,
292  // inlining may lead to an invalid cross-function reference. So we shouldn't
293  // import such function either.
294  if (BB.hasAddressTaken()) {
295  for (User *U : BlockAddress::get(const_cast<BasicBlock *>(&BB))->users())
296  if (!isa<CallBrInst>(*U)) {
297  HasIndirBranchToBlockAddress = true;
298  break;
299  }
300  }
301 
302  for (const Instruction &I : BB) {
303  if (I.isDebugOrPseudoInst())
304  continue;
305  ++NumInsts;
306 
307  // Regular LTO module doesn't participate in ThinLTO import,
308  // so no reference from it can be read/writeonly, since this
309  // would require importing variable as local copy
310  if (IsThinLTO) {
311  if (isNonVolatileLoad(&I)) {
312  // Postpone processing of non-volatile load instructions
313  // See comments below
314  Visited.insert(&I);
315  NonVolatileLoads.push_back(&I);
316  continue;
317  } else if (isNonVolatileStore(&I)) {
318  Visited.insert(&I);
319  NonVolatileStores.push_back(&I);
320  // All references from second operand of store (destination address)
321  // can be considered write-only if they're not referenced by any
322  // non-store instruction. References from first operand of store
323  // (stored value) can't be treated either as read- or as write-only
324  // so we add them to RefEdges as we do with all other instructions
325  // except non-volatile load.
326  Value *Stored = I.getOperand(0);
327  if (auto *GV = dyn_cast<GlobalValue>(Stored))
328  // findRefEdges will try to examine GV operands, so instead
329  // of calling it we should add GV to RefEdges directly.
330  RefEdges.insert(Index.getOrInsertValueInfo(GV));
331  else if (auto *U = dyn_cast<User>(Stored))
332  findRefEdges(Index, U, RefEdges, Visited);
333  continue;
334  }
335  }
336  findRefEdges(Index, &I, RefEdges, Visited);
337  const auto *CB = dyn_cast<CallBase>(&I);
338  if (!CB) {
339  if (I.mayThrow())
340  MayThrow = true;
341  continue;
342  }
343 
344  const auto *CI = dyn_cast<CallInst>(&I);
345  // Since we don't know exactly which local values are referenced in inline
346  // assembly, conservatively mark the function as possibly referencing
347  // a local value from inline assembly to ensure we don't export a
348  // reference (which would require renaming and promotion of the
349  // referenced value).
350  if (HasLocalsInUsedOrAsm && CI && CI->isInlineAsm())
351  HasInlineAsmMaybeReferencingInternal = true;
352 
353  auto *CalledValue = CB->getCalledOperand();
354  auto *CalledFunction = CB->getCalledFunction();
355  if (CalledValue && !CalledFunction) {
356  CalledValue = CalledValue->stripPointerCasts();
357  // Stripping pointer casts can reveal a called function.
358  CalledFunction = dyn_cast<Function>(CalledValue);
359  }
360  // Check if this is an alias to a function. If so, get the
361  // called aliasee for the checks below.
362  if (auto *GA = dyn_cast<GlobalAlias>(CalledValue)) {
363  assert(!CalledFunction && "Expected null called function in callsite for alias");
364  CalledFunction = dyn_cast<Function>(GA->getAliaseeObject());
365  }
366  // Check if this is a direct call to a known function or a known
367  // intrinsic, or an indirect call with profile data.
368  if (CalledFunction) {
369  if (CI && CalledFunction->isIntrinsic()) {
371  CI, TypeTests, TypeTestAssumeVCalls, TypeCheckedLoadVCalls,
372  TypeTestAssumeConstVCalls, TypeCheckedLoadConstVCalls, DT);
373  continue;
374  }
375  // We should have named any anonymous globals
376  assert(CalledFunction->hasName());
377  auto ScaledCount = PSI->getProfileCount(*CB, BFI);
378  auto Hotness = ScaledCount ? getHotness(*ScaledCount, PSI)
382 
383  // Use the original CalledValue, in case it was an alias. We want
384  // to record the call edge to the alias in that case. Eventually
385  // an alias summary will be created to associate the alias and
386  // aliasee.
387  auto &ValueInfo = CallGraphEdges[Index.getOrInsertValueInfo(
388  cast<GlobalValue>(CalledValue))];
389  ValueInfo.updateHotness(Hotness);
390  // Add the relative block frequency to CalleeInfo if there is no profile
391  // information.
392  if (BFI != nullptr && Hotness == CalleeInfo::HotnessType::Unknown) {
393  uint64_t BBFreq = BFI->getBlockFreq(&BB).getFrequency();
394  uint64_t EntryFreq = BFI->getEntryFreq();
395  ValueInfo.updateRelBlockFreq(BBFreq, EntryFreq);
396  }
397  } else {
398  HasUnknownCall = true;
399  // Skip inline assembly calls.
400  if (CI && CI->isInlineAsm())
401  continue;
402  // Skip direct calls.
403  if (!CalledValue || isa<Constant>(CalledValue))
404  continue;
405 
406  // Check if the instruction has a callees metadata. If so, add callees
407  // to CallGraphEdges to reflect the references from the metadata, and
408  // to enable importing for subsequent indirect call promotion and
409  // inlining.
410  if (auto *MD = I.getMetadata(LLVMContext::MD_callees)) {
411  for (const auto &Op : MD->operands()) {
412  Function *Callee = mdconst::extract_or_null<Function>(Op);
413  if (Callee)
414  CallGraphEdges[Index.getOrInsertValueInfo(Callee)];
415  }
416  }
417 
418  uint32_t NumVals, NumCandidates;
419  uint64_t TotalCount;
420  auto CandidateProfileData =
422  &I, NumVals, TotalCount, NumCandidates);
423  for (const auto &Candidate : CandidateProfileData)
424  CallGraphEdges[Index.getOrInsertValueInfo(Candidate.Value)]
425  .updateHotness(getHotness(Candidate.Count, PSI));
426  }
427 
428  // TODO: Skip indirect calls for now. Need to handle these better, likely
429  // by creating multiple Callsites, one per target, then speculatively
430  // devirtualize while applying clone info in the ThinLTO backends. This
431  // will also be important because we will have a different set of clone
432  // versions per target. This handling needs to match that in the ThinLTO
433  // backend so we handle things consistently for matching of callsite
434  // summaries to instructions.
435  if (!CalledFunction)
436  continue;
437 
438  // Compute the list of stack ids first (so we can trim them from the stack
439  // ids on any MIBs).
441  I.getMetadata(LLVMContext::MD_callsite));
442  auto *MemProfMD = I.getMetadata(LLVMContext::MD_memprof);
443  if (MemProfMD) {
444  std::vector<MIBInfo> MIBs;
445  for (auto &MDOp : MemProfMD->operands()) {
446  auto *MIBMD = cast<const MDNode>(MDOp);
447  MDNode *StackNode = getMIBStackNode(MIBMD);
448  assert(StackNode);
449  SmallVector<unsigned> StackIdIndices;
450  CallStack<MDNode, MDNode::op_iterator> StackContext(StackNode);
451  // Collapse out any on the allocation call (inlining).
452  for (auto ContextIter =
453  StackContext.beginAfterSharedPrefix(InstCallsite);
454  ContextIter != StackContext.end(); ++ContextIter) {
455  unsigned StackIdIdx = Index.addOrGetStackIdIndex(*ContextIter);
456  // If this is a direct recursion, simply skip the duplicate
457  // entries. If this is mutual recursion, handling is left to
458  // the LTO link analysis client.
459  if (StackIdIndices.empty() || StackIdIndices.back() != StackIdIdx)
460  StackIdIndices.push_back(StackIdIdx);
461  }
462  MIBs.push_back(
463  MIBInfo(getMIBAllocType(MIBMD), std::move(StackIdIndices)));
464  }
465  Allocs.push_back(AllocInfo(std::move(MIBs)));
466  } else if (!InstCallsite.empty()) {
467  SmallVector<unsigned> StackIdIndices;
468  for (auto StackId : InstCallsite)
469  StackIdIndices.push_back(Index.addOrGetStackIdIndex(StackId));
470  // Use the original CalledValue, in case it was an alias. We want
471  // to record the call edge to the alias in that case. Eventually
472  // an alias summary will be created to associate the alias and
473  // aliasee.
474  auto CalleeValueInfo =
475  Index.getOrInsertValueInfo(cast<GlobalValue>(CalledValue));
476  Callsites.push_back({CalleeValueInfo, StackIdIndices});
477  }
478  }
479  }
480  Index.addBlockCount(F.size());
481 
482  std::vector<ValueInfo> Refs;
483  if (IsThinLTO) {
484  auto AddRefEdges = [&](const std::vector<const Instruction *> &Instrs,
485  SetVector<ValueInfo> &Edges,
487  for (const auto *I : Instrs) {
488  Cache.erase(I);
489  findRefEdges(Index, I, Edges, Cache);
490  }
491  };
492 
493  // By now we processed all instructions in a function, except
494  // non-volatile loads and non-volatile value stores. Let's find
495  // ref edges for both of instruction sets
496  AddRefEdges(NonVolatileLoads, LoadRefEdges, Visited);
497  // We can add some values to the Visited set when processing load
498  // instructions which are also used by stores in NonVolatileStores.
499  // For example this can happen if we have following code:
500  //
501  // store %Derived* @foo, %Derived** bitcast (%Base** @bar to %Derived**)
502  // %42 = load %Derived*, %Derived** bitcast (%Base** @bar to %Derived**)
503  //
504  // After processing loads we'll add bitcast to the Visited set, and if
505  // we use the same set while processing stores, we'll never see store
506  // to @bar and @bar will be mistakenly treated as readonly.
508  AddRefEdges(NonVolatileStores, StoreRefEdges, StoreCache);
509 
510  // If both load and store instruction reference the same variable
511  // we won't be able to optimize it. Add all such reference edges
512  // to RefEdges set.
513  for (const auto &VI : StoreRefEdges)
514  if (LoadRefEdges.remove(VI))
515  RefEdges.insert(VI);
516 
517  unsigned RefCnt = RefEdges.size();
518  // All new reference edges inserted in two loops below are either
519  // read or write only. They will be grouped in the end of RefEdges
520  // vector, so we can use a single integer value to identify them.
521  for (const auto &VI : LoadRefEdges)
522  RefEdges.insert(VI);
523 
524  unsigned FirstWORef = RefEdges.size();
525  for (const auto &VI : StoreRefEdges)
526  RefEdges.insert(VI);
527 
528  Refs = RefEdges.takeVector();
529  for (; RefCnt < FirstWORef; ++RefCnt)
530  Refs[RefCnt].setReadOnly();
531 
532  for (; RefCnt < Refs.size(); ++RefCnt)
533  Refs[RefCnt].setWriteOnly();
534  } else {
535  Refs = RefEdges.takeVector();
536  }
537  // Explicit add hot edges to enforce importing for designated GUIDs for
538  // sample PGO, to enable the same inlines as the profiled optimized binary.
539  for (auto &I : F.getImportGUIDs())
540  CallGraphEdges[Index.getOrInsertValueInfo(I)].updateHotness(
544 
545  bool NonRenamableLocal = isNonRenamableLocal(F);
546  bool NotEligibleForImport = NonRenamableLocal ||
547  HasInlineAsmMaybeReferencingInternal ||
548  HasIndirBranchToBlockAddress;
550  F.getLinkage(), F.getVisibility(), NotEligibleForImport,
551  /* Live = */ false, F.isDSOLocal(), F.canBeOmittedFromSymbolTable());
552  FunctionSummary::FFlags FunFlags{
553  F.doesNotAccessMemory(), F.onlyReadsMemory() && !F.doesNotAccessMemory(),
554  F.hasFnAttribute(Attribute::NoRecurse), F.returnDoesNotAlias(),
555  // FIXME: refactor this to use the same code that inliner is using.
556  // Don't try to import functions with noinline attribute.
557  F.getAttributes().hasFnAttr(Attribute::NoInline),
558  F.hasFnAttribute(Attribute::AlwaysInline),
559  F.hasFnAttribute(Attribute::NoUnwind), MayThrow, HasUnknownCall,
561  std::vector<FunctionSummary::ParamAccess> ParamAccesses;
562  if (auto *SSI = GetSSICallback(F))
563  ParamAccesses = SSI->getParamAccesses(Index);
564  auto FuncSummary = std::make_unique<FunctionSummary>(
565  Flags, NumInsts, FunFlags, /*EntryCount=*/0, std::move(Refs),
566  CallGraphEdges.takeVector(), TypeTests.takeVector(),
567  TypeTestAssumeVCalls.takeVector(), TypeCheckedLoadVCalls.takeVector(),
568  TypeTestAssumeConstVCalls.takeVector(),
569  TypeCheckedLoadConstVCalls.takeVector(), std::move(ParamAccesses),
570  std::move(Callsites), std::move(Allocs));
571  if (NonRenamableLocal)
572  CantBePromoted.insert(F.getGUID());
573  Index.addGlobalValueSummary(F, std::move(FuncSummary));
574 }
575 
576 /// Find function pointers referenced within the given vtable initializer
577 /// (or subset of an initializer) \p I. The starting offset of \p I within
578 /// the vtable initializer is \p StartingOffset. Any discovered function
579 /// pointers are added to \p VTableFuncs along with their cumulative offset
580 /// within the initializer.
581 static void findFuncPointers(const Constant *I, uint64_t StartingOffset,
582  const Module &M, ModuleSummaryIndex &Index,
583  VTableFuncList &VTableFuncs) {
584  // First check if this is a function pointer.
585  if (I->getType()->isPointerTy()) {
586  auto Fn = dyn_cast<Function>(I->stripPointerCasts());
587  // We can disregard __cxa_pure_virtual as a possible call target, as
588  // calls to pure virtuals are UB.
589  if (Fn && Fn->getName() != "__cxa_pure_virtual")
590  VTableFuncs.push_back({Index.getOrInsertValueInfo(Fn), StartingOffset});
591  return;
592  }
593 
594  // Walk through the elements in the constant struct or array and recursively
595  // look for virtual function pointers.
596  const DataLayout &DL = M.getDataLayout();
597  if (auto *C = dyn_cast<ConstantStruct>(I)) {
598  StructType *STy = dyn_cast<StructType>(C->getType());
599  assert(STy);
600  const StructLayout *SL = DL.getStructLayout(C->getType());
601 
602  for (auto EI : llvm::enumerate(STy->elements())) {
603  auto Offset = SL->getElementOffset(EI.index());
604  unsigned Op = SL->getElementContainingOffset(Offset);
605  findFuncPointers(cast<Constant>(I->getOperand(Op)),
606  StartingOffset + Offset, M, Index, VTableFuncs);
607  }
608  } else if (auto *C = dyn_cast<ConstantArray>(I)) {
609  ArrayType *ATy = C->getType();
610  Type *EltTy = ATy->getElementType();
611  uint64_t EltSize = DL.getTypeAllocSize(EltTy);
612  for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) {
613  findFuncPointers(cast<Constant>(I->getOperand(i)),
614  StartingOffset + i * EltSize, M, Index, VTableFuncs);
615  }
616  }
617 }
618 
619 // Identify the function pointers referenced by vtable definition \p V.
621  const GlobalVariable &V, const Module &M,
622  VTableFuncList &VTableFuncs) {
623  if (!V.isConstant())
624  return;
625 
626  findFuncPointers(V.getInitializer(), /*StartingOffset=*/0, M, Index,
627  VTableFuncs);
628 
629 #ifndef NDEBUG
630  // Validate that the VTableFuncs list is ordered by offset.
631  uint64_t PrevOffset = 0;
632  for (auto &P : VTableFuncs) {
633  // The findVFuncPointers traversal should have encountered the
634  // functions in offset order. We need to use ">=" since PrevOffset
635  // starts at 0.
636  assert(P.VTableOffset >= PrevOffset);
637  PrevOffset = P.VTableOffset;
638  }
639 #endif
640 }
641 
642 /// Record vtable definition \p V for each type metadata it references.
643 static void
645  const GlobalVariable &V,
646  SmallVectorImpl<MDNode *> &Types) {
647  for (MDNode *Type : Types) {
648  auto TypeID = Type->getOperand(1).get();
649 
650  uint64_t Offset =
651  cast<ConstantInt>(
652  cast<ConstantAsMetadata>(Type->getOperand(0))->getValue())
653  ->getZExtValue();
654 
655  if (auto *TypeId = dyn_cast<MDString>(TypeID))
656  Index.getOrInsertTypeIdCompatibleVtableSummary(TypeId->getString())
657  .push_back({Offset, Index.getOrInsertValueInfo(&V)});
658  }
659 }
660 
662  const GlobalVariable &V,
663  DenseSet<GlobalValue::GUID> &CantBePromoted,
664  const Module &M,
665  SmallVectorImpl<MDNode *> &Types) {
666  SetVector<ValueInfo> RefEdges;
668  bool HasBlockAddress = findRefEdges(Index, &V, RefEdges, Visited);
669  bool NonRenamableLocal = isNonRenamableLocal(V);
671  V.getLinkage(), V.getVisibility(), NonRenamableLocal,
672  /* Live = */ false, V.isDSOLocal(), V.canBeOmittedFromSymbolTable());
673 
674  VTableFuncList VTableFuncs;
675  // If splitting is not enabled, then we compute the summary information
676  // necessary for index-based whole program devirtualization.
677  if (!Index.enableSplitLTOUnit()) {
678  Types.clear();
679  V.getMetadata(LLVMContext::MD_type, Types);
680  if (!Types.empty()) {
681  // Identify the function pointers referenced by this vtable definition.
682  computeVTableFuncs(Index, V, M, VTableFuncs);
683 
684  // Record this vtable definition for each type metadata it references.
686  }
687  }
688 
689  // Don't mark variables we won't be able to internalize as read/write-only.
690  bool CanBeInternalized =
691  !V.hasComdat() && !V.hasAppendingLinkage() && !V.isInterposable() &&
693  bool Constant = V.isConstant();
694  GlobalVarSummary::GVarFlags VarFlags(CanBeInternalized,
695  Constant ? false : CanBeInternalized,
697  auto GVarSummary = std::make_unique<GlobalVarSummary>(Flags, VarFlags,
698  RefEdges.takeVector());
699  if (NonRenamableLocal)
700  CantBePromoted.insert(V.getGUID());
701  if (HasBlockAddress)
702  GVarSummary->setNotEligibleToImport();
703  if (!VTableFuncs.empty())
704  GVarSummary->setVTableFuncs(VTableFuncs);
705  Index.addGlobalValueSummary(V, std::move(GVarSummary));
706 }
707 
709  DenseSet<GlobalValue::GUID> &CantBePromoted) {
710  // Skip summary for indirect function aliases as summary for aliasee will not
711  // be emitted.
712  const GlobalObject *Aliasee = A.getAliaseeObject();
713  if (isa<GlobalIFunc>(Aliasee))
714  return;
715  bool NonRenamableLocal = isNonRenamableLocal(A);
717  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
718  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
719  auto AS = std::make_unique<AliasSummary>(Flags);
720  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
721  assert(AliaseeVI && "Alias expects aliasee summary to be available");
722  assert(AliaseeVI.getSummaryList().size() == 1 &&
723  "Expected a single entry per aliasee in per-module index");
724  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
725  if (NonRenamableLocal)
726  CantBePromoted.insert(A.getGUID());
727  Index.addGlobalValueSummary(A, std::move(AS));
728 }
729 
730 // Set LiveRoot flag on entries matching the given value name.
732  if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID(Name)))
733  for (const auto &Summary : VI.getSummaryList())
734  Summary->setLive(true);
735 }
736 
738  const Module &M,
739  std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback,
740  ProfileSummaryInfo *PSI,
741  std::function<const StackSafetyInfo *(const Function &F)> GetSSICallback) {
742  assert(PSI);
743  bool EnableSplitLTOUnit = false;
744  if (auto *MD = mdconst::extract_or_null<ConstantInt>(
745  M.getModuleFlag("EnableSplitLTOUnit")))
746  EnableSplitLTOUnit = MD->getZExtValue();
747  ModuleSummaryIndex Index(/*HaveGVs=*/true, EnableSplitLTOUnit);
748 
749  // Identify the local values in the llvm.used and llvm.compiler.used sets,
750  // which should not be exported as they would then require renaming and
751  // promotion, but we may have opaque uses e.g. in inline asm. We collect them
752  // here because we use this information to mark functions containing inline
753  // assembly calls as not importable.
756  // First collect those in the llvm.used set.
757  collectUsedGlobalVariables(M, Used, /*CompilerUsed=*/false);
758  // Next collect those in the llvm.compiler.used set.
759  collectUsedGlobalVariables(M, Used, /*CompilerUsed=*/true);
760  DenseSet<GlobalValue::GUID> CantBePromoted;
761  for (auto *V : Used) {
762  if (V->hasLocalLinkage()) {
763  LocalsUsed.insert(V);
764  CantBePromoted.insert(V->getGUID());
765  }
766  }
767 
768  bool HasLocalInlineAsmSymbol = false;
769  if (!M.getModuleInlineAsm().empty()) {
770  // Collect the local values defined by module level asm, and set up
771  // summaries for these symbols so that they can be marked as NoRename,
772  // to prevent export of any use of them in regular IR that would require
773  // renaming within the module level asm. Note we don't need to create a
774  // summary for weak or global defs, as they don't need to be flagged as
775  // NoRename, and defs in module level asm can't be imported anyway.
776  // Also, any values used but not defined within module level asm should
777  // be listed on the llvm.used or llvm.compiler.used global and marked as
778  // referenced from there.
780  M, [&](StringRef Name, object::BasicSymbolRef::Flags Flags) {
781  // Symbols not marked as Weak or Global are local definitions.
782  if (Flags & (object::BasicSymbolRef::SF_Weak |
784  return;
785  HasLocalInlineAsmSymbol = true;
786  GlobalValue *GV = M.getNamedValue(Name);
787  if (!GV)
788  return;
789  assert(GV->isDeclaration() && "Def in module asm already has definition");
792  /* NotEligibleToImport = */ true,
793  /* Live = */ true,
794  /* Local */ GV->isDSOLocal(), GV->canBeOmittedFromSymbolTable());
795  CantBePromoted.insert(GV->getGUID());
796  // Create the appropriate summary type.
797  if (Function *F = dyn_cast<Function>(GV)) {
798  std::unique_ptr<FunctionSummary> Summary =
799  std::make_unique<FunctionSummary>(
800  GVFlags, /*InstCount=*/0,
802  F->hasFnAttribute(Attribute::ReadNone),
803  F->hasFnAttribute(Attribute::ReadOnly),
804  F->hasFnAttribute(Attribute::NoRecurse),
805  F->returnDoesNotAlias(),
806  /* NoInline = */ false,
807  F->hasFnAttribute(Attribute::AlwaysInline),
808  F->hasFnAttribute(Attribute::NoUnwind),
809  /* MayThrow */ true,
810  /* HasUnknownCall */ true,
811  /* MustBeUnreachable */ false},
812  /*EntryCount=*/0, ArrayRef<ValueInfo>{},
821  Index.addGlobalValueSummary(*GV, std::move(Summary));
822  } else {
823  std::unique_ptr<GlobalVarSummary> Summary =
824  std::make_unique<GlobalVarSummary>(
825  GVFlags,
827  false, false, cast<GlobalVariable>(GV)->isConstant(),
830  Index.addGlobalValueSummary(*GV, std::move(Summary));
831  }
832  });
833  }
834 
835  bool IsThinLTO = true;
836  if (auto *MD =
837  mdconst::extract_or_null<ConstantInt>(M.getModuleFlag("ThinLTO")))
838  IsThinLTO = MD->getZExtValue();
839 
840  // Compute summaries for all functions defined in module, and save in the
841  // index.
842  for (const auto &F : M) {
843  if (F.isDeclaration())
844  continue;
845 
846  DominatorTree DT(const_cast<Function &>(F));
847  BlockFrequencyInfo *BFI = nullptr;
848  std::unique_ptr<BlockFrequencyInfo> BFIPtr;
849  if (GetBFICallback)
850  BFI = GetBFICallback(F);
851  else if (F.hasProfileData()) {
852  LoopInfo LI{DT};
853  BranchProbabilityInfo BPI{F, LI};
854  BFIPtr = std::make_unique<BlockFrequencyInfo>(F, BPI, LI);
855  BFI = BFIPtr.get();
856  }
857 
858  computeFunctionSummary(Index, M, F, BFI, PSI, DT,
859  !LocalsUsed.empty() || HasLocalInlineAsmSymbol,
860  CantBePromoted, IsThinLTO, GetSSICallback);
861  }
862 
863  // Compute summaries for all variables defined in module, and save in the
864  // index.
866  for (const GlobalVariable &G : M.globals()) {
867  if (G.isDeclaration())
868  continue;
869  computeVariableSummary(Index, G, CantBePromoted, M, Types);
870  }
871 
872  // Compute summaries for all aliases defined in module, and save in the
873  // index.
874  for (const GlobalAlias &A : M.aliases())
875  computeAliasSummary(Index, A, CantBePromoted);
876 
877  // Iterate through ifuncs, set their resolvers all alive.
878  for (const GlobalIFunc &I : M.ifuncs()) {
879  I.applyAlongResolverPath([&Index](const GlobalValue &GV) {
880  Index.getGlobalValueSummary(GV)->setLive(true);
881  });
882  }
883 
884  for (auto *V : LocalsUsed) {
885  auto *Summary = Index.getGlobalValueSummary(*V);
886  assert(Summary && "Missing summary for global value");
887  Summary->setNotEligibleToImport();
888  }
889 
890  // The linker doesn't know about these LLVM produced values, so we need
891  // to flag them as live in the index to ensure index-based dead value
892  // analysis treats them as live roots of the analysis.
893  setLiveRoot(Index, "llvm.used");
894  setLiveRoot(Index, "llvm.compiler.used");
895  setLiveRoot(Index, "llvm.global_ctors");
896  setLiveRoot(Index, "llvm.global_dtors");
897  setLiveRoot(Index, "llvm.global.annotations");
898 
899  for (auto &GlobalList : Index) {
900  // Ignore entries for references that are undefined in the current module.
901  if (GlobalList.second.SummaryList.empty())
902  continue;
903 
904  assert(GlobalList.second.SummaryList.size() == 1 &&
905  "Expected module's index to have one summary per GUID");
906  auto &Summary = GlobalList.second.SummaryList[0];
907  if (!IsThinLTO) {
908  Summary->setNotEligibleToImport();
909  continue;
910  }
911 
912  bool AllRefsCanBeExternallyReferenced =
913  llvm::all_of(Summary->refs(), [&](const ValueInfo &VI) {
914  return !CantBePromoted.count(VI.getGUID());
915  });
916  if (!AllRefsCanBeExternallyReferenced) {
917  Summary->setNotEligibleToImport();
918  continue;
919  }
920 
921  if (auto *FuncSummary = dyn_cast<FunctionSummary>(Summary.get())) {
922  bool AllCallsCanBeExternallyReferenced = llvm::all_of(
923  FuncSummary->calls(), [&](const FunctionSummary::EdgeTy &Edge) {
924  return !CantBePromoted.count(Edge.first.getGUID());
925  });
926  if (!AllCallsCanBeExternallyReferenced)
927  Summary->setNotEligibleToImport();
928  }
929  }
930 
931  if (!ModuleSummaryDotFile.empty()) {
932  std::error_code EC;
934  if (EC)
935  report_fatal_error(Twine("Failed to open dot file ") +
936  ModuleSummaryDotFile + ": " + EC.message() + "\n");
937  Index.exportToDot(OSDot, {});
938  }
939 
940  return Index;
941 }
942 
943 AnalysisKey ModuleSummaryIndexAnalysis::Key;
944 
948  auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
949  bool NeedSSI = needsParamAccessSummary(M);
951  M,
952  [&FAM](const Function &F) {
954  *const_cast<Function *>(&F));
955  },
956  &PSI,
957  [&FAM, NeedSSI](const Function &F) -> const StackSafetyInfo * {
958  return NeedSSI ? &FAM.getResult<StackSafetyAnalysis>(
959  const_cast<Function &>(F))
960  : nullptr;
961  });
962 }
963 
965 
966 INITIALIZE_PASS_BEGIN(ModuleSummaryIndexWrapperPass, "module-summary-analysis",
967  "Module Summary Analysis", false, true)
972  "Module Summary Analysis", false, true)
973 
975  return new ModuleSummaryIndexWrapperPass();
976 }
977 
979  : ModulePass(ID) {
981 }
982 
984  auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
985  bool NeedSSI = needsParamAccessSummary(M);
987  M,
988  [this](const Function &F) {
989  return &(this->getAnalysis<BlockFrequencyInfoWrapperPass>(
990  *const_cast<Function *>(&F))
991  .getBFI());
992  },
993  PSI,
994  [&](const Function &F) -> const StackSafetyInfo * {
995  return NeedSSI ? &getAnalysis<StackSafetyInfoWrapperPass>(
996  const_cast<Function &>(F))
997  .getResult()
998  : nullptr;
999  }));
1000  return false;
1001 }
1002 
1004  Index.reset();
1005  return false;
1006 }
1007 
1009  AU.setPreservesAll();
1013 }
1014 
1016 
1018  const ModuleSummaryIndex *Index)
1019  : ImmutablePass(ID), Index(Index) {
1022 }
1023 
1025  AnalysisUsage &AU) const {
1026  AU.setPreservesAll();
1027 }
1028 
1030  const ModuleSummaryIndex *Index) {
1032 }
1033 
1035  "Module summary info", false, true)
i
i
Definition: README.txt:29
StackSafetyAnalysis.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition: SmallVector.h:741
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::drop_begin
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition: STLExtras.h:387
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
FileSystem.h
llvm::sys::fs::OF_None
@ OF_None
Definition: FileSystem.h:757
Metadata.h
llvm::User::operands
op_range operands()
Definition: User.h:242
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(ModuleSummaryIndexWrapperPass, "module-summary-analysis", "Module Summary Analysis", false, true) INITIALIZE_PASS_END(ModuleSummaryIndexWrapperPass
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
IntrinsicInst.h
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:774
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:541
llvm::Function
Definition: Function.h:60
llvm::cl::location
LocationClass< Ty > location(Ty &L)
Definition: CommandLine.h:467
StringRef.h
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
Pass.h
llvm::BlockFrequencyInfoWrapperPass
Legacy analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:138
llvm::SetVector::size
size_type size() const
Determine the number of elements in the SetVector.
Definition: SetVector.h:77
llvm::ImmutableModuleSummaryIndexWrapperPass
Legacy wrapper pass to provide the ModuleSummaryIndex object.
Definition: ModuleSummaryAnalysis.h:83
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::enumerate
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...
Definition: STLExtras.h:2263
llvm::CalleeInfo::HotnessType::Cold
@ Cold
MapVector.h
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::GlobalObject::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1289
llvm::GlobalAlias
Definition: GlobalAlias.h:28
llvm::ModuleSummaryIndexWrapperPass::ModuleSummaryIndexWrapperPass
ModuleSummaryIndexWrapperPass()
Definition: ModuleSummaryAnalysis.cpp:978
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1793
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::needsParamAccessSummary
bool needsParamAccessSummary(const Module &M)
Definition: StackSafetyAnalysis.cpp:1094
Module.h
llvm::memprof::getMIBAllocType
AllocationType getMIBAllocType(const MDNode *MIB)
Returns the allocation type from an MIB metadata node.
Definition: MemoryProfileInfo.cpp:61
llvm::GlobalValue::hasSection
bool hasSection() const
Definition: GlobalValue.h:286
llvm::createImmutableModuleSummaryIndexWrapperPass
ImmutablePass * createImmutableModuleSummaryIndexWrapperPass(const ModuleSummaryIndex *Index)
Definition: ModuleSummaryAnalysis.cpp:1029
llvm::object::BasicSymbolRef::Flags
Flags
Definition: SymbolicFile.h:108
llvm::ProfileSummaryInfo::getProfileCount
Optional< uint64_t > getProfileCount(const CallBase &CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false) const
Returns the profile count for CallInst.
Definition: ProfileSummaryInfo.cpp:78
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition: GlobalValue.h:63
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::FunctionSummary::FSHT_AllNonCritical
@ FSHT_AllNonCritical
Definition: ModuleSummaryIndex.h:595
STLExtras.h
ModuleSummaryAnalysis.h
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::object::BasicSymbolRef::SF_Weak
@ SF_Weak
Definition: SymbolicFile.h:112
SymbolicFile.h
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
addIntrinsicToSummary
static void addIntrinsicToSummary(const CallInst *CI, SetVector< GlobalValue::GUID > &TypeTests, SetVector< FunctionSummary::VFuncId > &TypeTestAssumeVCalls, SetVector< FunctionSummary::VFuncId > &TypeCheckedLoadVCalls, SetVector< FunctionSummary::ConstVCall > &TypeTestAssumeConstVCalls, SetVector< FunctionSummary::ConstVCall > &TypeCheckedLoadConstVCalls, DominatorTree &DT)
If this intrinsic call requires that we add information to the function summary, do so via the non-co...
Definition: ModuleSummaryAnalysis.cpp:163
Use.h
ModuleSummaryIndex.h
llvm::ICallPromotionAnalysis
Definition: IndirectCallPromotionAnalysis.h:24
llvm::StackSafetyAnalysis
StackSafetyInfo wrapper for the new pass manager.
Definition: StackSafetyAnalysis.h:92
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::collectUsedGlobalVariables
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
Definition: Module.cpp:801
findRefEdges
static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser, SetVector< ValueInfo > &RefEdges, SmallPtrSet< const User *, 8 > &Visited)
Definition: ModuleSummaryAnalysis.cpp:93
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::GlobalValueSummary::GVFlags
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
Definition: ModuleSummaryIndex.h:370
IndirectCallPromotionAnalysis.h
computeVTableFuncs
static void computeVTableFuncs(ModuleSummaryIndex &Index, const GlobalVariable &V, const Module &M, VTableFuncList &VTableFuncs)
Definition: ModuleSummaryAnalysis.cpp:620
computeFunctionSummary
static void computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M, const Function &F, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, DominatorTree &DT, bool HasLocalsInUsedOrAsm, DenseSet< GlobalValue::GUID > &CantBePromoted, bool IsThinLTO, std::function< const StackSafetyInfo *(const Function &F)> GetSSICallback)
Definition: ModuleSummaryAnalysis.cpp:253
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
CommandLine.h
llvm::ImmutableModuleSummaryIndexWrapperPass::ID
static char ID
Definition: ModuleSummaryAnalysis.h:87
llvm::SetVector::remove
bool remove(const value_type &X)
Remove an item from the set vector.
Definition: SetVector.h:157
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
llvm::BlockFrequencyInfo
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Definition: BlockFrequencyInfo.h:37
llvm::ProfileSummaryInfo::isColdCount
bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
Definition: ProfileSummaryInfo.cpp:295
GlobalValue.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:266
llvm::ArrayType::getNumElements
uint64_t getNumElements() const
Definition: DerivedTypes.h:369
llvm::GlobalVarSummary::GVarFlags
Definition: ModuleSummaryIndex.h:1012
llvm::GlobalValue::hasAppendingLinkage
bool hasAppendingLinkage() const
Definition: GlobalValue.h:520
getHotness
static CalleeInfo::HotnessType getHotness(uint64_t ProfileCount, ProfileSummaryInfo *PSI)
Definition: ModuleSummaryAnalysis.cpp:128
Constants.h
llvm::FunctionSummary::EdgeTy
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
Definition: ModuleSummaryIndex.h:590
llvm::memprof::CallStack
Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...
Definition: MemoryProfileInfo.h:108
llvm::User
Definition: User.h:44
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::CallBase::getCalledFunction
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1397
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::BranchProbabilityInfo
Analysis providing branch probability information.
Definition: BranchProbabilityInfo.h:113
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:37
SI
@ SI
Definition: SIInstrInfo.cpp:7966
TypeMetadataUtils.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::FunctionSummary::ForceSummaryHotnessType
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
Definition: ModuleSummaryIndex.h:593
llvm::memprof::CallStack::beginAfterSharedPrefix
CallStackIterator beginAfterSharedPrefix(CallStack &Other)
Definition: MemoryProfileInfo.h:159
llvm::Value::uses
iterator_range< use_iterator > uses()
Definition: Value.h:376
DenseSet.h
false
Definition: StackSlotColoring.cpp:141
llvm::CalleeInfo::HotnessType
HotnessType
Definition: ModuleSummaryIndex.h:59
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::ModuleSummaryIndexAnalysis::run
Result run(Module &M, ModuleAnalysisManager &AM)
Definition: ModuleSummaryAnalysis.cpp:946
llvm::ImmutableModuleSummaryIndexWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: ModuleSummaryAnalysis.cpp:1024
llvm::Instruction
Definition: Instruction.h:42
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
addVCallToSet
static void addVCallToSet(DevirtCallSite Call, GlobalValue::GUID Guid, SetVector< FunctionSummary::VFuncId > &VCalls, SetVector< FunctionSummary::ConstVCall > &ConstVCalls)
Determine whether this call has all constant integer arguments (excluding "this") and summarize it to...
Definition: ModuleSummaryAnalysis.cpp:145
llvm::GlobalObject::VCallVisibilityPublic
@ VCallVisibilityPublic
Definition: GlobalObject.h:34
SmallPtrSet.h
llvm::ImmutableModuleSummaryIndexWrapperPass::ImmutableModuleSummaryIndexWrapperPass
ImmutableModuleSummaryIndexWrapperPass(const ModuleSummaryIndex *Index=nullptr)
Definition: ModuleSummaryAnalysis.cpp:1017
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::BlockFrequencyAnalysis
Analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:112
llvm::GlobalValue::getGUID
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:587
isNonRenamableLocal
static bool isNonRenamableLocal(const GlobalValue &GV)
Definition: ModuleSummaryAnalysis.cpp:139
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:169
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::CalleeInfo::HotnessType::None
@ None
LoopInfo.h
llvm::ProfileSummaryInfo
Analysis providing profile information.
Definition: ProfileSummaryInfo.h:40
llvm::SmallPtrSetImplBase::empty
bool empty() const
Definition: SmallPtrSet.h:92
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
FSEC
static cl::opt< FunctionSummary::ForceSummaryHotnessType, true > FSEC("force-summary-edges-cold", cl::Hidden, cl::location(ForceSummaryEdgesCold), cl::desc("Force all edges in the function summary to cold"), cl::values(clEnumValN(FunctionSummary::FSHT_None, "none", "None."), clEnumValN(FunctionSummary::FSHT_AllNonCritical, "all-non-critical", "All non-critical edges."), clEnumValN(FunctionSummary::FSHT_All, "all", "All edges.")))
BasicBlock.h
llvm::cl::opt
Definition: CommandLine.h:1412
llvm::GlobalValue::hasAvailableExternallyLinkage
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:507
llvm::CalleeInfo::HotnessType::Hot
@ Hot
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalVariable::getInitializer
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: GlobalVariable.h:135
VI
@ VI
Definition: SIInstrInfo.cpp:7967
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:705
BranchProbabilityInfo.h
llvm::ProfileSummaryInfo::isHotCount
bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
Definition: ProfileSummaryInfo.cpp:291
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::StructLayout
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
Definition: DataLayout.h:622
uint64_t
ProfileSummaryInfo.h
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:244
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::ModuleSummaryIndexWrapperPass::ID
static char ID
Definition: ModuleSummaryAnalysis.h:62
analysis
module summary analysis
Definition: ModuleSummaryAnalysis.cpp:971
isConstant
static bool isConstant(const MachineInstr &MI)
Definition: AMDGPUInstructionSelector.cpp:2605
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::VTableFuncList
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
Definition: ModuleSummaryIndex.h:994
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::ProfileSummaryInfoWrapperPass
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Definition: ProfileSummaryInfo.h:194
llvm::StructLayout::getElementContainingOffset
unsigned getElementContainingOffset(uint64_t Offset) const
Given a valid byte offset into the structure, returns the structure index that contains it.
Definition: DataLayout.cpp:83
ArrayRef.h
computeVariableSummary
static void computeVariableSummary(ModuleSummaryIndex &Index, const GlobalVariable &V, DenseSet< GlobalValue::GUID > &CantBePromoted, const Module &M, SmallVectorImpl< MDNode * > &Types)
Definition: ModuleSummaryAnalysis.cpp:661
llvm::DevirtCallSite
A call site that could be devirtualized.
Definition: TypeMetadataUtils.h:38
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::memprof::CallStack::empty
bool empty() const
Definition: MemoryProfileInfo.h:126
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:523
llvm::MapVector::takeVector
VectorType takeVector()
Clear the MapVector and return the underlying vector.
Definition: MapVector.h:56
llvm::initializeModuleSummaryIndexWrapperPassPass
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &)
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::ForceSummaryEdgesCold
FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold
Definition: ModuleSummaryAnalysis.cpp:67
llvm::initializeImmutableModuleSummaryIndexWrapperPassPass
void initializeImmutableModuleSummaryIndexWrapperPassPass(PassRegistry &)
setLiveRoot
static void setLiveRoot(ModuleSummaryIndex &Index, StringRef Name)
Definition: ModuleSummaryAnalysis.cpp:731
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:66
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
isNonVolatileStore
static bool isNonVolatileStore(const Instruction *I)
Definition: ModuleSummaryAnalysis.cpp:234
llvm::StackSafetyInfo
Interface to access stack safety analysis results for single function.
Definition: StackSafetyAnalysis.h:26
llvm::FunctionSummary::FFlags
Flags specific to function summaries.
Definition: ModuleSummaryIndex.h:637
llvm::GlobalObject::hasComdat
bool hasComdat() const
Definition: GlobalObject.h:121
llvm::SetVector::insert
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:141
llvm::Function::getIntrinsicID
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:205
llvm::ProfileSummaryAnalysis
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
Definition: ProfileSummaryInfo.h:212
ModuleSymbolTable.h
llvm::memprof::CallStack::end
CallStackIterator end() const
Definition: MemoryProfileInfo.h:129
llvm::GlobalValue::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:385
llvm::StackSafetyInfoWrapperPass
StackSafetyInfo wrapper for the legacy pass manager.
Definition: StackSafetyAnalysis.h:111
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::LoopInfo
Definition: LoopInfo.h:1108
llvm::memprof::getMIBStackNode
MDNode * getMIBStackNode(const MDNode *MIB)
Returns the stack node from an MIB metadata node.
Definition: MemoryProfileInfo.cpp:55
llvm::CalleeInfo::HotnessType::Unknown
@ Unknown
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1741
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
findFuncPointers
static void findFuncPointers(const Constant *I, uint64_t StartingOffset, const Module &M, ModuleSummaryIndex &Index, VTableFuncList &VTableFuncs)
Find function pointers referenced within the given vtable initializer (or subset of an initializer) I...
Definition: ModuleSummaryAnalysis.cpp:581
llvm::ModuleSummaryIndexWrapperPass::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: ModuleSummaryAnalysis.cpp:1003
uint32_t
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:680
recordTypeIdCompatibleVtableReferences
static void recordTypeIdCompatibleVtableReferences(ModuleSummaryIndex &Index, const GlobalVariable &V, SmallVectorImpl< MDNode * > &Types)
Record vtable definition V for each type metadata it references.
Definition: ModuleSummaryAnalysis.cpp:644
BlockFrequencyInfo.h
llvm::FunctionSummary::FSHT_None
@ FSHT_None
Definition: ModuleSummaryIndex.h:594
llvm::AMDGPUISD::BFI
@ BFI
Definition: AMDGPUISelLowering.h:432
llvm::ICallPromotionAnalysis::getPromotionCandidatesForInstruction
ArrayRef< InstrProfValueData > getPromotionCandidatesForInstruction(const Instruction *I, uint32_t &NumVals, uint64_t &TotalCount, uint32_t &NumCandidates)
Returns reference to array of InstrProfValueData for the given instruction I.
Definition: IndirectCallPromotionAnalysis.cpp:87
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:441
users
iv users
Definition: IVUsers.cpp:48
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:187
llvm::GlobalValue::isInterposable
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
Definition: Globals.cpp:102
llvm::CalleeInfo::HotnessType::Critical
@ Critical
llvm::memprof
Definition: MemoryProfileInfo.h:24
Attributes.h
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::createModuleSummaryIndexWrapperPass
ModulePass * createModuleSummaryIndexWrapperPass()
Definition: ModuleSummaryAnalysis.cpp:974
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::GlobalValue::hasDLLExportStorageClass
bool hasDLLExportStorageClass() const
Definition: GlobalValue.h:277
llvm::findDevirtualizableCallsForTypeCheckedLoad
void findDevirtualizableCallsForTypeCheckedLoad(SmallVectorImpl< DevirtCallSite > &DevirtCalls, SmallVectorImpl< Instruction * > &LoadedPtrs, SmallVectorImpl< Instruction * > &Preds, bool &HasNonCallUses, const CallInst *CI, DominatorTree &DT)
Given a call to the intrinsic @llvm.type.checked.load, find all devirtualizable call sites based on t...
Definition: TypeMetadataUtils.cpp:96
MemoryProfileInfo.h
llvm::StructType::elements
ArrayRef< Type * > elements() const
Definition: DerivedTypes.h:319
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::StructLayout::getElementOffset
uint64_t getElementOffset(unsigned Idx) const
Definition: DataLayout.h:652
GlobalVariable.h
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:591
Casting.h
Function.h
llvm::MIBInfo
Summary of a single MIB in a memprof metadata on allocations.
Definition: ModuleSummaryIndex.h:326
llvm::buildModuleSummaryIndex
ModuleSummaryIndex buildModuleSummaryIndex(const Module &M, std::function< BlockFrequencyInfo *(const Function &F)> GetBFICallback, ProfileSummaryInfo *PSI, std::function< const StackSafetyInfo *(const Function &F)> GetSSICallback=[](const Function &F) -> const StackSafetyInfo *{ return nullptr;})
Direct function to compute a ModuleSummaryIndex from a given module.
Definition: ModuleSummaryAnalysis.cpp:737
llvm::cl::value_desc
Definition: CommandLine.h:422
GlobalAlias.h
mustBeUnreachableFunction
static bool mustBeUnreachableFunction(const Function &F)
Definition: ModuleSummaryAnalysis.cpp:246
Instructions.h
llvm::ModuleSummaryIndexWrapperPass::runOnModule
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
Definition: ModuleSummaryAnalysis.cpp:983
SmallVector.h
isNonVolatileLoad
static bool isNonVolatileLoad(const Instruction *I)
Definition: ModuleSummaryAnalysis.cpp:227
User.h
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1199
llvm::GlobalVariable::isConstant
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Definition: GlobalVariable.h:152
Dominators.h
llvm::FunctionSummary::FSHT_All
@ FSHT_All
Definition: ModuleSummaryIndex.h:596
llvm::CallBase::getArgOperand
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1342
llvm::object::BasicSymbolRef::SF_Global
@ SF_Global
Definition: SymbolicFile.h:111
llvm::SmallVectorImpl::pop_back_val
T pop_back_val()
Definition: SmallVector.h:677
llvm::GlobalObject::getVCallVisibility
VCallVisibility getVCallVisibility() const
Definition: Metadata.cpp:1611
llvm::BlockAddress::get
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1751
llvm::ModuleSummaryIndexWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: ModuleSummaryAnalysis.cpp:1008
ModuleSummaryDotFile
static cl::opt< std::string > ModuleSummaryDotFile("module-summary-dot-file", cl::Hidden, cl::value_desc("filename"), cl::desc("File to emit dot graph of new summary into"))
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::InnerAnalysisManagerProxy
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:931
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1474
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::SetVector::takeVector
Vector takeVector()
Clear the SetVector and return the underlying vector.
Definition: SetVector.h:66
llvm::AllocInfo
Summary of memprof metadata on allocations.
Definition: ModuleSummaryIndex.h:341
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::ModuleSummaryIndexWrapperPass
Legacy wrapper pass to provide the ModuleSummaryIndex object.
Definition: ModuleSummaryAnalysis.h:58
llvm::Type::TypeID
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::Function::ProfileCount
Class to represent profile counts.
Definition: Function.h:253
llvm::cl::desc
Definition: CommandLine.h:413
llvm::SetVector
A vector that has set insertion semantics.
Definition: SetVector.h:40
llvm::GlobalValue::isDSOLocal
bool isDSOLocal() const
Definition: GlobalValue.h:301
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::ArrayType::getElementType
Type * getElementType() const
Definition: DerivedTypes.h:370
llvm::findDevirtualizableCallsForTypeTest
void findDevirtualizableCallsForTypeTest(SmallVectorImpl< DevirtCallSite > &DevirtCalls, SmallVectorImpl< CallInst * > &Assumes, const CallInst *CI, DominatorTree &DT)
Given a call to the intrinsic @llvm.type.test, find all devirtualizable call sites based on the call ...
Definition: TypeMetadataUtils.cpp:74
SetVector.h
computeAliasSummary
static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A, DenseSet< GlobalValue::GUID > &CantBePromoted)
Definition: ModuleSummaryAnalysis.cpp:708
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:365
llvm::ModuleSymbolTable::CollectAsmSymbols
static void CollectAsmSymbols(const Module &M, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module.
Definition: ModuleSymbolTable.cpp:130