mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-10 21:06:33 +03:00
Fix compilation with LLVM16 (#4176)
This commit is contained in:
parent
f4bbcdd07b
commit
a3eae7a815
2 changed files with 22 additions and 3 deletions
|
@ -35,8 +35,10 @@
|
|||
#include "llvm/Transforms/Utils/Cloning.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#ifdef LDC_LLVM_SUPPORTED_TARGET_SPIRV
|
||||
#if LDC_LLVM_VER < 1600
|
||||
#include "LLVMSPIRVLib/LLVMSPIRVLib.h"
|
||||
#endif
|
||||
#endif
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -65,10 +67,12 @@ void codegenModule(llvm::TargetMachine &Target, llvm::Module &m,
|
|||
|
||||
if (cb == ComputeBackend::SPIRV) {
|
||||
#ifdef LDC_LLVM_SUPPORTED_TARGET_SPIRV
|
||||
#if LDC_LLVM_VER < 1600
|
||||
IF_LOG Logger::println("running createSPIRVWriterPass()");
|
||||
std::ofstream out(filename, std::ofstream::binary);
|
||||
llvm::createSPIRVWriterPass(out)->runOnModule(m);
|
||||
IF_LOG Logger::println("Success.");
|
||||
#endif
|
||||
#else
|
||||
error(Loc(), "Trying to target SPIRV, but LDC is not built to do so!");
|
||||
#endif
|
||||
|
|
|
@ -458,19 +458,29 @@ static void addAddressSanitizerPasses(ModulePassManager &mpm,
|
|||
aso.UseAfterScope = true;
|
||||
aso.UseAfterReturn = AsanDetectStackUseAfterReturnMode::Runtime;
|
||||
|
||||
#if LDC_LLVM_VER >= 1600
|
||||
mpm.addPass(AddressSanitizerPass(aso));
|
||||
#else
|
||||
mpm.addPass(ModuleAddressSanitizerPass(aso));
|
||||
#endif
|
||||
if (verifyEach) {
|
||||
mpm.addPass(VerifierPass());
|
||||
}
|
||||
}
|
||||
|
||||
static void addMemorySanitizerPass(FunctionPassManager &fpm,
|
||||
OptimizationLevel level ) {
|
||||
static void addMemorySanitizerPass(ModulePassManager &mpm,
|
||||
FunctionPassManager &fpm,
|
||||
OptimizationLevel level ) {
|
||||
int trackOrigins = fSanitizeMemoryTrackOrigins;
|
||||
bool recover = false;
|
||||
bool kernel = false;
|
||||
#if LDC_LLVM_VER >= 1600
|
||||
mpm.addPass(MemorySanitizerPass(
|
||||
MemorySanitizerOptions{trackOrigins, recover, kernel}));
|
||||
#else
|
||||
fpm.addPass(MemorySanitizerPass(
|
||||
MemorySanitizerOptions{trackOrigins, recover, kernel}));
|
||||
#endif
|
||||
|
||||
// MemorySanitizer inserts complex instrumentation that mostly follows
|
||||
// the logic of the original code, but operates on "shadow" values.
|
||||
|
@ -494,8 +504,13 @@ static void addThreadSanitizerPass(ModulePassManager &mpm,
|
|||
|
||||
static void addSanitizerCoveragePass(ModulePassManager &mpm,
|
||||
OptimizationLevel level ) {
|
||||
#if LDC_LLVM_VER >= 1600
|
||||
mpm.addPass(SanitizerCoveragePass(
|
||||
opts::getSanitizerCoverageOptions()));
|
||||
#else
|
||||
mpm.addPass(ModuleSanitizerCoveragePass(
|
||||
opts::getSanitizerCoverageOptions()));
|
||||
#endif
|
||||
}
|
||||
// Adds PGO instrumentation generation and use passes.
|
||||
static void addPGOPasses(ModulePassManager &mpm,
|
||||
|
@ -665,7 +680,7 @@ void runOptimizationPasses(llvm::Module *M) {
|
|||
pb.registerOptimizerLastEPCallback([&](ModulePassManager &mpm,
|
||||
OptimizationLevel level) {
|
||||
FunctionPassManager fpm;
|
||||
addMemorySanitizerPass(fpm,level);
|
||||
addMemorySanitizerPass(mpm, fpm,level);
|
||||
mpm.addPass(createModuleToFunctionPassAdaptor(std::move(fpm)));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue