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

Chandler Carruth chandlerc at gmail.com
Fri Feb 6 20:04:20 PST 2015

This is looking really nice now. A minor comment below to try to lay some groundwork for any future enhancements here. Feel free to submit with that addressed.

Comment at: lib/Analysis/BasicAliasAnalysis.cpp:893-898
@@ -892,1 +892,8 @@
+/// Try to determine whether GEP1 and GEP2 index through arrays, into structs,
+/// such that the struct field accesses provably cannot alias.
+static AliasAnalysis::AliasResult
+analyzeArrayOfStructGEPsAlias(const GEPOperator *GEP1, uint64_t V1Size,
+                              const GEPOperator *GEP2, uint64_t V2Size,
+                              const DataLayout &DL) {
+  // If both GEPs are based on the same pointer, and said pointer is a
I would probably comment this and name it as something more general so someone else would think to add more logic here rather than in the function below.

Specifically, I think the right interesting criteria is when we have two GEPs off of the exact same pointer.

If we come up with any other ways to analyze two GEPs themselves when starting from the same pointer and concluding no-alias, it would make sense to me to add that logic here.

(Naturally, I would hoist the pointer operand comparison up to the caller, and just leave the check on the number if indices here.



More information about the llvm-commits mailing list