This patch provides an alternative approach to D144883, with the goal of
supporting the processing of dialect attributes attached to top-level module-
type operations during MLIR-to-LLVMIR lowering.
Based on reviewer comments, this approach modifies the
mlir::translateModuleToLLVMIR() function to call
ModuleTranslation::convertOperation() on the top-level operation, after its
body has been lowered. This, in turn, will get the
LLVMTranslationDialectInterface object associated to that operation's dialect
before trying to use it for lowering prior to processing dialect attributes
attached to the operation.
Since there are no LLVMTranslationDialectInterfaces for the builtin and GPU
dialects, which define their own module-type operations, this patch also adds
and registers them. Their purpose is to just succeed when processing module
operations, to allow the lowering process to continue and to prevent the
introduction of failures related to not finding such interfaces.
The mentioned interface is added to the builtin dialect, differently to every
other dialect, on creation. Alternatively, it would require substantial changes
to be registered before any lowering to LLVM IR can be done.
Nit: this should be one line.