[PATCH] D20665: Claim NoAlias if two GEPs index different fields of the same struct

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 17:08:45 PDT 2016


eli.friedman added a subscriber: eli.friedman.

================
Comment at: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp:842
@@ +841,3 @@
+  // of the same struct, they do not alias.
+  if (GEP1->isInBounds() && GEP2->isInBounds()) {
+    auto Opi1 = GEP1->op_begin() + 1;
----------------
You aren't allowed to make aliasing assumptions based on the type of a GEP; it's just pointer math.  "inbounds" just means that the result has to be in bounds relative to the allocation as a whole.  See http://llvm.org/docs/LangRef.html#getelementptr-instruction .

Even if a frontend generates "nice" code, LLVM itself performs transformations which will break any assumptions based on the type of a GEP (for example, LLVM will transform a bitcast into a GEP).


Repository:
  rL LLVM

http://reviews.llvm.org/D20665





More information about the llvm-commits mailing list