[llvm] [TBAA] Recover !tbaa for a memcpy of struct with same type fields (PR #214116)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 12:15:56 PDT 2026


================
@@ -818,7 +818,29 @@ AAMDNodes AAMDNodes::adjustForAccess(unsigned AccessSize) {
       M->getOperand(2) && isa<MDNode>(M->getOperand(2)))
     New.TBAA = cast<MDNode>(M->getOperand(2));
 
+  // The access may cover several !tbaa.struct fields (e.g. a {int, int} copy
+  // widened to an i64 load/store). If those fields share a single tag and tile
+  // [0, AccessSize) with no gaps, that tag still describes the whole access.
   New.TBAAStruct = nullptr;
+  if (New.TBAA || !M)
+    return New;
+  MDNode *CommonTag = nullptr;
+  uint64_t Offset = 0;
+  for (size_t I = 0, E = M->getNumOperands(); I < E; I += 3) {
+    ConstantInt *FieldOffset = mdconst::extract<ConstantInt>(M->getOperand(I));
----------------
andykaylor wrote:

This and the extract below will assert if the operand isn't an integer as expected.

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


More information about the llvm-commits mailing list