fix non-enzyme builds
This commit is contained in:
parent
a6e55271fb
commit
21d096184e
3 changed files with 14 additions and 8 deletions
|
@ -551,11 +551,12 @@ pub(crate) unsafe fn llvm_optimize(
|
|||
let vectorize_slp;
|
||||
let vectorize_loop;
|
||||
|
||||
let run_enzyme = cfg!(llvm_enzyme);
|
||||
// When we build rustc with enzyme/autodiff support, we want to postpone size-increasing
|
||||
// optimizations until after differentiation. FIXME(ZuseZ4): Before shipping on nightly,
|
||||
// we should make this more granular, or at least check that the user has at least one autodiff
|
||||
// call in their code, to justify altering the compilation pipeline.
|
||||
if skip_size_increasing_opts && cfg!(llvm_enzyme) {
|
||||
if skip_size_increasing_opts && run_enzyme {
|
||||
unroll_loops = false;
|
||||
vectorize_slp = false;
|
||||
vectorize_loop = false;
|
||||
|
@ -633,6 +634,7 @@ pub(crate) unsafe fn llvm_optimize(
|
|||
vectorize_loop,
|
||||
config.no_builtins,
|
||||
config.emit_lifetime_markers,
|
||||
run_enzyme,
|
||||
sanitizer_options.as_ref(),
|
||||
pgo_gen_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
|
||||
pgo_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
|
||||
|
|
|
@ -2346,6 +2346,7 @@ unsafe extern "C" {
|
|||
LoopVectorize: bool,
|
||||
DisableSimplifyLibCalls: bool,
|
||||
EmitLifetimeMarkers: bool,
|
||||
RunEnzyme: bool,
|
||||
SanitizerOptions: Option<&SanitizerOptions>,
|
||||
PGOGenPath: *const c_char,
|
||||
PGOUsePath: *const c_char,
|
||||
|
|
|
@ -688,7 +688,8 @@ struct LLVMRustSanitizerOptions {
|
|||
bool SanitizeKernelAddressRecover;
|
||||
};
|
||||
|
||||
extern "C" void registerEnzyme(llvm::PassBuilder &PB);
|
||||
// This symbol won't be available or used when Enzyme is not enabled
|
||||
extern "C" void registerEnzyme(llvm::PassBuilder &PB) __attribute__((weak));
|
||||
|
||||
extern "C" LLVMRustResult LLVMRustOptimize(
|
||||
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
|
||||
|
@ -696,7 +697,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
|
|||
bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
|
||||
bool LintIR, bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops,
|
||||
bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
|
||||
bool EmitLifetimeMarkers, LLVMRustSanitizerOptions *SanitizerOptions,
|
||||
bool EmitLifetimeMarkers, bool RunEnzyme, LLVMRustSanitizerOptions *SanitizerOptions,
|
||||
const char *PGOGenPath, const char *PGOUsePath, bool InstrumentCoverage,
|
||||
const char *InstrProfileOutput, const char *PGOSampleUsePath,
|
||||
bool DebugInfoForProfiling, void *LlvmSelfProfiler,
|
||||
|
@ -1013,11 +1014,13 @@ extern "C" LLVMRustResult LLVMRustOptimize(
|
|||
}
|
||||
|
||||
// now load "-enzyme" pass:
|
||||
registerEnzyme(PB);
|
||||
if (auto Err = PB.parsePassPipeline(MPM, "enzyme")) {
|
||||
std::string ErrMsg = toString(std::move(Err));
|
||||
LLVMRustSetLastError(ErrMsg.c_str());
|
||||
return LLVMRustResult::Failure;
|
||||
if (RunEnzyme) {
|
||||
registerEnzyme(PB);
|
||||
if (auto Err = PB.parsePassPipeline(MPM, "enzyme")) {
|
||||
std::string ErrMsg = toString(std::move(Err));
|
||||
LLVMRustSetLastError(ErrMsg.c_str());
|
||||
return LLVMRustResult::Failure;
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade all calls to old intrinsics first.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue