#include <llvm-c/Transforms/Utils.h>
#endif
#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 */
#if HAVE_LLVM >= 0x0306
gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module);
if (!gallivm->passmgr)
return FALSE;
+
+#if GALLIVM_HAVE_CORO
+ gallivm->cgpassmgr = LLVMCreatePassManager();
+#endif
/*
* TODO: some per module pass manager with IPO passes might be helpful -
* the generated texture functions may benefit from inlining if they are
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) {
/*
* TODO: Evaluate passes some more - keeping in mind
LLVMAddConstantPropagationPass(gallivm->passmgr);
LLVMAddInstructionCombiningPass(gallivm->passmgr);
LLVMAddGVNPass(gallivm->passmgr);
+#if GALLIVM_HAVE_CORO
+ LLVMAddCoroCleanupPass(gallivm->passmgr);
+#endif
}
else {
/* We need at least this pass to prevent the backends to fail in
LLVMDisposePassManager(gallivm->passmgr);
}
+#if GALLIVM_HAVE_CORO
+ if (gallivm->cgpassmgr) {
+ LLVMDisposePassManager(gallivm->cgpassmgr);
+ }
+#endif
+
if (gallivm->engine) {
/* This will already destroy any associated module */
LLVMDisposeExecutionEngine(gallivm->engine);
gallivm->target = NULL;
gallivm->module = NULL;
gallivm->module_name = NULL;
+ gallivm->cgpassmgr = NULL;
gallivm->passmgr = NULL;
gallivm->context = NULL;
gallivm->builder = NULL;
if (gallivm_debug & GALLIVM_DEBUG_PERF)
time_begin = os_time_get();
+#if GALLIVM_HAVE_CORO
+ LLVMRunPassManager(gallivm->cgpassmgr, gallivm->module);
+#endif
/* Run optimization passes */
LLVMInitializeFunctionPassManager(gallivm->passmgr);
func = LLVMGetFirstFunction(gallivm->module);