[clang] [mlir] [mlir][llvm] Add tbaa_struct field attrs to the LLVM dialect (PR #238991)

Tobias Gysi via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 22:35:10 PST 2026


================
@@ -1170,6 +1206,24 @@ LogicalResult ModuleImport::convertMetadata() {
       if (aliasAnalysisNodes.TBAA)
         if (failed(processTBAAMetadata(aliasAnalysisNodes.TBAA)))
           return failure();
+      // A `!tbaa.struct` node reaches its own tags, and those tags may appear
+      // nowhere else in the module. Without walking them here the struct
+      // conversion below finds nothing and the node is declined.
+      if (aliasAnalysisNodes.TBAAStruct) {
+        const llvm::MDNode *structNode = aliasAnalysisNodes.TBAAStruct;
+        for (unsigned i = 2, e = structNode->getNumOperands(); i < e; i += 3)
+          if (auto *tag =
+                  dyn_cast_if_present<llvm::MDNode>(structNode->getOperand(i)))
+            if (failed(processTBAAMetadata(tag)))
----------------
gysit wrote:

Ok I see the failure handling is the reason for doing this outside of `convertTBAAStructMetadata`. It would have been nice to check earlier the operands size is indeed a multiple of three...

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


More information about the cfe-commits mailing list