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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 09:50:14 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) {
----------------
fhahn wrote:

I think it looks like the code still has `I < E` instead of `I + 2 < E` as suggested by @andykaylor 

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


More information about the llvm-commits mailing list