[PATCH] D26438: [Verifier] Add verification for TBAA metadata

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 19:52:02 PST 2016


sanjoy added a comment.

In https://reviews.llvm.org/D26438#591414, @manmanren wrote:

> > The tag for the load instruction is `!2` whose access type is `!7` == `!{!"float", !5, i64 0}`.
>
> !7 is a scalar type node, it is a float, right?


Perhaps we are talking past each other, but are you concluding that it is scalar by looking at its name?  I thought the names themselves were not supposed to be significant within the TBAA type system.

Structurally, it is exactly a struct that with a single `char` field.  If I compile

  struct S {
       int i;
       float f;
  };
  
  struct S2 {
       char c;
  };
  
  float f(struct S* s, struct S2* s2) {
       return s->f + s2->c;
  }

then I get:

  !0 = !{i32 1, !"PIC Level", i32 2}
  !1 = !{!"clang version 4.0.0 (http://llvm.org/git/clang.git b74377b0a34a33cb3c7b565f0e543cd3e56b3f6b) (llvm/trunk 286280)"}
  !2 = !{!3, !7, i64 4}
  !3 = !{!"S", !4, i64 0, !7, i64 4}
  !4 = !{!"int", !5, i64 0}
  !5 = !{!"omnipotent char", !6, i64 0}
  !6 = !{!"Simple C/C++ TBAA"}
  !7 = !{!"float", !5, i64 0}
  !8 = !{!9, !5, i64 0}
  !9 = !{!"S2", !5, i64 0}

with `!2` as the access tag for `s->f` and `!8` as the access tag for `s2->c`.  `!2` has `!7` as its access type (which means it must be a scalar type), which is indistinguishable from the struct type node `!9`, except from its name.  Without a priori knowledge of what `"float"` and `"S2"` mean, we can't conclude one way or the other.


https://reviews.llvm.org/D26438





More information about the llvm-commits mailing list