================
@@ -4598,8 +4602,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
   if (base.getTBAAInfo().isMayAlias() ||
           rec->hasAttr<MayAliasAttr>() || FieldType->isVectorType()) {
     FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
-  } else if (rec->isUnion()) {
-    // TODO: Support TBAA for unions.
+  } else if (rec->isUnion() && !CGM.getCodeGenOpts().UnionTBAA) {
----------------
rjmccall wrote:

Well, I understand your intent and was asking whether you've put any effort in 
analyzing whether this rule actually matches the standard's aliasing rules.  
For what it's worth, I think it does, at least as currently written; IIRC, the 
committee has considered various weaker rules that permit union members to 
alias.  But it's also true that this is going to make us enforce a stricter 
rule than we have been.

This patch is both implementing the stricter rules and enabling them by 
default, right?  I think we should probably stage those separately, i.e. land 
this as an opt-in feature and then try turning it on by default in a  follow-up 
commit.  That way, if we see miscompiles from this, we can (temporarily) revert 
the small commit changing the default while we're analyzing that and not have 
to revert the whole implementation.

https://github.com/llvm/llvm-project/pull/75177
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to