This patch moves the call for translating an MLIR module to LLVM IR to the beginning of the translation process. This enables the use of dialect attributes attached to builtin.module operations and the amendOperation() flow to initialize dialect-specific global configuration before translating the contents of the module.
Currently, this patch does not impact the generated IR on its own.
Having the TestDialect depend on these is problematic I believe as these depend on LLVM proper so will pull in LLVM IR and such as link constructs.
You'd likely see this if building with shared libs.
I think the best way to implement this is to make a separate add_mlir_translation_library just for TestToLLVMIRTranslation that depends on TestDialect, builds`TestToLLVMIRTranslation.cpp` and make mlir-translate link against that if MLIR_INCLUDE_TESTS is true in CMake.