r321250 - [CodeGen] Fix access sizes in new-format TBAA tags

Ivan A. Kosarev via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 21 00:14:16 PST 2017

Author: kosarev
Date: Thu Dec 21 00:14:16 2017
New Revision: 321250

URL: http://llvm.org/viewvc/llvm-project?rev=321250&view=rev
[CodeGen] Fix access sizes in new-format TBAA tags

The new format requires to specify both the type of the access
and its size. This patch fixes setting access sizes for TBAA tags
that denote accesses to structure members. This fix affects all
future TBAA metadata tests for the new format, so I guess we
don't need any special tests for this fix.

Differential Revision: https://reviews.llvm.org/D41452


Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=321250&r1=321249&r2=321250&view=diff
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Dec 21 00:14:16 2017
@@ -3801,8 +3801,10 @@ LValue CodeGenFunction::EmitLValueForFie
       FieldTBAAInfo.Offset +=
           Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
-    // Update the final access type.
+    // Update the final access type and size.
     FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+    FieldTBAAInfo.Size =
+        getContext().getTypeSizeInChars(FieldType).getQuantity();
   Address addr = base.getAddress();

More information about the cfe-commits mailing list