add -fopt-bisect-limit

This commit is contained in:
Guillaume Wenzek
2023-01-03 12:05:09 +01:00
committed by GitHub
parent 93bdd04e88
commit a44085dc2a
8 changed files with 35 additions and 0 deletions

View File

@@ -31,6 +31,7 @@
#include <llvm/IR/Instructions.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/OptBisect.h>
#include <llvm/IR/PassManager.h>
#include <llvm/IR/Verifier.h>
#include <llvm/InitializePasses.h>
@@ -412,6 +413,18 @@ ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref) {
return wrap(Type::getTokenTy(*unwrap(context_ref)));
}
ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) {
// In LLVM15 we just have an OptBisect singleton we can edit.
OptBisect& bisect = getOptBisector();
bisect.setLimit(limit);
// In LLVM16 OptBisect will be wrapped in OptPassGate, and will need to be set per context.
// static OptBisect _opt_bisector;
// _opt_bisector.setLimit(limit);
// unwrap(context_ref)->setOptPassGate(_opt_bisector);
}
LLVMValueRef ZigLLVMAddFunctionInAddressSpace(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy, unsigned AddressSpace) {
Function* func = Function::Create(unwrap<FunctionType>(FunctionTy), GlobalValue::ExternalLinkage, AddressSpace, Name, unwrap(M));
return wrap(func);