llvm.org GIT mirror llvm / c5595c0
[Attributor] Do not update or manifest dead attributes Summary: If the associated context instruction is assumed dead we do not need to update or manifest the state. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66116 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368921 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert a month ago
2 changed file(s) with 29 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
103103
104104 struct AbstractAttribute;
105105 struct InformationCache;
106 struct AAIsDead;
106107
107108 class Function;
108109
651652 void identifyDefaultAbstractAttributes(
652653 Function &F, DenseSet *Whitelist = nullptr);
653654
655 /// Return true if \p AA (or its context instruction) is assumed dead.
656 ///
657 /// If \p LivenessAA is not provided it is queried.
658 bool isAssumedDead(const AbstractAttribute &AA, const AAIsDead *LivenessAA);
659
654660 /// Check \p Pred on all function call sites.
655661 ///
656662 /// This method will evaluate \p Pred on call sites and return
10751075
10761076 std::function &)> Pred =
10771077 [&](Value &RV, const SmallPtrSetImpl &RetInsts) -> bool {
1078
10791078 if (isKnownNonZero(&RV, A.getDataLayout()))
10801079 return true;
10811080
21422141 /// Attributor
21432142 /// ----------------------------------------------------------------------------
21442143
2144 bool Attributor::isAssumedDead(const AbstractAttribute &AA,
2145 const AAIsDead *LivenessAA) {
2146 const Instruction *CtxI = AA.getIRPosition().getCtxI();
2147 if (!CtxI)
2148 return false;
2149
2150 if (!LivenessAA)
2151 LivenessAA =
2152 getAAFor(AA, IRPosition::function(*CtxI->getFunction()));
2153 if (!LivenessAA || !LivenessAA->isAssumedDead(CtxI))
2154 return false;
2155
2156 // TODO: Do not track dependences automatically but add it here as only a
2157 // "is-assumed-dead" result causes a dependence.
2158 return true;
2159 }
2160
21452161 bool Attributor::checkForAllCallSites(const function_ref &Pred,
21462162 const AbstractAttribute &QueryingAA,
21472163 bool RequireAllCallSites) {
23532369 // Update all abstract attribute in the work list and record the ones that
23542370 // changed.
23552371 for (AbstractAttribute *AA : Worklist)
2356 if (AA->update(*this) == ChangeStatus::CHANGED)
2357 ChangedAAs.push_back(AA);
2372 if (!isAssumedDead(*AA, nullptr))
2373 if (AA->update(*this) == ChangeStatus::CHANGED)
2374 ChangedAAs.push_back(AA);
23582375
23592376 // Reset the work list and repopulate with the changed abstract attributes.
23602377 // Note that dependent ones are added above.
24142431 if (!State.isValidState())
24152432 continue;
24162433
2434 // Skip dead code.
2435 if (isAssumedDead(*AA, nullptr))
2436 continue;
24172437 // Manifest the state and record if we changed the IR.
24182438 ChangeStatus LocalChange = AA->manifest(*this);
24192439 if (LocalChange == ChangeStatus::CHANGED && AreStatisticsEnabled())