llvm.org GIT mirror llvm / 3f59c21
[Attributor][NFC] Expose call site traversal without QueryingAA git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374700 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert 1 year, 1 month ago
2 changed file(s) with 26 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
898898 const DataLayout &getDataLayout() const { return InfoCache.DL; }
899899
900900 private:
901 /// Check \p Pred on all call sites of \p Fn.
902 ///
903 /// This method will evaluate \p Pred on call sites and return
904 /// true if \p Pred holds in every call sites. However, this is only possible
905 /// all call sites are known, hence the function has internal linkage.
906 bool checkForAllCallSites(const function_ref &Pred,
907 const Function &Fn, bool RequireAllCallSites,
908 const AbstractAttribute *QueryingAA);
909
901910 /// The private version of getAAFor that allows to omit a querying abstract
902911 /// attribute. See also the public getAAFor method.
903912 template
41664166 return false;
41674167 }
41684168
4169 if (RequireAllCallSites && !AssociatedFunction->hasLocalLinkage()) {
4169 return checkForAllCallSites(Pred, *AssociatedFunction, RequireAllCallSites,
4170 &QueryingAA);
4171 }
4172
4173 bool Attributor::checkForAllCallSites(
4174 const function_ref &Pred, const Function &Fn,
4175 bool RequireAllCallSites, const AbstractAttribute *QueryingAA) {
4176 if (RequireAllCallSites && !Fn.hasLocalLinkage()) {
41704177 LLVM_DEBUG(
41714178 dbgs()
4172 << "[Attributor] Function " << AssociatedFunction->getName()
4179 << "[Attributor] Function " << Fn.getName()
41734180 << " has no internal linkage, hence not all call sites are known\n");
41744181 return false;
41754182 }
41764183
4177 for (const Use &U : AssociatedFunction->uses()) {
4184 for (const Use &U : Fn.uses()) {
41784185 AbstractCallSite ACS(&U);
41794186 if (!ACS) {
41804187 LLVM_DEBUG(dbgs() << "[Attributor] Function "
4181 << AssociatedFunction->getName()
4188 << Fn.getName()
41824189 << " has non call site use " << *U.get() << " in "
41834190 << *U.getUser() << "\n");
41844191 return false;
41874194 Instruction *I = ACS.getInstruction();
41884195 Function *Caller = I->getFunction();
41894196
4190 const auto &LivenessAA =
4191 getAAFor(QueryingAA, IRPosition::function(*Caller),
4197 const auto *LivenessAA =
4198 lookupAAFor(IRPosition::function(*Caller), QueryingAA,
41924199 /* TrackDependence */ false);
41934200
41944201 // Skip dead calls.
4195 if (LivenessAA.isAssumedDead(I)) {
4202 if (LivenessAA && LivenessAA->isAssumedDead(I)) {
41964203 // We actually used liveness information so we have to record a
41974204 // dependence.
4198 recordDependence(LivenessAA, QueryingAA);
4205 if (QueryingAA)
4206 recordDependence(*LivenessAA, *QueryingAA);
41994207 continue;
42004208 }
42014209
42064214 continue;
42074215 LLVM_DEBUG(dbgs() << "[Attributor] User " << EffectiveUse->getUser()
42084216 << " is an invalid use of "
4209 << AssociatedFunction->getName() << "\n");
4217 << Fn.getName() << "\n");
42104218 return false;
42114219 }
42124220