summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-05-25 11:46:40 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-05-25 11:48:00 +0100
commitba404c8f2a7e7ae25cccb66bdf378b4106d2a4df (patch)
tree33a315358fd1896b39f830802112b9006df29a20
parente5d0c730d124aa5ed380ed29162ea76329898844 (diff)
gallivm: Choose an appropriate code generation optimization level.
'Default' unless GALLIVM_DEBUG=nopt option is set.
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index bd080f397a..e02a45114b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -52,6 +52,29 @@ LLVMModuleProviderRef lp_build_provider = NULL;
LLVMTargetDataRef lp_build_target = NULL;
+/*
+ * Optimization values are:
+ * - 0: None (-O0)
+ * - 1: Less (-O1)
+ * - 2: Default (-O2, -Os)
+ * - 3: Aggressive (-O3)
+ *
+ * See also CodeGenOpt::Level in llvm/Target/TargetMachine.h
+ */
+enum LLVM_CodeGenOpt_Level {
+#if HAVE_LLVM >= 0x207
+ None, // -O0
+ Less, // -O1
+ Default, // -O2, -Os
+ Aggressive // -O3
+#else
+ Default,
+ None,
+ Aggressive
+#endif
+};
+
+
void
lp_build_init(void)
{
@@ -70,9 +93,18 @@ lp_build_init(void)
lp_build_provider = LLVMCreateModuleProviderForExistingModule(lp_build_module);
if (!lp_build_engine) {
+ enum LLVM_CodeGenOpt_Level optlevel;
char *error = NULL;
- if (LLVMCreateJITCompiler(&lp_build_engine, lp_build_provider, 1, &error)) {
+ if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) {
+ optlevel = None;
+ }
+ else {
+ optlevel = Default;
+ }
+
+ if (LLVMCreateJITCompiler(&lp_build_engine, lp_build_provider,
+ (unsigned)optlevel, &error)) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
assert(0);