From: David Majnemer Date: Mon, 15 Aug 2016 02:23:46 +0000 (+0000) Subject: Revert "[ScopedNoAliasAA] Remove an unneccesary set" X-Git-Tag: llvmorg-4.0.0-rc1~12465 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c77a1390deb5ed8b3d598a2b4904658ccbff6146;p=platform%2Fupstream%2Fllvm.git Revert "[ScopedNoAliasAA] Remove an unneccesary set" This reverts commit r278641. I'm not sure why but this has upset the multistage builders... llvm-svn: 278644 --- diff --git a/llvm/include/llvm/Analysis/ScopedNoAliasAA.h b/llvm/include/llvm/Analysis/ScopedNoAliasAA.h index d0514d1..11ffc62 100644 --- a/llvm/include/llvm/Analysis/ScopedNoAliasAA.h +++ b/llvm/include/llvm/Analysis/ScopedNoAliasAA.h @@ -42,6 +42,8 @@ public: private: bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const; + void collectMDInDomain(const MDNode *List, const MDNode *Domain, + SmallPtrSetImpl &Nodes) const; }; /// Analysis pass providing a never-invalidated alias analysis result. diff --git a/llvm/lib/Analysis/ScopedNoAliasAA.cpp b/llvm/lib/Analysis/ScopedNoAliasAA.cpp index b631fad..1c4d0fa 100644 --- a/llvm/lib/Analysis/ScopedNoAliasAA.cpp +++ b/llvm/lib/Analysis/ScopedNoAliasAA.cpp @@ -127,6 +127,15 @@ ModRefInfo ScopedNoAliasAAResult::getModRefInfo(ImmutableCallSite CS1, return AAResultBase::getModRefInfo(CS1, CS2); } +void ScopedNoAliasAAResult::collectMDInDomain( + const MDNode *List, const MDNode *Domain, + SmallPtrSetImpl &Nodes) const { + for (const MDOperand &MDOp : List->operands()) + if (const MDNode *MD = dyn_cast(MDOp)) + if (AliasScopeNode(MD).getDomain() == Domain) + Nodes.insert(MD); +} + bool ScopedNoAliasAAResult::mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const { if (!Scopes || !NoAlias) @@ -142,21 +151,19 @@ bool ScopedNoAliasAAResult::mayAliasInScopes(const MDNode *Scopes, // We alias unless, for some domain, the set of noalias scopes in that domain // is a superset of the set of alias scopes in that domain. for (const MDNode *Domain : Domains) { - SmallPtrSet NANodes; - for (const MDOperand &MDOp : NoAlias->operands()) - if (const MDNode *MD = dyn_cast(MDOp)) - if (AliasScopeNode(MD).getDomain() == Domain) - NANodes.insert(MD); + SmallPtrSet NANodes, ScopeNodes; + collectMDInDomain(NoAlias, Domain, NANodes); + collectMDInDomain(Scopes, Domain, ScopeNodes); + if (!ScopeNodes.size()) + continue; - // To not alias, all of the nodes in Scopes must be in NANodes. + // To not alias, all of the nodes in ScopeNodes must be in NANodes. bool FoundAll = true; - for (const MDOperand &MDOp : Scopes->operands()) - if (const MDNode *SMD = dyn_cast(MDOp)) - if (AliasScopeNode(SMD).getDomain() == Domain) - if (!NANodes.count(SMD)) { - FoundAll = false; - break; - } + for (const MDNode *SMD : ScopeNodes) + if (!NANodes.count(SMD)) { + FoundAll = false; + break; + } if (FoundAll) return false;