Exclude LLVM 12 from new optimizer.

This commit is contained in:
Christoffer Lerno
2022-08-28 16:51:33 +02:00
parent 4a296032ab
commit 73fd9371eb

View File

@@ -2,8 +2,10 @@
// Use of this source code is governed by the GNU LGPLv3.0 license
// a copy of which can be found in the LICENSE file.
#include <llvm-c/Error.h>
#include "llvm_codegen_internal.h"
#if LLVM_VERSION_MAJOR > 12
#include <llvm-c/Error.h>
typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef;
LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
LLVMTargetMachineRef TM,
@@ -12,6 +14,7 @@ LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void);
void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, LLVMBool VerifyEach);
void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, LLVMBool DebugLogging);
void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options);
#endif
const char* llvm_version = LLVM_VERSION_STRING;
const char* llvm_target = LLVM_DEFAULT_TARGET_TRIPLE;
@@ -847,7 +850,7 @@ static inline void llvm_opt_old(GenContext *c)
LLVMRunPassManager(pass_manager, c->module);
LLVMDisposePassManager(pass_manager);
}
#if LLVM_VERSION_MAJOR > 12
static inline void llvm_opt_new(GenContext *c)
{
LLVMPassBuilderOptionsRef options = LLVMCreatePassBuilderOptions();
@@ -887,14 +890,17 @@ static inline void llvm_opt_new(GenContext *c)
}
LLVMDisposePassBuilderOptions(options);
}
#endif
const char *llvm_codegen(void *context)
{
GenContext *c = context;
#if LLVM_VERSION_MAJOR > 12
if (active_target.use_new_optimizer)
{
llvm_opt_new(c);
}
else
#endif
{
llvm_opt_old(c);
}