Commit 3bfd1f09 authored by Nikita Popov's avatar Nikita Popov
Browse files

[AA] Make LI and EphValues option in EarliestEscapeInfo (NFC)

To allow using it in places where these may not be available.
parent b6ecdf0a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public:
/// approximation to a precise "captures before" analysis.
class EarliestEscapeInfo final : public CaptureInfo {
  DominatorTree &DT;
  const LoopInfo &LI;
  const LoopInfo *LI;

  /// Map from identified local object to an instruction before which it does
  /// not escape, or nullptr if it never escapes. The "earliest" instruction
@@ -184,11 +184,11 @@ class EarliestEscapeInfo final : public CaptureInfo {
  /// This is used for cache invalidation purposes.
  DenseMap<Instruction *, TinyPtrVector<const Value *>> Inst2Obj;

  const SmallPtrSetImpl<const Value *> &EphValues;
  const SmallPtrSetImpl<const Value *> *EphValues;

public:
  EarliestEscapeInfo(DominatorTree &DT, const LoopInfo &LI,
                     const SmallPtrSetImpl<const Value *> &EphValues)
  EarliestEscapeInfo(DominatorTree &DT, const LoopInfo *LI = nullptr,
                     const SmallPtrSetImpl<const Value *> *EphValues = nullptr)
      : DT(DT), LI(LI), EphValues(EphValues) {}

  bool isNotCapturedBeforeOrAt(const Value *Object,
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ namespace llvm {
  Instruction *
  FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures,
                      bool StoreCaptures, const DominatorTree &DT,
                      const SmallPtrSetImpl<const Value *> &EphValues,
                      const SmallPtrSetImpl<const Value *> *EphValues = nullptr,
                      unsigned MaxUsesToExplore = 0);

  /// This callback is used in conjunction with PointerMayBeCaptured. In
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ bool EarliestEscapeInfo::isNotCapturedBeforeOrAt(const Value *Object,
    return true;

  return I != Iter.first->second &&
         !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, &LI);
         !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
}

void EarliestEscapeInfo::removeInstruction(Instruction *I) {
+4 −5
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ namespace {
  struct EarliestCaptures : public CaptureTracker {

    EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT,
                     const SmallPtrSetImpl<const Value *> &EphValues)
                     const SmallPtrSetImpl<const Value *> *EphValues)
        : EphValues(EphValues), DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}

    void tooManyUses() override {
@@ -180,7 +180,7 @@ namespace {
      if (isa<ReturnInst>(I) && !ReturnCaptures)
        return false;

      if (EphValues.contains(I))
      if (EphValues && EphValues->contains(I))
        return false;

      if (!EarliestCapture)
@@ -194,7 +194,7 @@ namespace {
      return false;
    }

    const SmallPtrSetImpl<const Value *> &EphValues;
    const SmallPtrSetImpl<const Value *> *EphValues;

    Instruction *EarliestCapture = nullptr;

@@ -286,8 +286,7 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
Instruction *
llvm::FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures,
                          bool StoreCaptures, const DominatorTree &DT,

                          const SmallPtrSetImpl<const Value *> &EphValues,
                          const SmallPtrSetImpl<const Value *> *EphValues,
                          unsigned MaxUsesToExplore) {
  assert(!isa<GlobalValue>(V) &&
         "It doesn't make sense to ask whether a global is captured.");
+1 −1
Original line number Diff line number Diff line
@@ -865,7 +865,7 @@ struct DSEState {
  DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT,
           PostDominatorTree &PDT, AssumptionCache &AC,
           const TargetLibraryInfo &TLI, const LoopInfo &LI)
      : F(F), AA(AA), EI(DT, LI, EphValues), BatchAA(AA, &EI), MSSA(MSSA),
      : F(F), AA(AA), EI(DT, &LI, &EphValues), BatchAA(AA, &EI), MSSA(MSSA),
        DT(DT), PDT(PDT), TLI(TLI), DL(F.getParent()->getDataLayout()), LI(LI) {
    // Collect blocks with throwing instructions not modeled in MemorySSA and
    // alloc-like objects.