Add wrapper methods, use LLVM-transforms directly.

This commit is contained in:
Christoffer Lerno
2024-07-18 12:04:02 +02:00
committed by Christoffer Lerno
parent 8285720180
commit 9dfe7ddbde
3 changed files with 7 additions and 9 deletions

View File

@@ -8,17 +8,9 @@
#include <llvm-c/Error.h>
#include <llvm-c/Comdat.h>
#include <llvm-c/Linker.h>
#include <llvm-c/Transforms/PassBuilder.h>
const char *varargslots_name = "varargslots";
const char *temp_name = "$$temp";
typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef;
LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
LLVMTargetMachineRef TM,
LLVMPassBuilderOptionsRef Options);
LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void);
void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, LLVMBool VerifyEach);
void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, LLVMBool DebugLogging);
void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options);
static void llvm_emit_constructors_and_destructors(GenContext *c);
static void llvm_codegen_setup();

View File

@@ -296,6 +296,7 @@ void gencontext_end_module(GenContext *context);
// Patched functions
LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal);
void LLVMBuilderSetFastMathFlags(LLVMBuilderRef Builder, FpOpt option);
void LLVMSetDSOLocal(LLVMValueRef Global, bool value);
#ifndef LLVMCreateTypeAttribute
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,

View File

@@ -8,6 +8,7 @@
#include "llvm-c/TargetMachine.h"
#include "llvm/Target/TargetMachine.h"
#include "lld/Common/CommonLinkerContext.h"
#include "llvm/IR/GlobalValue.h"
#define LINK_SIG \
bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, \
@@ -183,6 +184,10 @@ extern "C" {
auto machine = reinterpret_cast<llvm::TargetMachine *>(ref);
machine->Options.UseInitArray = use_init_array;
}
void LLVMSetDSOLocal(LLVMValueRef Global, bool value)
{
llvm::unwrap<llvm::GlobalValue>(Global)->setDSOLocal(value);
}
void LLVMBuilderSetFastMathFlags(LLVMBuilderRef Builder, FastMathOption option)
{