LLVM  14.0.0git
CloneFunction.cpp
Go to the documentation of this file.
1 //===- CloneFunction.cpp - Clone a function into another function ---------===//
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 CloneFunctionInto interface, which is used as the
10 // low-level function cloner. This is used by the CloneFunction and function
11 // inliner to do the dirty work of copying the body of a function around.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/ADT/SetVector.h"
16 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/Analysis/LoopInfo.h"
21 #include "llvm/IR/CFG.h"
22 #include "llvm/IR/Constants.h"
23 #include "llvm/IR/DebugInfo.h"
24 #include "llvm/IR/DerivedTypes.h"
25 #include "llvm/IR/Function.h"
26 #include "llvm/IR/GlobalVariable.h"
27 #include "llvm/IR/Instructions.h"
28 #include "llvm/IR/IntrinsicInst.h"
29 #include "llvm/IR/LLVMContext.h"
30 #include "llvm/IR/MDBuilder.h"
31 #include "llvm/IR/Metadata.h"
32 #include "llvm/IR/Module.h"
37 #include <map>
38 using namespace llvm;
39 
40 #define DEBUG_TYPE "clone-function"
41 
42 /// See comments in Cloning.h.
44  const Twine &NameSuffix, Function *F,
45  ClonedCodeInfo *CodeInfo,
46  DebugInfoFinder *DIFinder) {
47  BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), "", F);
48  if (BB->hasName())
49  NewBB->setName(BB->getName() + NameSuffix);
50 
51  bool hasCalls = false, hasDynamicAllocas = false;
52  Module *TheModule = F ? F->getParent() : nullptr;
53 
54  // Loop over all instructions, and copy them over.
55  for (const Instruction &I : *BB) {
56  if (DIFinder && TheModule)
57  DIFinder->processInstruction(*TheModule, I);
58 
59  Instruction *NewInst = I.clone();
60  if (I.hasName())
61  NewInst->setName(I.getName() + NameSuffix);
62  NewBB->getInstList().push_back(NewInst);
63  VMap[&I] = NewInst; // Add instruction map to value.
64 
65  hasCalls |= (isa<CallInst>(I) && !I.isDebugOrPseudoInst());
66  if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
67  if (!AI->isStaticAlloca()) {
68  hasDynamicAllocas = true;
69  }
70  }
71  }
72 
73  if (CodeInfo) {
74  CodeInfo->ContainsCalls |= hasCalls;
75  CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas;
76  }
77  return NewBB;
78 }
79 
80 // Clone OldFunc into NewFunc, transforming the old arguments into references to
81 // VMap values.
82 //
83 void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
84  ValueToValueMapTy &VMap,
87  const char *NameSuffix, ClonedCodeInfo *CodeInfo,
88  ValueMapTypeRemapper *TypeMapper,
89  ValueMaterializer *Materializer) {
90  assert(NameSuffix && "NameSuffix cannot be null!");
91 
92 #ifndef NDEBUG
93  for (const Argument &I : OldFunc->args())
94  assert(VMap.count(&I) && "No mapping from source argument specified!");
95 #endif
96 
97  bool ModuleLevelChanges = Changes > CloneFunctionChangeType::LocalChangesOnly;
98 
99  // Copy all attributes other than those stored in the AttributeList. We need
100  // to remap the parameter indices of the AttributeList.
101  AttributeList NewAttrs = NewFunc->getAttributes();
102  NewFunc->copyAttributesFrom(OldFunc);
103  NewFunc->setAttributes(NewAttrs);
104 
105  // Fix up the personality function that got copied over.
106  if (OldFunc->hasPersonalityFn())
107  NewFunc->setPersonalityFn(
108  MapValue(OldFunc->getPersonalityFn(), VMap,
109  ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
110  TypeMapper, Materializer));
111 
112  SmallVector<AttributeSet, 4> NewArgAttrs(NewFunc->arg_size());
113  AttributeList OldAttrs = OldFunc->getAttributes();
114 
115  // Clone any argument attributes that are present in the VMap.
116  for (const Argument &OldArg : OldFunc->args()) {
117  if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
118  NewArgAttrs[NewArg->getArgNo()] =
119  OldAttrs.getParamAttrs(OldArg.getArgNo());
120  }
121  }
122 
123  NewFunc->setAttributes(
124  AttributeList::get(NewFunc->getContext(), OldAttrs.getFnAttrs(),
125  OldAttrs.getRetAttrs(), NewArgAttrs));
126 
127  // Everything else beyond this point deals with function instructions,
128  // so if we are dealing with a function declaration, we're done.
129  if (OldFunc->isDeclaration())
130  return;
131 
132  // When we remap instructions within the same module, we want to avoid
133  // duplicating inlined DISubprograms, so record all subprograms we find as we
134  // duplicate instructions and then freeze them in the MD map. We also record
135  // information about dbg.value and dbg.declare to avoid duplicating the
136  // types.
137  Optional<DebugInfoFinder> DIFinder;
138 
139  // Track the subprogram attachment that needs to be cloned to fine-tune the
140  // mapping within the same module.
141  DISubprogram *SPClonedWithinModule = nullptr;
143  assert((NewFunc->getParent() == nullptr ||
144  NewFunc->getParent() == OldFunc->getParent()) &&
145  "Expected NewFunc to have the same parent, or no parent");
146 
147  // Need to find subprograms, types, and compile units.
148  DIFinder.emplace();
149 
150  SPClonedWithinModule = OldFunc->getSubprogram();
151  if (SPClonedWithinModule)
152  DIFinder->processSubprogram(SPClonedWithinModule);
153  } else {
154  assert((NewFunc->getParent() == nullptr ||
155  NewFunc->getParent() != OldFunc->getParent()) &&
156  "Expected NewFunc to have different parents, or no parent");
157 
159  assert(NewFunc->getParent() &&
160  "Need parent of new function to maintain debug info invariants");
161 
162  // Need to find all the compile units.
163  DIFinder.emplace();
164  }
165  }
166 
167  // Loop over all of the basic blocks in the function, cloning them as
168  // appropriate. Note that we save BE this way in order to handle cloning of
169  // recursive functions into themselves.
170  for (const BasicBlock &BB : *OldFunc) {
171 
172  // Create a new basic block and copy instructions into it!
173  BasicBlock *CBB = CloneBasicBlock(&BB, VMap, NameSuffix, NewFunc, CodeInfo,
174  DIFinder ? &*DIFinder : nullptr);
175 
176  // Add basic block mapping.
177  VMap[&BB] = CBB;
178 
179  // It is only legal to clone a function if a block address within that
180  // function is never referenced outside of the function. Given that, we
181  // want to map block addresses from the old function to block addresses in
182  // the clone. (This is different from the generic ValueMapper
183  // implementation, which generates an invalid blockaddress when
184  // cloning a function.)
185  if (BB.hasAddressTaken()) {
186  Constant *OldBBAddr = BlockAddress::get(const_cast<Function *>(OldFunc),
187  const_cast<BasicBlock *>(&BB));
188  VMap[OldBBAddr] = BlockAddress::get(NewFunc, CBB);
189  }
190 
191  // Note return instructions for the caller.
192  if (ReturnInst *RI = dyn_cast<ReturnInst>(CBB->getTerminator()))
193  Returns.push_back(RI);
194  }
195 
197  DIFinder->subprogram_count() > 0) {
198  // Turn on module-level changes, since we need to clone (some of) the
199  // debug info metadata.
200  //
201  // FIXME: Metadata effectively owned by a function should be made
202  // local, and only that local metadata should be cloned.
203  ModuleLevelChanges = true;
204 
205  auto mapToSelfIfNew = [&VMap](MDNode *N) {
206  // Avoid clobbering an existing mapping.
207  (void)VMap.MD().try_emplace(N, N);
208  };
209 
210  // Avoid cloning types, compile units, and (other) subprograms.
211  for (DISubprogram *ISP : DIFinder->subprograms())
212  if (ISP != SPClonedWithinModule)
213  mapToSelfIfNew(ISP);
214 
215  for (DICompileUnit *CU : DIFinder->compile_units())
216  mapToSelfIfNew(CU);
217 
218  for (DIType *Type : DIFinder->types())
219  mapToSelfIfNew(Type);
220  } else {
221  assert(!SPClonedWithinModule &&
222  "Subprogram should be in DIFinder->subprogram_count()...");
223  }
224 
225  const auto RemapFlag = ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges;
226  // Duplicate the metadata that is attached to the cloned function.
227  // Subprograms/CUs/types that were already mapped to themselves won't be
228  // duplicated.
230  OldFunc->getAllMetadata(MDs);
231  for (auto MD : MDs) {
232  NewFunc->addMetadata(MD.first, *MapMetadata(MD.second, VMap, RemapFlag,
233  TypeMapper, Materializer));
234  }
235 
236  // Loop over all of the instructions in the new function, fixing up operand
237  // references as we go. This uses VMap to do all the hard work.
238  for (Function::iterator
239  BB = cast<BasicBlock>(VMap[&OldFunc->front()])->getIterator(),
240  BE = NewFunc->end();
241  BB != BE; ++BB)
242  // Loop over all instructions, fixing each one as we find it...
243  for (Instruction &II : *BB)
244  RemapInstruction(&II, VMap, RemapFlag, TypeMapper, Materializer);
245 
246  // Only update !llvm.dbg.cu for DifferentModule (not CloneModule). In the
247  // same module, the compile unit will already be listed (or not). When
248  // cloning a module, CloneModule() will handle creating the named metadata.
250  return;
251 
252  // Update !llvm.dbg.cu with compile units added to the new module if this
253  // function is being cloned in isolation.
254  //
255  // FIXME: This is making global / module-level changes, which doesn't seem
256  // like the right encapsulation Consider dropping the requirement to update
257  // !llvm.dbg.cu (either obsoleting the node, or restricting it to
258  // non-discardable compile units) instead of discovering compile units by
259  // visiting the metadata attached to global values, which would allow this
260  // code to be deleted. Alternatively, perhaps give responsibility for this
261  // update to CloneFunctionInto's callers.
262  auto *NewModule = NewFunc->getParent();
263  auto *NMD = NewModule->getOrInsertNamedMetadata("llvm.dbg.cu");
264  // Avoid multiple insertions of the same DICompileUnit to NMD.
266  for (auto *Operand : NMD->operands())
267  Visited.insert(Operand);
268  for (auto *Unit : DIFinder->compile_units()) {
269  MDNode *MappedUnit =
270  MapMetadata(Unit, VMap, RF_None, TypeMapper, Materializer);
271  if (Visited.insert(MappedUnit).second)
272  NMD->addOperand(MappedUnit);
273  }
274 }
275 
276 /// Return a copy of the specified function and add it to that function's
277 /// module. Also, any references specified in the VMap are changed to refer to
278 /// their mapped value instead of the original one. If any of the arguments to
279 /// the function are in the VMap, the arguments are deleted from the resultant
280 /// function. The VMap is updated to include mappings from all of the
281 /// instructions and basicblocks in the function from their old to new values.
282 ///
284  ClonedCodeInfo *CodeInfo) {
285  std::vector<Type *> ArgTypes;
286 
287  // The user might be deleting arguments to the function by specifying them in
288  // the VMap. If so, we need to not add the arguments to the arg ty vector
289  //
290  for (const Argument &I : F->args())
291  if (VMap.count(&I) == 0) // Haven't mapped the argument to anything yet?
292  ArgTypes.push_back(I.getType());
293 
294  // Create a new function type...
295  FunctionType *FTy =
296  FunctionType::get(F->getFunctionType()->getReturnType(), ArgTypes,
297  F->getFunctionType()->isVarArg());
298 
299  // Create the new function...
300  Function *NewF = Function::Create(FTy, F->getLinkage(), F->getAddressSpace(),
301  F->getName(), F->getParent());
302 
303  // Loop over the arguments, copying the names of the mapped arguments over...
304  Function::arg_iterator DestI = NewF->arg_begin();
305  for (const Argument &I : F->args())
306  if (VMap.count(&I) == 0) { // Is this argument preserved?
307  DestI->setName(I.getName()); // Copy the name over...
308  VMap[&I] = &*DestI++; // Add mapping to VMap
309  }
310 
311  SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned.
313  Returns, "", CodeInfo);
314 
315  return NewF;
316 }
317 
318 namespace {
319 /// This is a private class used to implement CloneAndPruneFunctionInto.
320 struct PruningFunctionCloner {
321  Function *NewFunc;
322  const Function *OldFunc;
323  ValueToValueMapTy &VMap;
324  bool ModuleLevelChanges;
325  const char *NameSuffix;
326  ClonedCodeInfo *CodeInfo;
327 
328 public:
329  PruningFunctionCloner(Function *newFunc, const Function *oldFunc,
330  ValueToValueMapTy &valueMap, bool moduleLevelChanges,
331  const char *nameSuffix, ClonedCodeInfo *codeInfo)
332  : NewFunc(newFunc), OldFunc(oldFunc), VMap(valueMap),
333  ModuleLevelChanges(moduleLevelChanges), NameSuffix(nameSuffix),
334  CodeInfo(codeInfo) {}
335 
336  /// The specified block is found to be reachable, clone it and
337  /// anything that it can reach.
338  void CloneBlock(const BasicBlock *BB, BasicBlock::const_iterator StartingInst,
339  std::vector<const BasicBlock *> &ToClone);
340 };
341 } // namespace
342 
343 /// The specified block is found to be reachable, clone it and
344 /// anything that it can reach.
345 void PruningFunctionCloner::CloneBlock(
346  const BasicBlock *BB, BasicBlock::const_iterator StartingInst,
347  std::vector<const BasicBlock *> &ToClone) {
348  WeakTrackingVH &BBEntry = VMap[BB];
349 
350  // Have we already cloned this block?
351  if (BBEntry)
352  return;
353 
354  // Nope, clone it now.
355  BasicBlock *NewBB;
356  BBEntry = NewBB = BasicBlock::Create(BB->getContext());
357  if (BB->hasName())
358  NewBB->setName(BB->getName() + NameSuffix);
359 
360  // It is only legal to clone a function if a block address within that
361  // function is never referenced outside of the function. Given that, we
362  // want to map block addresses from the old function to block addresses in
363  // the clone. (This is different from the generic ValueMapper
364  // implementation, which generates an invalid blockaddress when
365  // cloning a function.)
366  //
367  // Note that we don't need to fix the mapping for unreachable blocks;
368  // the default mapping there is safe.
369  if (BB->hasAddressTaken()) {
370  Constant *OldBBAddr = BlockAddress::get(const_cast<Function *>(OldFunc),
371  const_cast<BasicBlock *>(BB));
372  VMap[OldBBAddr] = BlockAddress::get(NewFunc, NewBB);
373  }
374 
375  bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
376 
377  // Loop over all instructions, and copy them over, DCE'ing as we go. This
378  // loop doesn't include the terminator.
379  for (BasicBlock::const_iterator II = StartingInst, IE = --BB->end(); II != IE;
380  ++II) {
381 
382  Instruction *NewInst = II->clone();
383 
384  // Eagerly remap operands to the newly cloned instruction, except for PHI
385  // nodes for which we defer processing until we update the CFG.
386  if (!isa<PHINode>(NewInst)) {
387  RemapInstruction(NewInst, VMap,
388  ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
389 
390  // If we can simplify this instruction to some other value, simply add
391  // a mapping to that value rather than inserting a new instruction into
392  // the basic block.
393  if (Value *V =
394  SimplifyInstruction(NewInst, BB->getModule()->getDataLayout())) {
395  // On the off-chance that this simplifies to an instruction in the old
396  // function, map it back into the new function.
397  if (NewFunc != OldFunc)
398  if (Value *MappedV = VMap.lookup(V))
399  V = MappedV;
400 
401  if (!NewInst->mayHaveSideEffects()) {
402  VMap[&*II] = V;
403  NewInst->deleteValue();
404  continue;
405  }
406  }
407  }
408 
409  if (II->hasName())
410  NewInst->setName(II->getName() + NameSuffix);
411  VMap[&*II] = NewInst; // Add instruction map to value.
412  NewBB->getInstList().push_back(NewInst);
413  hasCalls |= (isa<CallInst>(II) && !II->isDebugOrPseudoInst());
414 
415  if (CodeInfo) {
416  CodeInfo->OrigVMap[&*II] = NewInst;
417  if (auto *CB = dyn_cast<CallBase>(&*II))
418  if (CB->hasOperandBundles())
419  CodeInfo->OperandBundleCallSites.push_back(NewInst);
420  }
421 
422  if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
423  if (isa<ConstantInt>(AI->getArraySize()))
424  hasStaticAllocas = true;
425  else
426  hasDynamicAllocas = true;
427  }
428  }
429 
430  // Finally, clone over the terminator.
431  const Instruction *OldTI = BB->getTerminator();
432  bool TerminatorDone = false;
433  if (const BranchInst *BI = dyn_cast<BranchInst>(OldTI)) {
434  if (BI->isConditional()) {
435  // If the condition was a known constant in the callee...
436  ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition());
437  // Or is a known constant in the caller...
438  if (!Cond) {
439  Value *V = VMap.lookup(BI->getCondition());
440  Cond = dyn_cast_or_null<ConstantInt>(V);
441  }
442 
443  // Constant fold to uncond branch!
444  if (Cond) {
445  BasicBlock *Dest = BI->getSuccessor(!Cond->getZExtValue());
446  VMap[OldTI] = BranchInst::Create(Dest, NewBB);
447  ToClone.push_back(Dest);
448  TerminatorDone = true;
449  }
450  }
451  } else if (const SwitchInst *SI = dyn_cast<SwitchInst>(OldTI)) {
452  // If switching on a value known constant in the caller.
453  ConstantInt *Cond = dyn_cast<ConstantInt>(SI->getCondition());
454  if (!Cond) { // Or known constant after constant prop in the callee...
455  Value *V = VMap.lookup(SI->getCondition());
456  Cond = dyn_cast_or_null<ConstantInt>(V);
457  }
458  if (Cond) { // Constant fold to uncond branch!
459  SwitchInst::ConstCaseHandle Case = *SI->findCaseValue(Cond);
460  BasicBlock *Dest = const_cast<BasicBlock *>(Case.getCaseSuccessor());
461  VMap[OldTI] = BranchInst::Create(Dest, NewBB);
462  ToClone.push_back(Dest);
463  TerminatorDone = true;
464  }
465  }
466 
467  if (!TerminatorDone) {
468  Instruction *NewInst = OldTI->clone();
469  if (OldTI->hasName())
470  NewInst->setName(OldTI->getName() + NameSuffix);
471  NewBB->getInstList().push_back(NewInst);
472  VMap[OldTI] = NewInst; // Add instruction map to value.
473 
474  if (CodeInfo) {
475  CodeInfo->OrigVMap[OldTI] = NewInst;
476  if (auto *CB = dyn_cast<CallBase>(OldTI))
477  if (CB->hasOperandBundles())
478  CodeInfo->OperandBundleCallSites.push_back(NewInst);
479  }
480 
481  // Recursively clone any reachable successor blocks.
482  append_range(ToClone, successors(BB->getTerminator()));
483  }
484 
485  if (CodeInfo) {
486  CodeInfo->ContainsCalls |= hasCalls;
487  CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas;
488  CodeInfo->ContainsDynamicAllocas |=
489  hasStaticAllocas && BB != &BB->getParent()->front();
490  }
491 }
492 
493 /// This works like CloneAndPruneFunctionInto, except that it does not clone the
494 /// entire function. Instead it starts at an instruction provided by the caller
495 /// and copies (and prunes) only the code reachable from that instruction.
496 void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
497  const Instruction *StartingInst,
498  ValueToValueMapTy &VMap,
499  bool ModuleLevelChanges,
501  const char *NameSuffix,
502  ClonedCodeInfo *CodeInfo) {
503  assert(NameSuffix && "NameSuffix cannot be null!");
504 
505  ValueMapTypeRemapper *TypeMapper = nullptr;
506  ValueMaterializer *Materializer = nullptr;
507 
508 #ifndef NDEBUG
509  // If the cloning starts at the beginning of the function, verify that
510  // the function arguments are mapped.
511  if (!StartingInst)
512  for (const Argument &II : OldFunc->args())
513  assert(VMap.count(&II) && "No mapping from source argument specified!");
514 #endif
515 
516  PruningFunctionCloner PFC(NewFunc, OldFunc, VMap, ModuleLevelChanges,
517  NameSuffix, CodeInfo);
518  const BasicBlock *StartingBB;
519  if (StartingInst)
520  StartingBB = StartingInst->getParent();
521  else {
522  StartingBB = &OldFunc->getEntryBlock();
523  StartingInst = &StartingBB->front();
524  }
525 
526  // Clone the entry block, and anything recursively reachable from it.
527  std::vector<const BasicBlock *> CloneWorklist;
528  PFC.CloneBlock(StartingBB, StartingInst->getIterator(), CloneWorklist);
529  while (!CloneWorklist.empty()) {
530  const BasicBlock *BB = CloneWorklist.back();
531  CloneWorklist.pop_back();
532  PFC.CloneBlock(BB, BB->begin(), CloneWorklist);
533  }
534 
535  // Loop over all of the basic blocks in the old function. If the block was
536  // reachable, we have cloned it and the old block is now in the value map:
537  // insert it into the new function in the right order. If not, ignore it.
538  //
539  // Defer PHI resolution until rest of function is resolved.
541  for (const BasicBlock &BI : *OldFunc) {
542  Value *V = VMap.lookup(&BI);
543  BasicBlock *NewBB = cast_or_null<BasicBlock>(V);
544  if (!NewBB)
545  continue; // Dead block.
546 
547  // Add the new block to the new function.
548  NewFunc->getBasicBlockList().push_back(NewBB);
549 
550  // Handle PHI nodes specially, as we have to remove references to dead
551  // blocks.
552  for (const PHINode &PN : BI.phis()) {
553  // PHI nodes may have been remapped to non-PHI nodes by the caller or
554  // during the cloning process.
555  if (isa<PHINode>(VMap[&PN]))
556  PHIToResolve.push_back(&PN);
557  else
558  break;
559  }
560 
561  // Finally, remap the terminator instructions, as those can't be remapped
562  // until all BBs are mapped.
563  RemapInstruction(NewBB->getTerminator(), VMap,
564  ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
565  TypeMapper, Materializer);
566  }
567 
568  // Defer PHI resolution until rest of function is resolved, PHI resolution
569  // requires the CFG to be up-to-date.
570  for (unsigned phino = 0, e = PHIToResolve.size(); phino != e;) {
571  const PHINode *OPN = PHIToResolve[phino];
572  unsigned NumPreds = OPN->getNumIncomingValues();
573  const BasicBlock *OldBB = OPN->getParent();
574  BasicBlock *NewBB = cast<BasicBlock>(VMap[OldBB]);
575 
576  // Map operands for blocks that are live and remove operands for blocks
577  // that are dead.
578  for (; phino != PHIToResolve.size() &&
579  PHIToResolve[phino]->getParent() == OldBB;
580  ++phino) {
581  OPN = PHIToResolve[phino];
582  PHINode *PN = cast<PHINode>(VMap[OPN]);
583  for (unsigned pred = 0, e = NumPreds; pred != e; ++pred) {
584  Value *V = VMap.lookup(PN->getIncomingBlock(pred));
585  if (BasicBlock *MappedBlock = cast_or_null<BasicBlock>(V)) {
586  Value *InVal =
587  MapValue(PN->getIncomingValue(pred), VMap,
588  ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
589  assert(InVal && "Unknown input value?");
590  PN->setIncomingValue(pred, InVal);
591  PN->setIncomingBlock(pred, MappedBlock);
592  } else {
593  PN->removeIncomingValue(pred, false);
594  --pred; // Revisit the next entry.
595  --e;
596  }
597  }
598  }
599 
600  // The loop above has removed PHI entries for those blocks that are dead
601  // and has updated others. However, if a block is live (i.e. copied over)
602  // but its terminator has been changed to not go to this block, then our
603  // phi nodes will have invalid entries. Update the PHI nodes in this
604  // case.
605  PHINode *PN = cast<PHINode>(NewBB->begin());
606  NumPreds = pred_size(NewBB);
607  if (NumPreds != PN->getNumIncomingValues()) {
608  assert(NumPreds < PN->getNumIncomingValues());
609  // Count how many times each predecessor comes to this block.
610  std::map<BasicBlock *, unsigned> PredCount;
611  for (BasicBlock *Pred : predecessors(NewBB))
612  --PredCount[Pred];
613 
614  // Figure out how many entries to remove from each PHI.
615  for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
616  ++PredCount[PN->getIncomingBlock(i)];
617 
618  // At this point, the excess predecessor entries are positive in the
619  // map. Loop over all of the PHIs and remove excess predecessor
620  // entries.
621  BasicBlock::iterator I = NewBB->begin();
622  for (; (PN = dyn_cast<PHINode>(I)); ++I) {
623  for (const auto &PCI : PredCount) {
624  BasicBlock *Pred = PCI.first;
625  for (unsigned NumToRemove = PCI.second; NumToRemove; --NumToRemove)
626  PN->removeIncomingValue(Pred, false);
627  }
628  }
629  }
630 
631  // If the loops above have made these phi nodes have 0 or 1 operand,
632  // replace them with undef or the input value. We must do this for
633  // correctness, because 0-operand phis are not valid.
634  PN = cast<PHINode>(NewBB->begin());
635  if (PN->getNumIncomingValues() == 0) {
636  BasicBlock::iterator I = NewBB->begin();
637  BasicBlock::const_iterator OldI = OldBB->begin();
638  while ((PN = dyn_cast<PHINode>(I++))) {
639  Value *NV = UndefValue::get(PN->getType());
640  PN->replaceAllUsesWith(NV);
641  assert(VMap[&*OldI] == PN && "VMap mismatch");
642  VMap[&*OldI] = NV;
643  PN->eraseFromParent();
644  ++OldI;
645  }
646  }
647  }
648 
649  // Make a second pass over the PHINodes now that all of them have been
650  // remapped into the new function, simplifying the PHINode and performing any
651  // recursive simplifications exposed. This will transparently update the
652  // WeakTrackingVH in the VMap. Notably, we rely on that so that if we coalesce
653  // two PHINodes, the iteration over the old PHIs remains valid, and the
654  // mapping will just map us to the new node (which may not even be a PHI
655  // node).
656  const DataLayout &DL = NewFunc->getParent()->getDataLayout();
658  for (unsigned Idx = 0, Size = PHIToResolve.size(); Idx != Size; ++Idx)
659  if (isa<PHINode>(VMap[PHIToResolve[Idx]]))
660  Worklist.insert(PHIToResolve[Idx]);
661 
662  // Note that we must test the size on each iteration, the worklist can grow.
663  for (unsigned Idx = 0; Idx != Worklist.size(); ++Idx) {
664  const Value *OrigV = Worklist[Idx];
665  auto *I = dyn_cast_or_null<Instruction>(VMap.lookup(OrigV));
666  if (!I)
667  continue;
668 
669  // Skip over non-intrinsic callsites, we don't want to remove any nodes from
670  // the CGSCC.
671  CallBase *CB = dyn_cast<CallBase>(I);
672  if (CB && CB->getCalledFunction() &&
673  !CB->getCalledFunction()->isIntrinsic())
674  continue;
675 
676  // See if this instruction simplifies.
677  Value *SimpleV = SimplifyInstruction(I, DL);
678  if (!SimpleV)
679  continue;
680 
681  // Stash away all the uses of the old instruction so we can check them for
682  // recursive simplifications after a RAUW. This is cheaper than checking all
683  // uses of To on the recursive step in most cases.
684  for (const User *U : OrigV->users())
685  Worklist.insert(cast<Instruction>(U));
686 
687  // Replace the instruction with its simplified value.
688  I->replaceAllUsesWith(SimpleV);
689 
690  // If the original instruction had no side effects, remove it.
692  I->eraseFromParent();
693  else
694  VMap[OrigV] = I;
695  }
696 
697  // Now that the inlined function body has been fully constructed, go through
698  // and zap unconditional fall-through branches. This happens all the time when
699  // specializing code: code specialization turns conditional branches into
700  // uncond branches, and this code folds them.
701  Function::iterator Begin = cast<BasicBlock>(VMap[StartingBB])->getIterator();
702  Function::iterator I = Begin;
703  while (I != NewFunc->end()) {
704  // We need to simplify conditional branches and switches with a constant
705  // operand. We try to prune these out when cloning, but if the
706  // simplification required looking through PHI nodes, those are only
707  // available after forming the full basic block. That may leave some here,
708  // and we still want to prune the dead code as early as possible.
709  //
710  // Do the folding before we check if the block is dead since we want code
711  // like
712  // bb:
713  // br i1 undef, label %bb, label %bb
714  // to be simplified to
715  // bb:
716  // br label %bb
717  // before we call I->getSinglePredecessor().
719 
720  // Check if this block has become dead during inlining or other
721  // simplifications. Note that the first block will appear dead, as it has
722  // not yet been wired up properly.
723  if (I != Begin && (pred_empty(&*I) || I->getSinglePredecessor() == &*I)) {
724  BasicBlock *DeadBB = &*I++;
725  DeleteDeadBlock(DeadBB);
726  continue;
727  }
728 
729  BranchInst *BI = dyn_cast<BranchInst>(I->getTerminator());
730  if (!BI || BI->isConditional()) {
731  ++I;
732  continue;
733  }
734 
735  BasicBlock *Dest = BI->getSuccessor(0);
736  if (!Dest->getSinglePredecessor()) {
737  ++I;
738  continue;
739  }
740 
741  // We shouldn't be able to get single-entry PHI nodes here, as instsimplify
742  // above should have zapped all of them..
743  assert(!isa<PHINode>(Dest->begin()));
744 
745  // We know all single-entry PHI nodes in the inlined function have been
746  // removed, so we just need to splice the blocks.
747  BI->eraseFromParent();
748 
749  // Make all PHI nodes that referred to Dest now refer to I as their source.
750  Dest->replaceAllUsesWith(&*I);
751 
752  // Move all the instructions in the succ to the pred.
753  I->getInstList().splice(I->end(), Dest->getInstList());
754 
755  // Remove the dest block.
756  Dest->eraseFromParent();
757 
758  // Do not increment I, iteratively merge all things this block branches to.
759  }
760 
761  // Make a final pass over the basic blocks from the old function to gather
762  // any return instructions which survived folding. We have to do this here
763  // because we can iteratively remove and merge returns above.
764  for (Function::iterator I = cast<BasicBlock>(VMap[StartingBB])->getIterator(),
765  E = NewFunc->end();
766  I != E; ++I)
767  if (ReturnInst *RI = dyn_cast<ReturnInst>(I->getTerminator()))
768  Returns.push_back(RI);
769 }
770 
771 /// This works exactly like CloneFunctionInto,
772 /// except that it does some simple constant prop and DCE on the fly. The
773 /// effect of this is to copy significantly less code in cases where (for
774 /// example) a function call with constant arguments is inlined, and those
775 /// constant arguments cause a significant amount of code in the callee to be
776 /// dead. Since this doesn't produce an exact copy of the input, it can't be
777 /// used for things like CloneFunction or CloneModule.
779  Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap,
780  bool ModuleLevelChanges, SmallVectorImpl<ReturnInst *> &Returns,
781  const char *NameSuffix, ClonedCodeInfo *CodeInfo) {
782  CloneAndPruneIntoFromInst(NewFunc, OldFunc, &OldFunc->front().front(), VMap,
783  ModuleLevelChanges, Returns, NameSuffix, CodeInfo);
784 }
785 
786 /// Remaps instructions in \p Blocks using the mapping in \p VMap.
788  const SmallVectorImpl<BasicBlock *> &Blocks, ValueToValueMapTy &VMap) {
789  // Rewrite the code to refer to itself.
790  for (auto *BB : Blocks)
791  for (auto &Inst : *BB)
792  RemapInstruction(&Inst, VMap,
794 }
795 
796 /// Clones a loop \p OrigLoop. Returns the loop and the blocks in \p
797 /// Blocks.
798 ///
799 /// Updates LoopInfo and DominatorTree assuming the loop is dominated by block
800 /// \p LoopDomBB. Insert the new blocks before block specified in \p Before.
802  Loop *OrigLoop, ValueToValueMapTy &VMap,
803  const Twine &NameSuffix, LoopInfo *LI,
804  DominatorTree *DT,
806  Function *F = OrigLoop->getHeader()->getParent();
807  Loop *ParentLoop = OrigLoop->getParentLoop();
809 
810  Loop *NewLoop = LI->AllocateLoop();
811  LMap[OrigLoop] = NewLoop;
812  if (ParentLoop)
813  ParentLoop->addChildLoop(NewLoop);
814  else
815  LI->addTopLevelLoop(NewLoop);
816 
817  BasicBlock *OrigPH = OrigLoop->getLoopPreheader();
818  assert(OrigPH && "No preheader");
819  BasicBlock *NewPH = CloneBasicBlock(OrigPH, VMap, NameSuffix, F);
820  // To rename the loop PHIs.
821  VMap[OrigPH] = NewPH;
822  Blocks.push_back(NewPH);
823 
824  // Update LoopInfo.
825  if (ParentLoop)
826  ParentLoop->addBasicBlockToLoop(NewPH, *LI);
827 
828  // Update DominatorTree.
829  DT->addNewBlock(NewPH, LoopDomBB);
830 
831  for (Loop *CurLoop : OrigLoop->getLoopsInPreorder()) {
832  Loop *&NewLoop = LMap[CurLoop];
833  if (!NewLoop) {
834  NewLoop = LI->AllocateLoop();
835 
836  // Establish the parent/child relationship.
837  Loop *OrigParent = CurLoop->getParentLoop();
838  assert(OrigParent && "Could not find the original parent loop");
839  Loop *NewParentLoop = LMap[OrigParent];
840  assert(NewParentLoop && "Could not find the new parent loop");
841 
842  NewParentLoop->addChildLoop(NewLoop);
843  }
844  }
845 
846  for (BasicBlock *BB : OrigLoop->getBlocks()) {
847  Loop *CurLoop = LI->getLoopFor(BB);
848  Loop *&NewLoop = LMap[CurLoop];
849  assert(NewLoop && "Expecting new loop to be allocated");
850 
851  BasicBlock *NewBB = CloneBasicBlock(BB, VMap, NameSuffix, F);
852  VMap[BB] = NewBB;
853 
854  // Update LoopInfo.
855  NewLoop->addBasicBlockToLoop(NewBB, *LI);
856 
857  // Add DominatorTree node. After seeing all blocks, update to correct
858  // IDom.
859  DT->addNewBlock(NewBB, NewPH);
860 
861  Blocks.push_back(NewBB);
862  }
863 
864  for (BasicBlock *BB : OrigLoop->getBlocks()) {
865  // Update loop headers.
866  Loop *CurLoop = LI->getLoopFor(BB);
867  if (BB == CurLoop->getHeader())
868  LMap[CurLoop]->moveToHeader(cast<BasicBlock>(VMap[BB]));
869 
870  // Update DominatorTree.
871  BasicBlock *IDomBB = DT->getNode(BB)->getIDom()->getBlock();
872  DT->changeImmediateDominator(cast<BasicBlock>(VMap[BB]),
873  cast<BasicBlock>(VMap[IDomBB]));
874  }
875 
876  // Move them physically from the end of the block list.
877  F->getBasicBlockList().splice(Before->getIterator(), F->getBasicBlockList(),
878  NewPH);
879  F->getBasicBlockList().splice(Before->getIterator(), F->getBasicBlockList(),
880  NewLoop->getHeader()->getIterator(), F->end());
881 
882  return NewLoop;
883 }
884 
885 /// Duplicate non-Phi instructions from the beginning of block up to
886 /// StopAt instruction into a split block between BB and its predecessor.
888  BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt,
889  ValueToValueMapTy &ValueMapping, DomTreeUpdater &DTU) {
890 
891  assert(count(successors(PredBB), BB) == 1 &&
892  "There must be a single edge between PredBB and BB!");
893  // We are going to have to map operands from the original BB block to the new
894  // copy of the block 'NewBB'. If there are PHI nodes in BB, evaluate them to
895  // account for entry from PredBB.
896  BasicBlock::iterator BI = BB->begin();
897  for (; PHINode *PN = dyn_cast<PHINode>(BI); ++BI)
898  ValueMapping[PN] = PN->getIncomingValueForBlock(PredBB);
899 
900  BasicBlock *NewBB = SplitEdge(PredBB, BB);
901  NewBB->setName(PredBB->getName() + ".split");
902  Instruction *NewTerm = NewBB->getTerminator();
903 
904  // FIXME: SplitEdge does not yet take a DTU, so we include the split edge
905  // in the update set here.
906  DTU.applyUpdates({{DominatorTree::Delete, PredBB, BB},
907  {DominatorTree::Insert, PredBB, NewBB},
908  {DominatorTree::Insert, NewBB, BB}});
909 
910  // Clone the non-phi instructions of BB into NewBB, keeping track of the
911  // mapping and using it to remap operands in the cloned instructions.
912  // Stop once we see the terminator too. This covers the case where BB's
913  // terminator gets replaced and StopAt == BB's terminator.
914  for (; StopAt != &*BI && BB->getTerminator() != &*BI; ++BI) {
915  Instruction *New = BI->clone();
916  New->setName(BI->getName());
917  New->insertBefore(NewTerm);
918  ValueMapping[&*BI] = New;
919 
920  // Remap operands to patch up intra-block references.
921  for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i)
922  if (Instruction *Inst = dyn_cast<Instruction>(New->getOperand(i))) {
923  auto I = ValueMapping.find(Inst);
924  if (I != ValueMapping.end())
925  New->setOperand(i, I->second);
926  }
927  }
928 
929  return NewBB;
930 }
931 
933  DenseMap<MDNode *, MDNode *> &ClonedScopes,
935  MDBuilder MDB(Context);
936 
937  for (auto *ScopeList : NoAliasDeclScopes) {
938  for (auto &MDOperand : ScopeList->operands()) {
939  if (MDNode *MD = dyn_cast<MDNode>(MDOperand)) {
940  AliasScopeNode SNANode(MD);
941 
942  std::string Name;
943  auto ScopeName = SNANode.getName();
944  if (!ScopeName.empty())
945  Name = (Twine(ScopeName) + ":" + Ext).str();
946  else
947  Name = std::string(Ext);
948 
949  MDNode *NewScope = MDB.createAnonymousAliasScope(
950  const_cast<MDNode *>(SNANode.getDomain()), Name);
951  ClonedScopes.insert(std::make_pair(MD, NewScope));
952  }
953  }
954  }
955 }
956 
958  const DenseMap<MDNode *, MDNode *> &ClonedScopes,
959  LLVMContext &Context) {
960  auto CloneScopeList = [&](const MDNode *ScopeList) -> MDNode * {
961  bool NeedsReplacement = false;
962  SmallVector<Metadata *, 8> NewScopeList;
963  for (auto &MDOp : ScopeList->operands()) {
964  if (MDNode *MD = dyn_cast<MDNode>(MDOp)) {
965  if (auto *NewMD = ClonedScopes.lookup(MD)) {
966  NewScopeList.push_back(NewMD);
967  NeedsReplacement = true;
968  continue;
969  }
970  NewScopeList.push_back(MD);
971  }
972  }
973  if (NeedsReplacement)
974  return MDNode::get(Context, NewScopeList);
975  return nullptr;
976  };
977 
978  if (auto *Decl = dyn_cast<NoAliasScopeDeclInst>(I))
979  if (auto *NewScopeList = CloneScopeList(Decl->getScopeList()))
980  Decl->setScopeList(NewScopeList);
981 
982  auto replaceWhenNeeded = [&](unsigned MD_ID) {
983  if (const MDNode *CSNoAlias = I->getMetadata(MD_ID))
984  if (auto *NewScopeList = CloneScopeList(CSNoAlias))
985  I->setMetadata(MD_ID, NewScopeList);
986  };
987  replaceWhenNeeded(LLVMContext::MD_noalias);
988  replaceWhenNeeded(LLVMContext::MD_alias_scope);
989 }
990 
992  ArrayRef<BasicBlock *> NewBlocks,
994  if (NoAliasDeclScopes.empty())
995  return;
996 
997  DenseMap<MDNode *, MDNode *> ClonedScopes;
998  LLVM_DEBUG(dbgs() << "cloneAndAdaptNoAliasScopes: cloning "
999  << NoAliasDeclScopes.size() << " node(s)\n");
1000 
1001  cloneNoAliasScopes(NoAliasDeclScopes, ClonedScopes, Ext, Context);
1002  // Identify instructions using metadata that needs adaptation
1003  for (BasicBlock *NewBlock : NewBlocks)
1004  for (Instruction &I : *NewBlock)
1005  adaptNoAliasScopes(&I, ClonedScopes, Context);
1006 }
1007 
1009  Instruction *IStart, Instruction *IEnd,
1011  if (NoAliasDeclScopes.empty())
1012  return;
1013 
1014  DenseMap<MDNode *, MDNode *> ClonedScopes;
1015  LLVM_DEBUG(dbgs() << "cloneAndAdaptNoAliasScopes: cloning "
1016  << NoAliasDeclScopes.size() << " node(s)\n");
1017 
1018  cloneNoAliasScopes(NoAliasDeclScopes, ClonedScopes, Ext, Context);
1019  // Identify instructions using metadata that needs adaptation
1020  assert(IStart->getParent() == IEnd->getParent() && "different basic block ?");
1021  auto ItStart = IStart->getIterator();
1022  auto ItEnd = IEnd->getIterator();
1023  ++ItEnd; // IEnd is included, increment ItEnd to get the end of the range
1024  for (auto &I : llvm::make_range(ItStart, ItEnd))
1025  adaptNoAliasScopes(&I, ClonedScopes, Context);
1026 }
1027 
1029  ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes) {
1030  for (BasicBlock *BB : BBs)
1031  for (Instruction &I : *BB)
1032  if (auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&I))
1033  NoAliasDeclScopes.push_back(Decl->getScopeList());
1034 }
1035 
1038  SmallVectorImpl<MDNode *> &NoAliasDeclScopes) {
1039  for (Instruction &I : make_range(Start, End))
1040  if (auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&I))
1041  NoAliasDeclScopes.push_back(Decl->getScopeList());
1042 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
i
i
Definition: README.txt:29
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
llvm::RF_None
@ RF_None
Definition: ValueMapper.h:66
llvm::predecessors
pred_range predecessors(BasicBlock *BB)
Definition: CFG.h:127
llvm::Function::isIntrinsic
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Definition: Function.h:212
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::DIType
Base class for types.
Definition: DebugInfoMetadata.h:662
llvm::Function::args
iterator_range< arg_iterator > args()
Definition: Function.h:773
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::ReturnInst
Return a value (possibly void), from a function.
Definition: Instructions.h:2986
llvm::ClonedCodeInfo
This struct can be used to capture information about code being cloned, while it is being cloned.
Definition: Cloning.h:64
llvm::WeakTrackingVH
Value handle that is nullable, but tries to track the Value.
Definition: ValueHandle.h:204
ValueMapper.h
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
Metadata.h
llvm::MapMetadata
Metadata * MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Lookup or compute a mapping for a piece of metadata.
Definition: ValueMapper.h:231
llvm::Function::end
iterator end()
Definition: Function.h:736
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:90
llvm::cloneLoopWithPreheader
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
Definition: CloneFunction.cpp:801
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
IntrinsicInst.h
llvm::ValueMap::end
iterator end()
Definition: ValueMap.h:136
llvm::Function::getBasicBlockList
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Definition: Function.h:711
llvm::DomTreeUpdater::applyUpdates
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Definition: DomTreeUpdater.cpp:230
llvm::Function
Definition: Function.h:62
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::lookup
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:197
llvm::SetVector< T, SmallVector< T, N >, SmallDenseSet< T, N > >::size
size_type size() const
Determine the number of elements in the SetVector.
Definition: SetVector.h:77
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::SwitchInst::CaseHandleImpl
A handle to a particular switch case.
Definition: Instructions.h:3261
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition: Metadata.cpp:1541
llvm::Value::hasName
bool hasName() const
Definition: Value.h:261
llvm::Function::getEntryBlock
const BasicBlock & getEntryBlock() const
Definition: Function.h:718
DomTreeUpdater.h
llvm::PHINode::removeIncomingValue
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
Definition: Instructions.cpp:113
llvm::FunctionType::get
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:363
Local.h
llvm::AttributeList::get
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
Definition: Attributes.cpp:1011
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
llvm::MapValue
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Look up or compute a value in the value map.
Definition: ValueMapper.h:209
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:321
llvm::Function::arg_size
size_t arg_size() const
Definition: Function.h:782
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::CloneFunctionChangeType::DifferentModule
@ DifferentModule
Module.h
llvm::BasicBlock::eraseFromParent
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Definition: BasicBlock.cpp:133
llvm::AttributeList
Definition: Attributes.h:399
llvm::DominatorTreeBase< BasicBlock, false >::Insert
static constexpr UpdateKind Insert
Definition: GenericDomTree.h:242
llvm::DominatorTreeBase::getNode
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Definition: GenericDomTree.h:351
llvm::AttributeList::getFnAttrs
AttributeSet getFnAttrs() const
The function attributes are returned.
Definition: Attributes.cpp:1362
llvm::Optional
Definition: APInt.h:33
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::CloneFunctionChangeType::LocalChangesOnly
@ LocalChangesOnly
llvm::ore::NV
DiagnosticInfoOptimizationBase::Argument NV
Definition: OptimizationRemarkEmitter.h:136
llvm::ValueMapTypeRemapper
This is a class that can be implemented by clients to remap types when cloning constants and instruct...
Definition: ValueMapper.h:36
llvm::BasicBlock::getSinglePredecessor
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition: BasicBlock.cpp:268
llvm::DomTreeNodeBase::getIDom
DomTreeNodeBase * getIDom() const
Definition: GenericDomTree.h:89
llvm::successors
succ_range successors(Instruction *I)
Definition: CFG.h:262
llvm::DebugInfoFinder::compile_units
iterator_range< compile_unit_iterator > compile_units() const
Definition: DebugInfo.h:127
llvm::DebugInfoFinder
Utility to find all debug info in a module.
Definition: DebugInfo.h:90
llvm::PHINode::setIncomingValue
void setIncomingValue(unsigned i, Value *V)
Definition: Instructions.h:2732
ConstantFolding.h
llvm::MDBuilder::createAnonymousAliasScope
MDNode * createAnonymousAliasScope(MDNode *Domain, StringRef Name=StringRef())
Return metadata appropriate for an alias scope root node.
Definition: MDBuilder.h:140
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1233
llvm::Instruction::mayHaveSideEffects
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
Definition: Instruction.cpp:683
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::SwitchInst::CaseHandleImpl::getCaseSuccessor
BasicBlockT * getCaseSuccessor() const
Resolves successor for current case.
Definition: Instructions.h:3285
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::LoopBase::getParentLoop
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
Definition: LoopInfo.h:113
llvm::RemapInstruction
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Convert the instruction operands from referencing the current values into those specified by VM.
Definition: ValueMapper.h:254
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:228
Constants.h
llvm::PHINode::getIncomingValue
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
Definition: Instructions.h:2729
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::User
Definition: User.h:44
llvm::CallBase::getCalledFunction
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
Definition: InstrTypes.h:1383
llvm::LoopBase::addChildLoop
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
Definition: LoopInfo.h:395
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:296
llvm::remapInstructionsInBlocks
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock * > &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
Definition: CloneFunction.cpp:787
llvm::LoopInfoBase::addTopLevelLoop
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
Definition: LoopInfo.h:1024
llvm::PHINode::getIncomingValueForBlock
Value * getIncomingValueForBlock(const BasicBlock *BB) const
Definition: Instructions.h:2818
llvm::LoopBase::getBlocks
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
Definition: LoopInfo.h:171
llvm::Instruction
Definition: Instruction.h:45
llvm::SimplifyInstruction
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
Definition: InstructionSimplify.cpp:6328
MDBuilder.h
llvm::Function::copyAttributesFrom
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:712
llvm::GlobalObject::addMetadata
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
Definition: Metadata.cpp:1268
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:376
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:786
llvm::UndefValue::get
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1796
llvm::DomTreeUpdater
Definition: DomTreeUpdater.h:28
llvm::LoopBase::getLoopsInPreorder
SmallVector< const LoopT *, 4 > getLoopsInPreorder() const
Return all loops in the loop nest rooted by the loop in preorder, with siblings in forward program or...
Definition: LoopInfo.h:361
llvm::DominatorTreeBase::changeImmediateDominator
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
Definition: GenericDomTree.h:655
llvm::ValueMap::count
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: ValueMap.h:152
llvm::PHINode::getNumIncomingValues
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Definition: Instructions.h:2725
llvm::RF_NoModuleLevelChanges
@ RF_NoModuleLevelChanges
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
Definition: ValueMapper.h:71
CFG.h
LoopInfo.h
llvm::LoopInfoBase::AllocateLoop
LoopT * AllocateLoop(ArgsTy &&... Args)
Definition: LoopInfo.h:931
llvm::Function::getAttributes
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:327
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
llvm::ValueMap::MD
MDMapT & MD()
Definition: ValueMap.h:115
llvm::DebugInfoFinder::processSubprogram
void processSubprogram(DISubprogram *SP)
Process subprogram.
Definition: DebugInfo.cpp:258
llvm::cloneAndAdaptNoAliasScopes
void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
Definition: CloneFunction.cpp:991
llvm::CloneBasicBlock
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, DebugInfoFinder *DIFinder=nullptr)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
Definition: CloneFunction.cpp:43
llvm::DuplicateInstructionsInSplitBetween
BasicBlock * DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt, ValueToValueMapTy &ValueMapping, DomTreeUpdater &DTU)
Split edge between BB and PredBB and duplicate all non-Phi instructions from BB between its beginning...
Definition: CloneFunction.cpp:887
llvm::MipsISD::Ext
@ Ext
Definition: MipsISelLowering.h:156
llvm::AttributeList::getRetAttrs
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
Definition: Attributes.cpp:1358
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:78
llvm::count
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:1634
llvm::DomTreeNodeBase::getBlock
NodeT * getBlock() const
Definition: GenericDomTree.h:88
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:578
llvm::PHINode::setIncomingBlock
void setIncomingBlock(unsigned i, BasicBlock *BB)
Definition: Instructions.h:2768
llvm::Optional::emplace
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
Definition: Optional.h:264
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::BranchInst::Create
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
Definition: Instructions.h:3124
llvm::DenseMap
Definition: DenseMap.h:714
DebugInfo.h
llvm::LoopInfoBase::getLoopFor
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
Definition: LoopInfo.h:967
I
#define I(x, y, z)
Definition: MD5.cpp:59
Cloning.h
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1335
llvm::LoopBase::getLoopPreheader
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
Definition: LoopInfoImpl.h:167
llvm::adaptNoAliasScopes
void adaptNoAliasScopes(llvm::Instruction *I, const DenseMap< MDNode *, MDNode * > &ClonedScopes, LLVMContext &Context)
Adapt the metadata for the specified instruction according to the provided mapping.
Definition: CloneFunction.cpp:957
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:139
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::cloneNoAliasScopes
void cloneNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, DenseMap< MDNode *, MDNode * > &ClonedScopes, StringRef Ext, LLVMContext &Context)
Duplicate the specified list of noalias decl scopes.
Definition: CloneFunction.cpp:932
llvm::Function::setPersonalityFn
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1828
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::SetVector< T, SmallVector< T, N >, SmallDenseSet< T, N > >::insert
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:141
llvm::DebugInfoFinder::subprograms
iterator_range< subprogram_iterator > subprograms() const
Definition: DebugInfo.h:131
llvm::Instruction::clone
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Instruction.cpp:850
llvm::DebugInfoFinder::subprogram_count
unsigned subprogram_count() const
Definition: DebugInfo.h:149
llvm::CloneAndPruneFunctionInto
void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
Definition: CloneFunction.cpp:778
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::isInstructionTriviallyDead
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
Definition: Local.cpp:398
llvm::LoopInfo
Definition: LoopInfo.h:1083
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:179
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::identifyNoAliasScopesToClone
void identifyNoAliasScopesToClone(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< MDNode * > &NoAliasDeclScopes)
Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract ...
Definition: CloneFunction.cpp:1028
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::CloneAndPruneIntoFromInst
void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works like CloneAndPruneFunctionInto, except that it does not clone the entire function.
Definition: CloneFunction.cpp:496
llvm::pred_size
unsigned pred_size(const BasicBlock *BB)
Get the number of predecessors of BB.
Definition: CFG.h:124
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:532
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:100
getParent
static const Function * getParent(const Value *V)
Definition: BasicAliasAnalysis.cpp:867
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1748
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::pred_empty
bool pred_empty(const BasicBlock *BB)
Definition: CFG.h:119
llvm::CloneFunction
Function * CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo=nullptr)
Return a copy of the specified function and add it to that function's module.
Definition: CloneFunction.cpp:283
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
llvm::ValueMap< const Value *, WeakTrackingVH >
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:207
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:152
llvm::DominatorTreeBase::addNewBlock
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
Definition: GenericDomTree.h:619
llvm::ClonedCodeInfo::ContainsCalls
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
Definition: Cloning.h:66
llvm::BasicBlock::front
const Instruction & front() const
Definition: BasicBlock.h:308
llvm::RF_IgnoreMissingLocals
@ RF_IgnoreMissingLocals
If this flag is set, the remapper ignores missing function-local entries (Argument,...
Definition: ValueMapper.h:89
llvm::CloneFunctionChangeType
CloneFunctionChangeType
Definition: Cloning.h:136
llvm::SplitEdge
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the edge connecting the specified blocks, and return the newly created basic block between From...
Definition: BasicBlockUtils.cpp:493
llvm::AliasScopeNode::getName
StringRef getName() const
Definition: Metadata.h:1273
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::ConstantFoldTerminator
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr, DomTreeUpdater *DTU=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
Definition: Local.cpp:128
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::AliasScopeNode::getDomain
const MDNode * getDomain() const
Get the MDNode for this AliasScopeNode's domain.
Definition: Metadata.h:1268
GlobalVariable.h
Function.h
llvm::LoopBase::getHeader
BlockT * getHeader() const
Definition: LoopInfo.h:104
llvm::Module::getOrInsertNamedMetadata
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:263
llvm::ValueMap::find
iterator find(const KeyT &Val)
Definition: ValueMap.h:156
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1823
llvm::Function::arg_begin
arg_iterator arg_begin()
Definition: Function.h:749
llvm::MDBuilder
Definition: MDBuilder.h:35
llvm::Function::front
const BasicBlock & front() const
Definition: Function.h:741
llvm::BasicBlock::getInstList
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:363
Instructions.h
SmallVector.h
llvm::LoopBase::addBasicBlockToLoop
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
Definition: LoopInfoImpl.h:242
llvm::AliasScopeNode
This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...
Definition: Metadata.h:1257
N
#define N
llvm::DenseMapBase::try_emplace
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
Definition: DenseMap.h:222
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:94
InstructionSimplify.h
llvm::Value::deleteValue
void deleteValue()
Delete a pointer to a generic Value.
Definition: Value.cpp:110
llvm::BlockAddress::get
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1834
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Definition: Instructions.h:2749
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
llvm::PHINode
Definition: Instructions.h:2633
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1820
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:401
llvm::DeleteDeadBlock
void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
Delete the specified block, which must have no predecessors.
Definition: BasicBlockUtils.cpp:89
DerivedTypes.h
llvm::SmallSetVector
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:307
pred
hexagon gen pred
Definition: HexagonGenPredicate.cpp:134
llvm::CloneFunctionInto
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, CloneFunctionChangeType Changes, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values.
Definition: CloneFunction.cpp:83
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::ValueMap::lookup
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: ValueMap.h:165
LLVMContext.h
llvm::SwitchInst
Multiway switch.
Definition: Instructions.h:3212
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:62
llvm::BranchInst
Conditional or Unconditional Branch instruction.
Definition: Instructions.h:3068
llvm::DebugInfoFinder::types
iterator_range< type_iterator > types() const
Definition: DebugInfo.h:139
llvm::ClonedCodeInfo::ContainsDynamicAllocas
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
Definition: Cloning.h:71
llvm::DebugInfoFinder::processInstruction
void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
Definition: DebugInfo.cpp:192
llvm::AttributeList::getParamAttrs
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
Definition: Attributes.cpp:1354
BasicBlockUtils.h
llvm::ValueMaterializer
This is a class that can be implemented by clients to materialize Values on demand.
Definition: ValueMapper.h:49
llvm::Function::setAttributes
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition: Function.h:330
CU
Definition: AArch64AsmBackend.cpp:501
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::BranchInst::isConditional
bool isConditional() const
Definition: Instructions.h:3147
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:753
llvm::BranchInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition: Instructions.h:3161
SetVector.h
llvm::DominatorTreeBase< BasicBlock, false >::Delete
static constexpr UpdateKind Delete
Definition: GenericDomTree.h:243
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:91
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::Function::iterator
BasicBlockListType::iterator iterator
Definition: Function.h:68
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:364