Open Kreijstal opened 2 months ago
so I used an llm to try to fix it lol (this makes llvm crate compile)
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Transforms/Vectorize/SLPVectorizer.h"
#include <iostream>
#include <mutex>
#include <stdlib.h>
using namespace llvm;
extern "C" {
void LLVMSetPartialFastMath(LLVMValueRef V) {
if (auto I = dyn_cast<Instruction>(unwrap<Value>(V))) {
I->setFast(true);
I->setHasAllowReassoc(true);
I->setHasAllowReciprocal(true);
I->setHasAllowContract(true);
}
}
void LLVMSetFastMath(LLVMValueRef V) {
if (auto I = dyn_cast<Instruction>(unwrap<Value>(V))) {
I->setFast(true);
}
}
void LLVMPurgeAttrs(LLVMValueRef V) {
if (auto func = dyn_cast<Function>(unwrap<Value>(V))) {
func->setAttributes(AttributeList());
}
}
void addSLPVectorizerPass(ModulePassManager &MPM) {
FunctionPassManager FPM;
FPM.addPass(SLPVectorizerPass());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
void setupOptimizationPipeline(Module &M) {
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;
PassBuilder PB;
PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
PB.registerFunctionAnalyses(FAM);
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
ModulePassManager MPM = PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2);
addSLPVectorizerPass(MPM);
MPM.run(M, MAM);
}
} // extern "C"
did export LLVM_LINK_SHARED=1 and tried to compile but it seems rust attempts to use llvm objects that aren't there anymore..
well in llvm 18 you don't have passmanagerbuilder, so this won't work with modern llvm
https://github.com/pascalkuthe/OpenVAF/blob/a9697ae7780518f021f9f64e819b3a57033bd39f/openvaf/llvm/wrapper/OpenVafWrapper.cpp#L5