Re: [PATCH v2 14/50] helper-to-tcg: PrepareForOptPass, map annotations
Alessandro Di Federico via qemu development <[email protected]>
| Newsgroups | gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <20260807122651.692d3cec@spawn> |
On Thu, 30 Jul 2026 05:09:48 +0200 Anton Johansson <[email protected]> wrote: > diff --git a/subprojects/helper-to-tcg/src/Pipeline.cpp b/subprojects/helper-to-tcg/src/Pipeline.cpp > index 59de572bf6..051611b0f3 100644 > --- a/subprojects/helper-to-tcg/src/Pipeline.cpp > +++ b/subprojects/helper-to-tcg/src/Pipeline.cpp > @@ -184,7 +184,11 @@ int main(int argc, char **argv) { > MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); > } > > - MPM.addPass(PrepareForOptPass()); > > + // TODO: Get pass results via dependencies instead? Adds more boiler-plate > + // but is correlct in LLVM-terms. The more appropriate way to do this is to have an *analysis* holding the data you want to share among your custom passes (AFAIU Annotations, DebugInfo, TcgGlobals, VL). An analysis, unlike a pass (i.e., a transformation) cannot modify the IR but it can expose (non-const) data to passes. For instance the `DominatorTreeAnalysis` exposes a dominator tree that can be updated. Another good example of this is the whole LLVM backend which holds the machine IR in an analysis and the backend passes modify it. Then, in your transformation passes you can depend on the analysis and update its content. It's always tempting to create local variables in the function creating the pass manager and passing references to custom passes in the constructor, but this makes the passes unusable from `opt`, which is important for unit testing. > + AnnotationMapTy Annotations; > + MPM.addPass(PrepareForOptPass(Annotations)); > > { > FunctionPassManager FPM; -- Alessandro Di Federico rev.ng Labs