[PATCH] [BasicAA] Add add-hoc rule to distinguish different fields in arrays of structs.

Chandler Carruth chandlerc at gmail.com
Fri Feb 6 17:55:25 PST 2015


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1016-1020
@@ +1015,7 @@
+
+      // Find the last-indexed type of the GEP, i.e., the type you'd get if
+      // you stripped the last index.
+      // On the way, look at each indexed type.  If there's something other
+      // than an array, different indices can lead to different final types.
+      auto LookThroughArrayIndices = [](const GEPOperator *GEP) -> StructType *{
+        SmallVector<Value *, 8> IntermediateIndices;
----------------
I still think this would all be much more readable in a separate static helper function rather than being inlined (even using lambdas heavily like this to get early return).

This lambda wouldn't be needed, the code would be much less indented, and it would be a good place to hang the high-level comments about this approach, and a good place to add other structural analysis of GEPs in the future.

http://reviews.llvm.org/D7453

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list