[llvm] r277362 - [CFLAA] Make CFLAnders more conservative with new Values.

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 11:27:35 PDT 2016


Author: gbiv
Date: Mon Aug  1 13:27:33 2016
New Revision: 277362

URL: http://llvm.org/viewvc/llvm-project?rev=277362&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp?rev=277362&r1=277361&r2=277362&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp Mon Aug  1 13:27:33 2016
@@ -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<con
   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::Functio
 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;




More information about the llvm-commits mailing list