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

Taewook Oh via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 13:14:42 PDT 2016


twoh added a comment.

@dberlin I meant the same level of type information as tbaa for GEP's pointer operand.

For eli's example above, if the original access were to the array field of the struct, clang generates GEP like

  %20 = load %struct.A*, %struct.A** %3, align 8
  %21 = getelementptr inbounds %struct.A, %struct.A* %20, i32 0, i32 0
  %22 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %19

But if the access were to char* casted pointer, then it is like

  %20 = load %struct.A*, %struct.A** %3, align 8
  %21 = bitcast %struct.A* %20 to i8*
  %22 = getelementptr inbounds i8, i8* %21, i64 %19

and these instructions are eventually combined to

  %10 = getelementptr inbounds %struct.A, %struct.A* %0, i64 0, i32 0, i64 %9

So by knowing the original pointer operand type of GEP, it is possible to tell if the original accesses were to the field of the struct itself or to the casted pointer, assuming that clang generates bitscast operation for every type casting.


Repository:
  rL LLVM

http://reviews.llvm.org/D20665





More information about the llvm-commits mailing list