[MLIR] Type tree attribute and its translation to LLVM Enzyme's type metadata #3893
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 396 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3893"
general
weight: 0.35
vchuravy
Split out of #3430 (review: emit MLIR attributes and convert them to LLVM metadata instead of round-tripping through strings). Nothing Fortran-specific here; #3430 is rebased on top of this.
#enzyme.type_treeis Enzyme's TypeTree as a nested attribute in the enzyme dialect. A node has the concrete type of the value, if known (integer,pointer,anything, or a floating-point type), and the subtrees of the memory it points to, each at a byte offset, with -1 for every offset:TypeTreeKindenum (EnzymeEnums.td), so the dialect does not include LLVM Enzyme'sBaseType.h.Attributes, verified by the dialect (
verifyOperationAttribute,verifyRegionArgAttribute) rather than by the translation:enzyme.type: a type tree, on any op or function argument.enzyme.arg_types: on a call (CallOpInterface), one type tree orunitper argument operand.enzyme.ret_types: on a function (FunctionOpInterface), one type tree orunitper result.The names are
EnzymeDialect::getTypeTreeAttrName.MLIREnzymeToLLVMIRTranslation(Target/EnzymeToLLVMIRTranslation.cpp,registerEnzymeDialectTranslation) turns them into what LLVM Enzyme's type analysis already reads, without parsing anything:enzyme.typeon a global →!enzyme_typemetadata; on another op →!enzyme_typeon every instruction it lowers to; on a function argument → its"enzyme_type"attribute.enzyme.arg_types→ the"enzyme_type"of each call argument.enzyme.ret_types→ the"enzyme_type"of the function result.The metadata is built recursively from the tree in the encoding of
TypeTree::toMD."enzyme_type"attributes stay strings inTypeTree::strsyntax ({[-1]:Pointer, [-1,0]:Float@double}), because LLVM Enzyme reads them as strings. Concrete type names come fromConcreteType, which is included asTypeAnalysis/ConcreteType.h.enzymemlir-translategets an-enzyme-to-llvmirtranslation that registers this interface;-activity-to-llvmkeeps its own, since a dialect can have only one LLVM translation interface.Tests:
MLIR/Passes/type_tree_attr.mlir: round trip, subtree sorting, and one negative case per verifier diagnostic.MLIR/Passes/type_tree_to_llvm.mlir: global, argument, result, call and instruction translation. It requires the new lit featureenzymemlir-translate, which is set when the%etranslatebinary exists.Tested locally against LLVM main (with the 4 LLVM 24 port commits reverted to match that toolchain):
check-enzymemlirpasses, 239 passed and 1 expected failure, including both new tests.---
_Generated by Claude Code_