FlangEnzymeMLIR: a flang plugin for Enzyme's MLIR passes, loaded by FlangEnzyme #3848
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 374 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.355
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3848"
general
weight: 0.35
vchuravy
<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_
This is the smallest part of #2968 that the FIR type annotations (#3430) need, together with the FlangEnzyme loader from #3436. It adds no passes yet:
FlangEnzymeMLIRis an empty plugin shell, with the build, test and CI wiring around it. #3430 is stacked on top of this PR and adds the first pass.What is in it
FlangEnzymeMLIR-<v>, a module forflang -fc1 -load, inEnzyme/MLIR/Flang. It resolves MLIR, FIR and flang symbols from the host.FlangEnzymedlopensFlangEnzymeMLIRwhen the host exportsfir::registerPassPipelineConfigCallback, which it tests through a weak declaration. So--config=FlangEnzyme-<v>.cfgis enough, and no extra-Xflang -loadis needed. Outside flang (e.g.opt) nothing is loaded.-
ENZYME_FLANG=ONimpliesENZYME_MLIR=ONon LLVM 24 or newer, the first version with flang's pipeline callback.-
ENZYME_FLANG_MLIRbuilds the plugin. It defaults to ON whenENZYME_FLANGis on and LLVM is 24 or newer, and needs Flang's CMake package.-
ENZYME_FLANG_MLIR_LOADER(default ON) builds the loader intoFlangEnzyme; turn it off to keep the two plugins independent.%flang_fc1and%flang_enzymesubstitutions and aflang_enzyme_mlirfeature (LLVM 24 or newer).test/MLIR/FIRaddscheck-enzymemlir-firwith a smoke test that the plugin loads.enzyme-mlir.ymljob now builds flang as part of its LLVM build (withFLANG_PLUGIN_SUPPORT=ON) and configures Enzyme withENZYME_FLANGandENZYME_FORTRAN. The LLVM cache key changes so that cached builds without flang are not reused.What is left out of #2968
These parts are not needed for type annotations:
HLFIREnzymeCallLowering,EnzymeFortranAutoDiffRegistration,HLFIRAutoDiffOpInterfaceImpl.h, and thelower_fortran_callstest.fir-optpluginenzyme-fir-plugin.cpp, along with%fir_enzymeandenzyme_module.Those can follow on top of this PR if they are wanted.
Known rough edge
flang -fc1does not find the intrinsic modules by itself, so lit asks the driver for the directory of__fortran_builtins.modand passes it with-fintrinsic-modules-path. Flang's module layout is being reworked upstream; this lookup should be revisited once that settles.Why
MITgcm with flang plus Enzyme fails in TypeAnalysis on untyped integer COMMON blocks. flang's TBAA tags carry no scalar type, so TypeAnalysis gets nothing from them. The FIR type annotations in #3430 fix this by emitting
!enzyme_typefrom FIR, and they need this plugin to run inside flang.Supersedes #3436.
🤖 Generated with Claude Code