[PATCH] D116465: [SPIRV 6/6] Add one essential pass and the simplest tests

Ilia Diachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 17 16:27:44 PST 2022


iliya-diyachkov added a comment.

In general the approach works fine, but if we have no functions at module, SPIRVAsmPrinter::runOnMachineFunction() is not called and we have to output global instructions later, during AsmPrinter::doFinalization(). At this point, calling getAnalysis<SPIRVModuleAnalysis>() fails because Resolver (in Pass::getAnalysisID(AnalysisID PI)) cannot find SPIRVModuleAnalysis.

The issue can be solved by storing the analysis results in a static member of SPIRVModuleAnalysis. In such implementation, the results are available both in SPIRVAsmPrinter::runOnMachineFunction() and in SPIRVAsmPrinter::doFinalization() and we don't even need to call getAnalysis<SPIRVModuleAnalysis>() in SPIRVAsmPrinter.

I think this small trick is acceptable for the experimental backend if there is no other way to get the analysis results in doFinalization().


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116465/new/

https://reviews.llvm.org/D116465



More information about the llvm-commits mailing list