[llvm] [clang] [Clang][IR] add TBAA metadata on pointer, union and array types. (PR #75177)

Bushev Dmitry via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 21 08:36:24 PST 2023


================
@@ -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) {
----------------
dybv-sc wrote:

The goal of that patch is to re-utilize existing struct path TBAA metadata and amend it functionality to work for union types. Here I allow for that metadata to be generated for union members accesses, so yes there will be tbaa struct records with all members with offset 0. Later in code I adapted current struct-path-tbaa tree walkers to handle such situations where multiple fields have same offset.  

https://github.com/llvm/llvm-project/pull/75177


More information about the cfe-commits mailing list