[PATCH] D23077: [CFLAA] Make CFLAnders more conservative when it sees newly created values

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 15:25:12 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL277533: [CFLAA] Be more conservative with values we haven't seen. (authored by gbiv).

Changed prior to commit:
  https://reviews.llvm.org/D23077?vs=66517&id=66569#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23077

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

Index: llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
+++ llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
@@ -305,7 +305,7 @@
   /// Summary of externally visible effects.
   AliasSummary Summary;
 
-  AliasAttrs getAttrs(const Value *) const;
+  Optional<AliasAttrs> getAttrs(const Value *) const;
 
 public:
   FunctionInfo(const Function &, const SmallVectorImpl<Value *> &,
@@ -479,28 +479,33 @@
   populateExternalRelations(Summary.RetParamRelations, Fn, RetVals, ReachSet);
 }
 
-AliasAttrs CFLAndersAAResult::FunctionInfo::getAttrs(const Value *V) const {
+Optional<AliasAttrs>
+CFLAndersAAResult::FunctionInfo::getAttrs(const Value *V) const {
   assert(V != nullptr);
 
-  // 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;
-  return Attr;
+    return Itr->second;
+  return None;
 }
 
 bool CFLAndersAAResult::FunctionInfo::mayAlias(const Value *LHS,
                                                uint64_t LHSSize,
                                                const Value *RHS,
                                                uint64_t RHSSize) const {
   assert(LHS && RHS);
 
-  // Check AliasAttrs first since it's cheaper
-  auto AttrsA = getAttrs(LHS);
-  auto AttrsB = getAttrs(RHS);
+  // Check if we've seen LHS and RHS before. Sometimes LHS or RHS can be created
+  // after the analysis gets executed, and we want to be conservative in those
+  // cases.
+  auto MaybeAttrsA = getAttrs(LHS);
+  auto MaybeAttrsB = getAttrs(RHS);
+  if (!MaybeAttrsA || !MaybeAttrsB)
+    return true;
+
+  // Check AliasAttrs before AliasMap lookup since it's cheaper
+  auto AttrsA = *MaybeAttrsA;
+  auto AttrsB = *MaybeAttrsB;
   if (hasUnknownOrCallerAttr(AttrsA))
     return AttrsB.any();
   if (hasUnknownOrCallerAttr(AttrsB))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23077.66569.patch
Type: text/x-patch
Size: 2116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/433a1e70/attachment.bin>


More information about the llvm-commits mailing list