radv: port to use common passmgr code.
authorDave Airlie <airlied@redhat.com>
Tue, 26 Jun 2018 23:02:25 +0000 (09:02 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 Jul 2018 19:30:34 +0000 (05:30 +1000)
This adds a inline always pass, but otherwise should work the
same.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_util.c
src/amd/vulkan/radv_nir_to_llvm.c

index b25f9e3e6ddd0d1de2509f2a50b307cda5ead3de..01852dbff4664f36e238b7efc56cd502ee4af39a 100644 (file)
@@ -172,8 +172,9 @@ LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_inf
        if (!passmgr)
                return NULL;
 
-       LLVMAddTargetLibraryInfo(target_library_info,
-                                passmgr);
+       if (target_library_info)
+               LLVMAddTargetLibraryInfo(target_library_info,
+                                        passmgr);
 
        if (check_ir)
                LLVMAddVerifierPass(passmgr);
index ce6d5e1547d4fda53e20aebc67751f01b3aabb5a..dbbf2c13d6688ff777e7564dd7ff99cb9c6efdb5 100644 (file)
@@ -2996,30 +2996,10 @@ static void ac_llvm_finalize_module(struct radv_shader_context *ctx,
                                    const struct radv_nir_compiler_options *options)
 {
        LLVMPassManagerRef passmgr;
-       /* Create the pass manager */
-       passmgr = LLVMCreateFunctionPassManagerForModule(
-                                                       ctx->ac.module);
-
-       if (options->check_ir)
-               LLVMAddVerifierPass(passmgr);
-
-       /* This pass should eliminate all the load and store instructions */
-       LLVMAddPromoteMemoryToRegisterPass(passmgr);
-
-       /* Add some optimization passes */
-       LLVMAddScalarReplAggregatesPass(passmgr);
-       LLVMAddLICMPass(passmgr);
-       LLVMAddAggressiveDCEPass(passmgr);
-       LLVMAddCFGSimplificationPass(passmgr);
-       /* This is recommended by the instruction combining pass. */
-       LLVMAddEarlyCSEMemSSAPass(passmgr);
-       LLVMAddInstructionCombiningPass(passmgr);
-
-       /* Run the pass */
-       LLVMInitializeFunctionPassManager(passmgr);
-       LLVMRunFunctionPassManager(passmgr, ctx->main_function);
-       LLVMFinalizeFunctionPassManager(passmgr);
 
+       passmgr = ac_create_passmgr(NULL, options->check_ir);
+
+       LLVMRunPassManager(passmgr, ctx->ac.module);
        LLVMDisposeBuilder(ctx->ac.builder);
        LLVMDisposePassManager(passmgr);