mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 09:30:13 +01:00
gallivm: add coroutine pass manager support
coroutines require a proper pass manager, so add the passes to the correct places Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
9cf1340e4f
commit
d32690b43c
3 changed files with 32 additions and 1 deletions
|
|
@ -95,6 +95,11 @@ typedef void *LLVMMCJITMemoryManagerRef;
|
||||||
#define LLVMInsertBasicBlock ILLEGAL_LLVM_FUNCTION
|
#define LLVMInsertBasicBlock ILLEGAL_LLVM_FUNCTION
|
||||||
#define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION
|
#define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION
|
||||||
|
|
||||||
|
#if HAVE_LLVM >= 0x0800
|
||||||
|
#define GALLIVM_HAVE_CORO 1
|
||||||
|
#else
|
||||||
|
#define GALLIVM_HAVE_CORO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before LLVM 3.4 LLVMSetAlignment only supported GlobalValue, not
|
* Before LLVM 3.4 LLVMSetAlignment only supported GlobalValue, not
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@
|
||||||
#include <llvm-c/Transforms/Utils.h>
|
#include <llvm-c/Transforms/Utils.h>
|
||||||
#endif
|
#endif
|
||||||
#include <llvm-c/BitWriter.h>
|
#include <llvm-c/BitWriter.h>
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
#include <llvm-c/Transforms/Coroutines.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Only MCJIT is available as of LLVM SVN r216982 */
|
/* Only MCJIT is available as of LLVM SVN r216982 */
|
||||||
#if HAVE_LLVM >= 0x0306
|
#if HAVE_LLVM >= 0x0306
|
||||||
|
|
@ -125,6 +127,10 @@ create_pass_manager(struct gallivm_state *gallivm)
|
||||||
gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module);
|
gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module);
|
||||||
if (!gallivm->passmgr)
|
if (!gallivm->passmgr)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
gallivm->cgpassmgr = LLVMCreatePassManager();
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* TODO: some per module pass manager with IPO passes might be helpful -
|
* TODO: some per module pass manager with IPO passes might be helpful -
|
||||||
* the generated texture functions may benefit from inlining if they are
|
* the generated texture functions may benefit from inlining if they are
|
||||||
|
|
@ -144,6 +150,12 @@ create_pass_manager(struct gallivm_state *gallivm)
|
||||||
free(td_str);
|
free(td_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
LLVMAddCoroEarlyPass(gallivm->cgpassmgr);
|
||||||
|
LLVMAddCoroSplitPass(gallivm->cgpassmgr);
|
||||||
|
LLVMAddCoroElidePass(gallivm->cgpassmgr);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((gallivm_perf & GALLIVM_PERF_NO_OPT) == 0) {
|
if ((gallivm_perf & GALLIVM_PERF_NO_OPT) == 0) {
|
||||||
/*
|
/*
|
||||||
* TODO: Evaluate passes some more - keeping in mind
|
* TODO: Evaluate passes some more - keeping in mind
|
||||||
|
|
@ -170,6 +182,9 @@ create_pass_manager(struct gallivm_state *gallivm)
|
||||||
LLVMAddConstantPropagationPass(gallivm->passmgr);
|
LLVMAddConstantPropagationPass(gallivm->passmgr);
|
||||||
LLVMAddInstructionCombiningPass(gallivm->passmgr);
|
LLVMAddInstructionCombiningPass(gallivm->passmgr);
|
||||||
LLVMAddGVNPass(gallivm->passmgr);
|
LLVMAddGVNPass(gallivm->passmgr);
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
LLVMAddCoroCleanupPass(gallivm->passmgr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* We need at least this pass to prevent the backends to fail in
|
/* We need at least this pass to prevent the backends to fail in
|
||||||
|
|
@ -193,6 +208,12 @@ gallivm_free_ir(struct gallivm_state *gallivm)
|
||||||
LLVMDisposePassManager(gallivm->passmgr);
|
LLVMDisposePassManager(gallivm->passmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
if (gallivm->cgpassmgr) {
|
||||||
|
LLVMDisposePassManager(gallivm->cgpassmgr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gallivm->engine) {
|
if (gallivm->engine) {
|
||||||
/* This will already destroy any associated module */
|
/* This will already destroy any associated module */
|
||||||
LLVMDisposeExecutionEngine(gallivm->engine);
|
LLVMDisposeExecutionEngine(gallivm->engine);
|
||||||
|
|
@ -219,6 +240,7 @@ gallivm_free_ir(struct gallivm_state *gallivm)
|
||||||
gallivm->target = NULL;
|
gallivm->target = NULL;
|
||||||
gallivm->module = NULL;
|
gallivm->module = NULL;
|
||||||
gallivm->module_name = NULL;
|
gallivm->module_name = NULL;
|
||||||
|
gallivm->cgpassmgr = NULL;
|
||||||
gallivm->passmgr = NULL;
|
gallivm->passmgr = NULL;
|
||||||
gallivm->context = NULL;
|
gallivm->context = NULL;
|
||||||
gallivm->builder = NULL;
|
gallivm->builder = NULL;
|
||||||
|
|
@ -610,6 +632,9 @@ gallivm_compile_module(struct gallivm_state *gallivm)
|
||||||
if (gallivm_debug & GALLIVM_DEBUG_PERF)
|
if (gallivm_debug & GALLIVM_DEBUG_PERF)
|
||||||
time_begin = os_time_get();
|
time_begin = os_time_get();
|
||||||
|
|
||||||
|
#if GALLIVM_HAVE_CORO
|
||||||
|
LLVMRunPassManager(gallivm->cgpassmgr, gallivm->module);
|
||||||
|
#endif
|
||||||
/* Run optimization passes */
|
/* Run optimization passes */
|
||||||
LLVMInitializeFunctionPassManager(gallivm->passmgr);
|
LLVMInitializeFunctionPassManager(gallivm->passmgr);
|
||||||
func = LLVMGetFirstFunction(gallivm->module);
|
func = LLVMGetFirstFunction(gallivm->module);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ struct gallivm_state
|
||||||
LLVMExecutionEngineRef engine;
|
LLVMExecutionEngineRef engine;
|
||||||
LLVMTargetDataRef target;
|
LLVMTargetDataRef target;
|
||||||
LLVMPassManagerRef passmgr;
|
LLVMPassManagerRef passmgr;
|
||||||
|
LLVMPassManagerRef cgpassmgr;
|
||||||
LLVMContextRef context;
|
LLVMContextRef context;
|
||||||
LLVMBuilderRef builder;
|
LLVMBuilderRef builder;
|
||||||
LLVMMCJITMemoryManagerRef memorymgr;
|
LLVMMCJITMemoryManagerRef memorymgr;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue