[cfe-commits] r65366 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp lib/Analysis/RegionStore.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Mon Feb 23 18:23:11 PST 2009


Author: kremenek
Date: Mon Feb 23 20:23:11 2009
New Revision: 65366

URL: http://llvm.org/viewvc/llvm-project?rev=65366&view=rev
Log:
Fix <rdar://problem/6611677>: Add basic transfer function support in the static
analyzer for array subscript expressions involving bases that are vectors. This
solution is probably a hack: it gets the lvalue of the vector instead of an
rvalue like all other types. This should be reviewed (big FIXME in
GRExprEngine).

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=65366&r1=65365&r2=65366&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Mon Feb 23 20:23:11 2009
@@ -850,7 +850,16 @@
   Expr* Base = A->getBase()->IgnoreParens();
   Expr* Idx  = A->getIdx()->IgnoreParens();
   NodeSet Tmp;
-  Visit(Base, Pred, Tmp);   // Get Base's rvalue, which should be an LocVal.
+  
+  if (Base->getType()->isVectorType()) {
+    // For vector types get its lvalue.
+    // FIXME: This may not be correct.  Is the rvalue of a vector its location?
+    //  In fact, I think this is just a hack.  We need to get the right
+    // semantics.
+    VisitLValue(Base, Pred, Tmp);
+  }
+  else  
+    Visit(Base, Pred, Tmp);   // Get Base's rvalue, which should be an LocVal.
   
   for (NodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {    
     NodeSet Tmp2;

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=65366&r1=65365&r2=65366&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Feb 23 20:23:11 2009
@@ -591,9 +591,14 @@
   //
   // Such funny addressing will occur due to layering of regions.
 
-  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
-    if (TR->getRValueType(getContext())->isStructureType())
+  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
+    QualType T =TR->getRValueType(getContext());
+    if (T->isStructureType())
       return RetrieveStruct(St, TR);
+    // FIXME: handle Vector types.
+    if (T->isVectorType())
+      return UnknownVal();
+  }
   
   RegionBindingsTy B = GetRegionBindings(St->getStore());
   RegionBindingsTy::data_type* V = B.lookup(R);
@@ -636,6 +641,7 @@
       return loc::MemRegionVal(getSelfRegion(0));
   }
   
+
   if (MRMgr.onStack(R) || MRMgr.onHeap(R)) {
     // All stack variables are considered to have undefined values
     // upon creation.  All heap allocated blocks are considered to

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=65366&r1=65365&r2=65366&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Feb 23 20:23:11 2009
@@ -115,4 +115,14 @@
   ({});
 }
 
+// <rdar://problem/6611677>
+// This test case test the use of a vector type within an array subscript
+// expression.
+typedef long long __a64vector __attribute__((__vector_size__(8)));
+typedef long long __a128vector __attribute__((__vector_size__(16)));
+static inline __a64vector __attribute__((__always_inline__, __nodebug__))  
+my_test_mm_movepi64_pi64(__a128vector a) {
+  return (__a64vector)a[0];
+}
+
 





More information about the cfe-commits mailing list