[PATCH] D33328: [CodeGen] Pessimize aliasing for union members (and may-alias) objects

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 24 11:22:16 PDT 2017

rjmccall added inline comments.

Comment at: lib/CodeGen/CGExpr.cpp:1436
+    if (BaseInfo.getMayAlias())
+      TBAAInfo = CGM.getTBAAInfo(getContext().CharTy);
     llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
kparzysz wrote:
> rjmccall wrote:
> > kparzysz wrote:
> > > rjmccall wrote:
> > > > Hmm.  Should we be constructing a struct-path TBAA at all if the base may alias, as opposed to just using 'char'?
> > > I did that and got a verifier error: "Old-style TBAA is no longer allowed, use struct-path TBAA instead. fatal error: error in backend: Broken function found, compilation aborted!"
> > Oh, I haven't been paying enough attention to LLVM's TBAA changes.  It looks like they've canonicalized on always using the struct-access-style TBAA metadata, which is fine; the point is that we should be using whatever tag we would use for dereferencing a simple char*, which I believe just means passing true for ConvertTypeToTag to DecorateInstructionWithTBAA .
> With that change I'm getting another error:
> ```
> Access type node must be a valid scalar type
>   store <4 x double> %call2, <4 x double>* %b, align 32, !tbaa !8
> !8 = !{!9, !9, i64 0}
> !9 = !{!4, !4, i64 0}
> fatal error: error in backend: Broken function found, compilation aborted!
> ```
Sorry, I see now that what I said was unclear.  If you do this, you need to pass the result of getTBAAInfo(CharTy) down as the argument to DecorateInstructionWithTBAA instead of building of a TBAA struct tag.



More information about the cfe-commits mailing list