diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-08-01 18:27:33 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-08-01 18:27:33 +0000 |
| commit | 4c58266038b70d95168fb3920ae50c5189333675 (patch) | |
| tree | 2b56c1108f92fa941d3cb87d96bdd12b31979b69 /llvm/lib | |
| parent | d1548eaa179bb3f897e250ef1220f75bf901292b (diff) | |
| download | bcm5719-llvm-4c58266038b70d95168fb3920ae50c5189333675.tar.gz bcm5719-llvm-4c58266038b70d95168fb3920ae50c5189333675.zip | |
[CFLAA] Make CFLAnders more conservative with new Values.
Currently, CFLAnders assumes that values it hasn't seen don't alias
anything. This patch fixes that. Given that the only way for this to
happen is to query AA, rely on specific transformations happening, then
query AA again (looking for a specific set of queries), lit testing is a
bit difficult. If someone really wants a test, I'm happy to add one.
Patch by Jia Chen.
Differential Revision: https://reviews.llvm.org/D22981
llvm-svn: 277362
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp index d699cbb4532..f5985c8ccc6 100644 --- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -213,8 +213,6 @@ public: typedef MapType::const_iterator const_iterator; bool add(InstantiatedValue V, AliasAttrs Attr) { - if (Attr.none()) - return false; auto &OldAttr = AttrMap[V]; auto NewAttr = OldAttr | Attr; if (OldAttr == NewAttr) @@ -346,9 +344,11 @@ static void populateAttrMap(DenseMap<const Value *, AliasAttrs> &AttrMap, for (const auto &Mapping : AMap.mappings()) { auto IVal = Mapping.first; + // Insert IVal into the map + auto &Attr = AttrMap[IVal.Val]; // AttrMap only cares about top-level values if (IVal.DerefLevel == 0) - AttrMap[IVal.Val] |= Mapping.second; + Attr |= Mapping.second; } } @@ -482,7 +482,10 @@ CFLAndersAAResult::FunctionInfo::FunctionInfo( AliasAttrs CFLAndersAAResult::FunctionInfo::getAttrs(const Value *V) const { assert(V != nullptr); - AliasAttrs Attr; + // Return AttrUnknown if V is not found in AttrMap. Sometimes V can be created + // after the analysis gets executed, and we want to be conservative in + // those cases. + AliasAttrs Attr = getAttrUnknown(); auto Itr = AttrMap.find(V); if (Itr != AttrMap.end()) Attr = Itr->second; |

