LLVM  15.0.0git
SCCP.cpp
Go to the documentation of this file.
1 //===- SCCP.cpp - Sparse Conditional Constant Propagation -----------------===//
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 sparse conditional constant propagation and merging:
10 //
11 // Specifically, this:
12 // * Assumes values are constant unless proven otherwise
13 // * Assumes BasicBlocks are dead unless proven otherwise
14 // * Proves values to be constant, and replaces them with constants
15 // * Proves conditional branches to be unconditional
16 //
17 //===----------------------------------------------------------------------===//
18 
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/MapVector.h"
22 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/SetVector.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/Statistic.h"
33 #include "llvm/IR/BasicBlock.h"
34 #include "llvm/IR/Constant.h"
35 #include "llvm/IR/Constants.h"
36 #include "llvm/IR/DerivedTypes.h"
37 #include "llvm/IR/Function.h"
38 #include "llvm/IR/GlobalVariable.h"
39 #include "llvm/IR/InstrTypes.h"
40 #include "llvm/IR/Instruction.h"
41 #include "llvm/IR/Instructions.h"
42 #include "llvm/IR/IntrinsicInst.h"
43 #include "llvm/IR/Module.h"
44 #include "llvm/IR/PassManager.h"
45 #include "llvm/IR/Type.h"
46 #include "llvm/IR/User.h"
47 #include "llvm/IR/Value.h"
48 #include "llvm/InitializePasses.h"
49 #include "llvm/Pass.h"
50 #include "llvm/Support/Casting.h"
51 #include "llvm/Support/Debug.h"
54 #include "llvm/Transforms/Scalar.h"
57 #include <cassert>
58 #include <utility>
59 #include <vector>
60 
61 using namespace llvm;
62 
63 #define DEBUG_TYPE "sccp"
64 
65 STATISTIC(NumInstRemoved, "Number of instructions removed");
66 STATISTIC(NumDeadBlocks , "Number of basic blocks unreachable");
67 STATISTIC(NumInstReplaced,
68  "Number of instructions replaced with (simpler) instruction");
69 
70 STATISTIC(IPNumInstRemoved, "Number of instructions removed by IPSCCP");
71 STATISTIC(IPNumArgsElimed ,"Number of arguments constant propagated by IPSCCP");
72 STATISTIC(IPNumGlobalConst, "Number of globals found to be constant by IPSCCP");
73 STATISTIC(
74  IPNumInstReplaced,
75  "Number of instructions replaced with (simpler) instruction by IPSCCP");
76 
77 // Helper to check if \p LV is either a constant or a constant
78 // range with a single element. This should cover exactly the same cases as the
79 // old ValueLatticeElement::isConstant() and is intended to be used in the
80 // transition to ValueLatticeElement.
81 static bool isConstant(const ValueLatticeElement &LV) {
82  return LV.isConstant() ||
84 }
85 
86 // Helper to check if \p LV is either overdefined or a constant range with more
87 // than a single element. This should cover exactly the same cases as the old
88 // ValueLatticeElement::isOverdefined() and is intended to be used in the
89 // transition to ValueLatticeElement.
90 static bool isOverdefined(const ValueLatticeElement &LV) {
91  return !LV.isUnknownOrUndef() && !isConstant(LV);
92 }
93 
96  return true;
97 
98  // Some instructions can be handled but are rejected above. Catch
99  // those cases by falling through to here.
100  // TODO: Mark globals as being constant earlier, so
101  // TODO: wouldInstructionBeTriviallyDead() knows that atomic loads
102  // TODO: are safe to remove.
103  return isa<LoadInst>(I);
104 }
105 
106 static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
107  Constant *Const = nullptr;
108  if (V->getType()->isStructTy()) {
109  std::vector<ValueLatticeElement> IVs = Solver.getStructLatticeValueFor(V);
110  if (llvm::any_of(IVs, isOverdefined))
111  return false;
112  std::vector<Constant *> ConstVals;
113  auto *ST = cast<StructType>(V->getType());
114  for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) {
115  ValueLatticeElement V = IVs[i];
116  ConstVals.push_back(isConstant(V)
117  ? Solver.getConstant(V)
118  : UndefValue::get(ST->getElementType(i)));
119  }
120  Const = ConstantStruct::get(ST, ConstVals);
121  } else {
122  const ValueLatticeElement &IV = Solver.getLatticeValueFor(V);
123  if (isOverdefined(IV))
124  return false;
125 
126  Const =
127  isConstant(IV) ? Solver.getConstant(IV) : UndefValue::get(V->getType());
128  }
129  assert(Const && "Constant is nullptr here!");
130 
131  // Replacing `musttail` instructions with constant breaks `musttail` invariant
132  // unless the call itself can be removed.
133  // Calls with "clang.arc.attachedcall" implicitly use the return value and
134  // those uses cannot be updated with a constant.
135  CallBase *CB = dyn_cast<CallBase>(V);
136  if (CB && ((CB->isMustTailCall() &&
137  !canRemoveInstruction(CB)) ||
139  Function *F = CB->getCalledFunction();
140 
141  // Don't zap returns of the callee
142  if (F)
144 
145  LLVM_DEBUG(dbgs() << " Can\'t treat the result of call " << *CB
146  << " as a constant\n");
147  return false;
148  }
149 
150  LLVM_DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n');
151 
152  // Replaces all of the uses of a variable with uses of the constant.
153  V->replaceAllUsesWith(Const);
154  return true;
155 }
156 
158  SmallPtrSetImpl<Value *> &InsertedValues,
159  Statistic &InstRemovedStat,
160  Statistic &InstReplacedStat) {
161  bool MadeChanges = false;
162  for (Instruction &Inst : make_early_inc_range(BB)) {
163  if (Inst.getType()->isVoidTy())
164  continue;
165  if (tryToReplaceWithConstant(Solver, &Inst)) {
166  if (canRemoveInstruction(&Inst))
167  Inst.eraseFromParent();
168 
169  MadeChanges = true;
170  ++InstRemovedStat;
171  } else if (isa<SExtInst>(&Inst)) {
172  Value *ExtOp = Inst.getOperand(0);
173  if (isa<Constant>(ExtOp) || InsertedValues.count(ExtOp))
174  continue;
175  const ValueLatticeElement &IV = Solver.getLatticeValueFor(ExtOp);
176  if (!IV.isConstantRange(/*UndefAllowed=*/false))
177  continue;
178  if (IV.getConstantRange().isAllNonNegative()) {
179  auto *ZExt = new ZExtInst(ExtOp, Inst.getType(), "", &Inst);
180  ZExt->takeName(&Inst);
181  InsertedValues.insert(ZExt);
182  Inst.replaceAllUsesWith(ZExt);
183  Solver.removeLatticeValueFor(&Inst);
184  Inst.eraseFromParent();
185  InstReplacedStat++;
186  MadeChanges = true;
187  }
188  }
189  }
190  return MadeChanges;
191 }
192 
193 // runSCCP() - Run the Sparse Conditional Constant Propagation algorithm,
194 // and return true if the function was modified.
195 static bool runSCCP(Function &F, const DataLayout &DL,
196  const TargetLibraryInfo *TLI) {
197  LLVM_DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n");
198  SCCPSolver Solver(
199  DL, [TLI](Function &F) -> const TargetLibraryInfo & { return *TLI; },
200  F.getContext());
201 
202  // Mark the first block of the function as being executable.
203  Solver.markBlockExecutable(&F.front());
204 
205  // Mark all arguments to the function as being overdefined.
206  for (Argument &AI : F.args())
207  Solver.markOverdefined(&AI);
208 
209  // Solve for constants.
210  bool ResolvedUndefs = true;
211  while (ResolvedUndefs) {
212  Solver.solve();
213  LLVM_DEBUG(dbgs() << "RESOLVING UNDEFs\n");
214  ResolvedUndefs = Solver.resolvedUndefsIn(F);
215  }
216 
217  bool MadeChanges = false;
218 
219  // If we decided that there are basic blocks that are dead in this function,
220  // delete their contents now. Note that we cannot actually delete the blocks,
221  // as we cannot modify the CFG of the function.
222 
223  SmallPtrSet<Value *, 32> InsertedValues;
224  for (BasicBlock &BB : F) {
225  if (!Solver.isBlockExecutable(&BB)) {
226  LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << BB);
227 
228  ++NumDeadBlocks;
229  NumInstRemoved += removeAllNonTerminatorAndEHPadInstructions(&BB).first;
230 
231  MadeChanges = true;
232  continue;
233  }
234 
235  MadeChanges |= simplifyInstsInBlock(Solver, BB, InsertedValues,
236  NumInstRemoved, NumInstReplaced);
237  }
238 
239  return MadeChanges;
240 }
241 
243  const DataLayout &DL = F.getParent()->getDataLayout();
244  auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
245  if (!runSCCP(F, DL, &TLI))
246  return PreservedAnalyses::all();
247 
248  auto PA = PreservedAnalyses();
249  PA.preserveSet<CFGAnalyses>();
250  return PA;
251 }
252 
253 namespace {
254 
255 //===--------------------------------------------------------------------===//
256 //
257 /// SCCP Class - This class uses the SCCPSolver to implement a per-function
258 /// Sparse Conditional Constant Propagator.
259 ///
260 class SCCPLegacyPass : public FunctionPass {
261 public:
262  // Pass identification, replacement for typeid
263  static char ID;
264 
265  SCCPLegacyPass() : FunctionPass(ID) {
267  }
268 
269  void getAnalysisUsage(AnalysisUsage &AU) const override {
272  AU.setPreservesCFG();
273  }
274 
275  // runOnFunction - Run the Sparse Conditional Constant Propagation
276  // algorithm, and return true if the function was modified.
277  bool runOnFunction(Function &F) override {
278  if (skipFunction(F))
279  return false;
280  const DataLayout &DL = F.getParent()->getDataLayout();
281  const TargetLibraryInfo *TLI =
282  &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
283  return runSCCP(F, DL, TLI);
284  }
285 };
286 
287 } // end anonymous namespace
288 
289 char SCCPLegacyPass::ID = 0;
290 
291 INITIALIZE_PASS_BEGIN(SCCPLegacyPass, "sccp",
292  "Sparse Conditional Constant Propagation", false, false)
294 INITIALIZE_PASS_END(SCCPLegacyPass, "sccp",
295  "Sparse Conditional Constant Propagation", false, false)
296 
297 // createSCCPPass - This is the public interface to this file.
298 FunctionPass *llvm::createSCCPPass() { return new SCCPLegacyPass(); }
299 
301  SmallVector<ReturnInst *, 8> &ReturnsToZap,
302  SCCPSolver &Solver) {
303  // We can only do this if we know that nothing else can call the function.
304  if (!Solver.isArgumentTrackedFunction(&F))
305  return;
306 
307  if (Solver.mustPreserveReturn(&F)) {
308  LLVM_DEBUG(
309  dbgs()
310  << "Can't zap returns of the function : " << F.getName()
311  << " due to present musttail or \"clang.arc.attachedcall\" call of "
312  "it\n");
313  return;
314  }
315 
316  assert(
317  all_of(F.users(),
318  [&Solver](User *U) {
319  if (isa<Instruction>(U) &&
320  !Solver.isBlockExecutable(cast<Instruction>(U)->getParent()))
321  return true;
322  // Non-callsite uses are not impacted by zapping. Also, constant
323  // uses (like blockaddresses) could stuck around, without being
324  // used in the underlying IR, meaning we do not have lattice
325  // values for them.
326  if (!isa<CallBase>(U))
327  return true;
328  if (U->getType()->isStructTy()) {
329  return all_of(Solver.getStructLatticeValueFor(U),
330  [](const ValueLatticeElement &LV) {
331  return !isOverdefined(LV);
332  });
333  }
334  return !isOverdefined(Solver.getLatticeValueFor(U));
335  }) &&
336  "We can only zap functions where all live users have a concrete value");
337 
338  for (BasicBlock &BB : F) {
339  if (CallInst *CI = BB.getTerminatingMustTailCall()) {
340  LLVM_DEBUG(dbgs() << "Can't zap return of the block due to present "
341  << "musttail call : " << *CI << "\n");
342  (void)CI;
343  return;
344  }
345 
346  if (auto *RI = dyn_cast<ReturnInst>(BB.getTerminator()))
347  if (!isa<UndefValue>(RI->getOperand(0)))
348  ReturnsToZap.push_back(RI);
349  }
350 }
351 
352 static bool removeNonFeasibleEdges(const SCCPSolver &Solver, BasicBlock *BB,
353  DomTreeUpdater &DTU,
354  BasicBlock *&NewUnreachableBB) {
355  SmallPtrSet<BasicBlock *, 8> FeasibleSuccessors;
356  bool HasNonFeasibleEdges = false;
357  for (BasicBlock *Succ : successors(BB)) {
358  if (Solver.isEdgeFeasible(BB, Succ))
359  FeasibleSuccessors.insert(Succ);
360  else
361  HasNonFeasibleEdges = true;
362  }
363 
364  // All edges feasible, nothing to do.
365  if (!HasNonFeasibleEdges)
366  return false;
367 
368  // SCCP can only determine non-feasible edges for br, switch and indirectbr.
369  Instruction *TI = BB->getTerminator();
370  assert((isa<BranchInst>(TI) || isa<SwitchInst>(TI) ||
371  isa<IndirectBrInst>(TI)) &&
372  "Terminator must be a br, switch or indirectbr");
373 
374  if (FeasibleSuccessors.size() == 0) {
375  // Branch on undef/poison, replace with unreachable.
378  for (BasicBlock *Succ : successors(BB)) {
379  Succ->removePredecessor(BB);
380  if (SeenSuccs.insert(Succ).second)
381  Updates.push_back({DominatorTree::Delete, BB, Succ});
382  }
383  TI->eraseFromParent();
384  new UnreachableInst(BB->getContext(), BB);
385  DTU.applyUpdatesPermissive(Updates);
386  } else if (FeasibleSuccessors.size() == 1) {
387  // Replace with an unconditional branch to the only feasible successor.
388  BasicBlock *OnlyFeasibleSuccessor = *FeasibleSuccessors.begin();
390  bool HaveSeenOnlyFeasibleSuccessor = false;
391  for (BasicBlock *Succ : successors(BB)) {
392  if (Succ == OnlyFeasibleSuccessor && !HaveSeenOnlyFeasibleSuccessor) {
393  // Don't remove the edge to the only feasible successor the first time
394  // we see it. We still do need to remove any multi-edges to it though.
395  HaveSeenOnlyFeasibleSuccessor = true;
396  continue;
397  }
398 
399  Succ->removePredecessor(BB);
400  Updates.push_back({DominatorTree::Delete, BB, Succ});
401  }
402 
403  BranchInst::Create(OnlyFeasibleSuccessor, BB);
404  TI->eraseFromParent();
405  DTU.applyUpdatesPermissive(Updates);
406  } else if (FeasibleSuccessors.size() > 1) {
407  SwitchInstProfUpdateWrapper SI(*cast<SwitchInst>(TI));
409 
410  // If the default destination is unfeasible it will never be taken. Replace
411  // it with a new block with a single Unreachable instruction.
412  BasicBlock *DefaultDest = SI->getDefaultDest();
413  if (!FeasibleSuccessors.contains(DefaultDest)) {
414  if (!NewUnreachableBB) {
415  NewUnreachableBB =
416  BasicBlock::Create(DefaultDest->getContext(), "default.unreachable",
417  DefaultDest->getParent(), DefaultDest);
418  new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
419  }
420 
421  SI->setDefaultDest(NewUnreachableBB);
422  Updates.push_back({DominatorTree::Delete, BB, DefaultDest});
423  Updates.push_back({DominatorTree::Insert, BB, NewUnreachableBB});
424  }
425 
426  for (auto CI = SI->case_begin(); CI != SI->case_end();) {
427  if (FeasibleSuccessors.contains(CI->getCaseSuccessor())) {
428  ++CI;
429  continue;
430  }
431 
432  BasicBlock *Succ = CI->getCaseSuccessor();
433  Succ->removePredecessor(BB);
434  Updates.push_back({DominatorTree::Delete, BB, Succ});
435  SI.removeCase(CI);
436  // Don't increment CI, as we removed a case.
437  }
438 
439  DTU.applyUpdatesPermissive(Updates);
440  } else {
441  llvm_unreachable("Must have at least one feasible successor");
442  }
443  return true;
444 }
445 
447  Module &M, const DataLayout &DL,
448  std::function<const TargetLibraryInfo &(Function &)> GetTLI,
449  function_ref<AnalysisResultsForFn(Function &)> getAnalysis) {
450  SCCPSolver Solver(DL, GetTLI, M.getContext());
451 
452  // Loop over all functions, marking arguments to those with their addresses
453  // taken or that are external as overdefined.
454  for (Function &F : M) {
455  if (F.isDeclaration())
456  continue;
457 
458  Solver.addAnalysis(F, getAnalysis(F));
459 
460  // Determine if we can track the function's return values. If so, add the
461  // function to the solver's set of return-tracked functions.
463  Solver.addTrackedFunction(&F);
464 
465  // Determine if we can track the function's arguments. If so, add the
466  // function to the solver's set of argument-tracked functions.
468  Solver.addArgumentTrackedFunction(&F);
469  continue;
470  }
471 
472  // Assume the function is called.
473  Solver.markBlockExecutable(&F.front());
474 
475  // Assume nothing about the incoming arguments.
476  for (Argument &AI : F.args())
477  Solver.markOverdefined(&AI);
478  }
479 
480  // Determine if we can track any of the module's global variables. If so, add
481  // the global variables we can track to the solver's set of tracked global
482  // variables.
483  for (GlobalVariable &G : M.globals()) {
484  G.removeDeadConstantUsers();
486  Solver.trackValueOfGlobalVariable(&G);
487  }
488 
489  // Solve for constants.
490  bool ResolvedUndefs = true;
491  Solver.solve();
492  while (ResolvedUndefs) {
493  LLVM_DEBUG(dbgs() << "RESOLVING UNDEFS\n");
494  ResolvedUndefs = false;
495  for (Function &F : M) {
496  if (Solver.resolvedUndefsIn(F))
497  ResolvedUndefs = true;
498  }
499  if (ResolvedUndefs)
500  Solver.solve();
501  }
502 
503  bool MadeChanges = false;
504 
505  // Iterate over all of the instructions in the module, replacing them with
506  // constants if we have found them to be of constant values.
507 
508  for (Function &F : M) {
509  if (F.isDeclaration())
510  continue;
511 
512  SmallVector<BasicBlock *, 512> BlocksToErase;
513 
514  if (Solver.isBlockExecutable(&F.front())) {
515  bool ReplacedPointerArg = false;
516  for (Argument &Arg : F.args()) {
517  if (!Arg.use_empty() && tryToReplaceWithConstant(Solver, &Arg)) {
518  ReplacedPointerArg |= Arg.getType()->isPointerTy();
519  ++IPNumArgsElimed;
520  }
521  }
522 
523  // If we replaced an argument, the argmemonly and
524  // inaccessiblemem_or_argmemonly attributes do not hold any longer. Remove
525  // them from both the function and callsites.
526  if (ReplacedPointerArg) {
527  AttributeMask AttributesToRemove;
528  AttributesToRemove.addAttribute(Attribute::ArgMemOnly);
529  AttributesToRemove.addAttribute(Attribute::InaccessibleMemOrArgMemOnly);
530  F.removeFnAttrs(AttributesToRemove);
531 
532  for (User *U : F.users()) {
533  auto *CB = dyn_cast<CallBase>(U);
534  if (!CB || CB->getCalledFunction() != &F)
535  continue;
536 
537  CB->removeFnAttrs(AttributesToRemove);
538  }
539  }
540  MadeChanges |= ReplacedPointerArg;
541  }
542 
543  SmallPtrSet<Value *, 32> InsertedValues;
544  for (BasicBlock &BB : F) {
545  if (!Solver.isBlockExecutable(&BB)) {
546  LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << BB);
547  ++NumDeadBlocks;
548 
549  MadeChanges = true;
550 
551  if (&BB != &F.front())
552  BlocksToErase.push_back(&BB);
553  continue;
554  }
555 
556  MadeChanges |= simplifyInstsInBlock(Solver, BB, InsertedValues,
557  IPNumInstRemoved, IPNumInstReplaced);
558  }
559 
560  DomTreeUpdater DTU = Solver.getDTU(F);
561  // Change dead blocks to unreachable. We do it after replacing constants
562  // in all executable blocks, because changeToUnreachable may remove PHI
563  // nodes in executable blocks we found values for. The function's entry
564  // block is not part of BlocksToErase, so we have to handle it separately.
565  for (BasicBlock *BB : BlocksToErase) {
566  NumInstRemoved += changeToUnreachable(BB->getFirstNonPHI(),
567  /*PreserveLCSSA=*/false, &DTU);
568  }
569  if (!Solver.isBlockExecutable(&F.front()))
570  NumInstRemoved += changeToUnreachable(F.front().getFirstNonPHI(),
571  /*PreserveLCSSA=*/false, &DTU);
572 
573  BasicBlock *NewUnreachableBB = nullptr;
574  for (BasicBlock &BB : F)
575  MadeChanges |= removeNonFeasibleEdges(Solver, &BB, DTU, NewUnreachableBB);
576 
577  for (BasicBlock *DeadBB : BlocksToErase)
578  if (!DeadBB->hasAddressTaken())
579  DTU.deleteBB(DeadBB);
580 
581  for (BasicBlock &BB : F) {
582  for (Instruction &Inst : llvm::make_early_inc_range(BB)) {
583  if (Solver.getPredicateInfoFor(&Inst)) {
584  if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
585  if (II->getIntrinsicID() == Intrinsic::ssa_copy) {
586  Value *Op = II->getOperand(0);
587  Inst.replaceAllUsesWith(Op);
588  Inst.eraseFromParent();
589  }
590  }
591  }
592  }
593  }
594  }
595 
596  // If we inferred constant or undef return values for a function, we replaced
597  // all call uses with the inferred value. This means we don't need to bother
598  // actually returning anything from the function. Replace all return
599  // instructions with return undef.
600  //
601  // Do this in two stages: first identify the functions we should process, then
602  // actually zap their returns. This is important because we can only do this
603  // if the address of the function isn't taken. In cases where a return is the
604  // last use of a function, the order of processing functions would affect
605  // whether other functions are optimizable.
606  SmallVector<ReturnInst*, 8> ReturnsToZap;
607 
608  for (const auto &I : Solver.getTrackedRetVals()) {
609  Function *F = I.first;
610  const ValueLatticeElement &ReturnValue = I.second;
611 
612  // If there is a known constant range for the return value, add !range
613  // metadata to the function's call sites.
614  if (ReturnValue.isConstantRange() &&
615  !ReturnValue.getConstantRange().isSingleElement()) {
616  // Do not add range metadata if the return value may include undef.
617  if (ReturnValue.isConstantRangeIncludingUndef())
618  continue;
619 
620  auto &CR = ReturnValue.getConstantRange();
621  for (User *User : F->users()) {
622  auto *CB = dyn_cast<CallBase>(User);
623  if (!CB || CB->getCalledFunction() != F)
624  continue;
625 
626  // Limit to cases where the return value is guaranteed to be neither
627  // poison nor undef. Poison will be outside any range and currently
628  // values outside of the specified range cause immediate undefined
629  // behavior.
630  if (!isGuaranteedNotToBeUndefOrPoison(CB, nullptr, CB))
631  continue;
632 
633  // Do not touch existing metadata for now.
634  // TODO: We should be able to take the intersection of the existing
635  // metadata and the inferred range.
636  if (CB->getMetadata(LLVMContext::MD_range))
637  continue;
638 
639  LLVMContext &Context = CB->getParent()->getContext();
640  Metadata *RangeMD[] = {
643  CB->setMetadata(LLVMContext::MD_range, MDNode::get(Context, RangeMD));
644  }
645  continue;
646  }
647  if (F->getReturnType()->isVoidTy())
648  continue;
649  if (isConstant(ReturnValue) || ReturnValue.isUnknownOrUndef())
650  findReturnsToZap(*F, ReturnsToZap, Solver);
651  }
652 
653  for (auto F : Solver.getMRVFunctionsTracked()) {
654  assert(F->getReturnType()->isStructTy() &&
655  "The return type should be a struct");
656  StructType *STy = cast<StructType>(F->getReturnType());
657  if (Solver.isStructLatticeConstant(F, STy))
658  findReturnsToZap(*F, ReturnsToZap, Solver);
659  }
660 
661  // Zap all returns which we've identified as zap to change.
662  SmallSetVector<Function *, 8> FuncZappedReturn;
663  for (unsigned i = 0, e = ReturnsToZap.size(); i != e; ++i) {
664  Function *F = ReturnsToZap[i]->getParent()->getParent();
665  ReturnsToZap[i]->setOperand(0, UndefValue::get(F->getReturnType()));
666  // Record all functions that are zapped.
667  FuncZappedReturn.insert(F);
668  }
669 
670  // Remove the returned attribute for zapped functions and the
671  // corresponding call sites.
672  for (Function *F : FuncZappedReturn) {
673  for (Argument &A : F->args())
674  F->removeParamAttr(A.getArgNo(), Attribute::Returned);
675  for (Use &U : F->uses()) {
676  // Skip over blockaddr users.
677  if (isa<BlockAddress>(U.getUser()))
678  continue;
679  CallBase *CB = cast<CallBase>(U.getUser());
680  for (Use &Arg : CB->args())
681  CB->removeParamAttr(CB->getArgOperandNo(&Arg), Attribute::Returned);
682  }
683  }
684 
685  // If we inferred constant or undef values for globals variables, we can
686  // delete the global and any stores that remain to it.
687  for (auto &I : make_early_inc_range(Solver.getTrackedGlobals())) {
688  GlobalVariable *GV = I.first;
689  if (isOverdefined(I.second))
690  continue;
691  LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName()
692  << "' is constant!\n");
693  while (!GV->use_empty()) {
694  StoreInst *SI = cast<StoreInst>(GV->user_back());
695  SI->eraseFromParent();
696  MadeChanges = true;
697  }
698  M.getGlobalList().erase(GV);
699  ++IPNumGlobalConst;
700  }
701 
702  return MadeChanges;
703 }
i
i
Definition: README.txt:29
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
removeNonFeasibleEdges
static bool removeNonFeasibleEdges(const SCCPSolver &Solver, BasicBlock *BB, DomTreeUpdater &DTU, BasicBlock *&NewUnreachableBB)
Definition: SCCP.cpp:352
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
llvm::ValueLatticeElement::getConstantRange
const ConstantRange & getConstantRange(bool UndefAllowed=true) const
Returns the constant range for this value.
Definition: ValueLattice.h:272
llvm::ValueLatticeElement::isConstant
bool isConstant() const
Definition: ValueLattice.h:243
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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::DomTreeUpdater::deleteBB
void deleteBB(BasicBlock *DelBB)
Delete DelBB.
Definition: DomTreeUpdater.cpp:178
llvm::CallBase::getOperandBundle
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
Definition: InstrTypes.h:2027
sccp
sccp
Definition: SCCP.cpp:294
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
Insert
Vector Rotate Left Mask Mask Insert
Definition: README_P9.txt:112
llvm::SwitchInstProfUpdateWrapper
A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...
Definition: Instructions.h:3572
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
IntrinsicInst.h
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:780
Scalar.h
llvm::AnalysisResultsForFn
Helper struct for bundling up the analysis results per function for IPSCCP.
Definition: SCCPSolver.h:40
llvm::Function
Definition: Function.h:60
llvm::ConstantStruct::get
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1355
Pass.h
isConstant
static bool isConstant(const ValueLatticeElement &LV)
Definition: SCCP.cpp:81
llvm::SCCPSolver::getStructLatticeValueFor
std::vector< ValueLatticeElement > getStructLatticeValueFor(Value *V) const
Definition: SCCPSolver.cpp:1590
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
Statistic.h
function
function Propagate constant arguments by specializing the function
Definition: SCCP.cpp:193
ErrorHandling.h
SCCP.h
llvm::initializeSCCPLegacyPassPass
void initializeSCCPLegacyPassPass(PassRegistry &)
MapVector.h
DomTreeUpdater.h
llvm::GlobalVariable
Definition: GlobalVariable.h:39
ValueTracking.h
Local.h
GlobalsModRef.h
llvm::SCCPSolver::getConstant
Constant * getConstant(const ValueLatticeElement &LV) const
Helper to return a Constant if LV is either a constant or a constant range with a single element.
Definition: SCCPSolver.cpp:1622
DenseMap.h
Module.h
llvm::AttributeMask
Definition: Attributes.h:963
llvm::CallBase::isMustTailCall
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Definition: Instructions.cpp:298
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
isGuaranteedNotToBeUndefOrPoison
static bool isGuaranteedNotToBeUndefOrPoison(const Value *V, AssumptionCache *AC, const Instruction *CtxI, const DominatorTree *DT, unsigned Depth, bool PoisonOnly)
Definition: ValueTracking.cpp:5273
llvm::successors
auto successors(MachineBasicBlock *BB)
Definition: MachineSSAContext.h:29
llvm::SCCPSolver::markBlockExecutable
bool markBlockExecutable(BasicBlock *BB)
markBlockExecutable - This method can be used by clients to mark all of the blocks that are known to ...
Definition: SCCPSolver.cpp:1541
STLExtras.h
llvm::SCCPSolver::addArgumentTrackedFunction
void addArgumentTrackedFunction(Function *F)
Definition: SCCPSolver.cpp:1567
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
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
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
Instruction.h
llvm::CallBase::removeParamAttr
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1568
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:1617
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::ValueLatticeElement::isUnknownOrUndef
bool isUnknownOrUndef() const
Definition: ValueLattice.h:242
Constants.h
llvm::SCCPSolver::markOverdefined
void markOverdefined(Value *V)
markOverdefined - Mark the specified value overdefined.
Definition: SCCPSolver.cpp:1616
llvm::User
Definition: User.h:44
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(IPSCCPLegacyPass, "ipsccp", "Interprocedural Sparse Conditional Constant Propagation", false, false) INITIALIZE_PASS_END(IPSCCPLegacyPass
runSCCP
static bool runSCCP(Function &F, const DataLayout &DL, const TargetLibraryInfo *TLI)
Definition: SCCP.cpp:195
InstrTypes.h
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:1396
llvm::SCCPSolver::isArgumentTrackedFunction
bool isArgumentTrackedFunction(Function *F)
Returns true if the given function is in the solver's set of argument-tracked functions.
Definition: SCCPSolver.cpp:1571
llvm::ValueLatticeElement::isConstantRangeIncludingUndef
bool isConstantRangeIncludingUndef() const
Definition: ValueLattice.h:245
llvm::ConstantRange::isSingleElement
bool isSingleElement() const
Return true if this set contains exactly one member.
Definition: ConstantRange.h:261
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::LLVMContext::OB_clang_arc_attachedcall
@ OB_clang_arc_attachedcall
Definition: LLVMContext.h:96
Propagation
Interprocedural Sparse Conditional Constant Propagation
Definition: SCCP.cpp:103
TargetLibraryInfo.h
false
Definition: StackSlotColoring.cpp:141
llvm::removeAllNonTerminatorAndEHPadInstructions
std::pair< unsigned, unsigned > removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB)
Remove all instructions from a basic block other than its terminator and any present EH pad instructi...
Definition: Local.cpp:2098
llvm::SCCPSolver::addAnalysis
void addAnalysis(Function &F, AnalysisResultsForFn A)
Definition: SCCPSolver.cpp:1537
llvm::Instruction
Definition: Instruction.h:42
canRemoveInstruction
static bool canRemoveInstruction(Instruction *I)
Definition: SCCP.cpp:94
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::UndefValue::get
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1777
llvm::DomTreeUpdater
Definition: DomTreeUpdater.h:28
tryToReplaceWithConstant
static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V)
Definition: SCCP.cpp:106
llvm::SCCPSolver::isStructLatticeConstant
bool isStructLatticeConstant(Function *F, StructType *STy)
Definition: SCCPSolver.cpp:1618
SmallPtrSet.h
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::canTrackGlobalVariableInterprocedurally
bool canTrackGlobalVariableInterprocedurally(GlobalVariable *GV)
Determine if the value maintained in the given global variable can be tracked interprocedurally.
Definition: ValueLatticeUtils.cpp:27
llvm::Value::use_empty
bool use_empty() const
Definition: Value.h:344
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::runIPSCCP
bool runIPSCCP(Module &M, const DataLayout &DL, std::function< const TargetLibraryInfo &(Function &)> GetTLI, function_ref< AnalysisResultsForFn(Function &)> getAnalysis)
Definition: SCCP.cpp:446
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::Value::user_back
User * user_back()
Definition: Value.h:407
llvm::SCCPSolver::getTrackedRetVals
const MapVector< Function *, ValueLatticeElement > & getTrackedRetVals()
getTrackedRetVals - Get the inferred return value map.
Definition: SCCPSolver.cpp:1603
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::wouldInstructionBeTriviallyDead
bool wouldInstructionBeTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction would have no side effects if it was not used.
Definition: Local.cpp:414
BasicBlock.h
llvm::SCCPSolver::getLatticeValueFor
const ValueLatticeElement & getLatticeValueFor(Value *V) const
Definition: SCCPSolver.cpp:1598
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:297
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:77
simplifyInstsInBlock
static bool simplifyInstsInBlock(SCCPSolver &Solver, BasicBlock &BB, SmallPtrSetImpl< Value * > &InsertedValues, Statistic &InstRemovedStat, Statistic &InstReplacedStat)
Definition: SCCP.cpp:157
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:468
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::SCCPSolver::getPredicateInfoFor
const PredicateBase * getPredicateInfoFor(Instruction *I)
Definition: SCCPSolver.cpp:1545
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::SCCPPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: SCCP.cpp:242
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::make_early_inc_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:618
llvm::SCCPSolver
SCCPSolver - This interface class is a general purpose solver for Sparse Conditional Constant Propaga...
Definition: SCCPSolver.h:61
llvm::SmallPtrSetImpl::begin
iterator begin() const
Definition: SmallPtrSet.h:403
llvm::SCCPSolver::getTrackedGlobals
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals()
getTrackedGlobals - Get and return the set of inferred initializers for global variables.
Definition: SCCPSolver.cpp:1608
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::SmallPtrSetImpl::count
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:383
llvm::ZExtInst
This class represents zero extension of integer types.
Definition: Instructions.h:4806
llvm::createSCCPPass
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:298
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::SCCPSolver::getDTU
DomTreeUpdater getDTU(Function &F)
Definition: SCCPSolver.cpp:1549
isOverdefined
static bool isOverdefined(const ValueLatticeElement &LV)
Definition: SCCP.cpp:90
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:1624
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:263
findReturnsToZap
static void findReturnsToZap(Function &F, SmallVector< ReturnInst *, 8 > &ReturnsToZap, SCCPSolver &Solver)
Definition: SCCP.cpp:300
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:113
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition: PassAnalysisSupport.h:98
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:529
A
* A
Definition: README_ALTIVEC.txt:89
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::SCCPSolver::removeLatticeValueFor
void removeLatticeValueFor(Value *V)
Definition: SCCPSolver.cpp:1594
llvm::ValueLatticeElement
This class represents lattice values for constants.
Definition: ValueLattice.h:29
llvm::SCCPSolver::mustPreserveReturn
bool mustPreserveReturn(Function *F)
Returns true if the return of the given function cannot be modified.
Definition: SCCPSolver.cpp:1563
llvm::TrackingStatistic
Definition: Statistic.h:50
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:305
ValueLatticeUtils.h
llvm::SCCPSolver::isBlockExecutable
bool isBlockExecutable(BasicBlock *BB) const
Definition: SCCPSolver.cpp:1581
llvm::SmallPtrSetImplBase::size
size_type size() const
Definition: SmallPtrSet.h:93
llvm::BasicBlock::getContext
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:35
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition: EntryExitInstrumenter.cpp:69
llvm::SCCPSolver::isEdgeFeasible
bool isEdgeFeasible(BasicBlock *From, BasicBlock *To) const
Definition: SCCPSolver.cpp:1585
Constant.h
SCCPSolver.h
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:345
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
GlobalVariable.h
Casting.h
Function.h
PassManager.h
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:222
llvm::SCCPSolver::resolvedUndefsIn
bool resolvedUndefsIn(Function &F)
resolvedUndefsIn - While solving the dataflow for a function, we assume that branches on undef values...
Definition: SCCPSolver.cpp:1577
llvm::CallBase::getArgOperandNo
unsigned getArgOperandNo(const Use *U) const
Given a use for a arg operand, get the arg operand number that corresponds to it.
Definition: InstrTypes.h:1372
llvm::changeToUnreachable
unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
Definition: Local.cpp:2122
llvm::SCCPSolver::addToMustPreserveReturnsInFunctions
void addToMustPreserveReturnsInFunctions(Function *F)
Add function to the list of functions whose return cannot be modified.
Definition: SCCPSolver.cpp:1559
Instructions.h
llvm::Type::isStructTy
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:212
SmallVector.h
User.h
llvm::canTrackArgumentsInterprocedurally
bool canTrackArgumentsInterprocedurally(Function *F)
Determine if the values of the given function's arguments can be tracked interprocedurally.
Definition: ValueLatticeUtils.cpp:19
llvm::ValueLatticeElement::isConstantRange
bool isConstantRange(bool UndefAllowed=true) const
Returns true if this value is a constant range.
Definition: ValueLattice.h:252
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition: GlobalsModRef.h:148
llvm::BasicBlock::removePredecessor
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Definition: BasicBlock.cpp:318
IV
static const uint32_t IV[8]
Definition: blake3_impl.h:85
llvm::SCCPSolver::trackValueOfGlobalVariable
void trackValueOfGlobalVariable(GlobalVariable *GV)
trackValueOfGlobalVariable - Clients can use this method to inform the SCCPSolver that it should trac...
Definition: SCCPSolver.cpp:1551
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
DerivedTypes.h
llvm::SmallPtrSetImpl< Value * >
llvm::SmallSetVector
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:307
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1461
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::UnreachableInst
This function has undefined behavior.
Definition: Instructions.h:4727
llvm::SCCPSolver::solve
void solve()
Solve - Solve for constants and executable blocks.
Definition: SCCPSolver.cpp:1575
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::AttributeMask::addAttribute
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
Definition: Attributes.h:978
raw_ostream.h
llvm::SCCPSolver::addTrackedFunction
void addTrackedFunction(Function *F)
addTrackedFunction - If the SCCP solver is supposed to track calls into and out of the specified func...
Definition: SCCPSolver.cpp:1555
llvm::SmallPtrSetImpl::contains
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:389
Value.h
InitializePasses.h
ValueLattice.h
llvm::DomTreeUpdater::applyUpdatesPermissive
void applyUpdatesPermissive(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Definition: DomTreeUpdater.cpp:250
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
Debug.h
llvm::TargetLibraryAnalysis
Analysis pass providing the TargetLibraryInfo.
Definition: TargetLibraryInfo.h:443
llvm::SCCPSolver::getMRVFunctionsTracked
const SmallPtrSet< Function *, 16 > getMRVFunctionsTracked()
getMRVFunctionsTracked - Get the set of functions which return multiple values tracked by the pass.
Definition: SCCPSolver.cpp:1612
llvm::CallBase::args
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
Definition: InstrTypes.h:1332
SetVector.h
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::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::canTrackReturnsInterprocedurally
bool canTrackReturnsInterprocedurally(Function *F)
Determine if the values of the given function's returns can be tracked interprocedurally.
Definition: ValueLatticeUtils.cpp:23