@@ -688,15 +688,16 @@ struct LLVMRustSanitizerOptions {
688
688
bool SanitizeKernelAddressRecover;
689
689
};
690
690
691
- extern " C" void registerEnzyme (llvm::PassBuilder &PB);
691
+ // This symbol won't be available or used when Enzyme is not enabled
692
+ extern " C" void registerEnzyme (llvm::PassBuilder &PB) __attribute__((weak));
692
693
693
694
extern " C" LLVMRustResult LLVMRustOptimize (
694
695
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
695
696
LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
696
697
bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
697
698
bool LintIR, bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops,
698
699
bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
699
- bool EmitLifetimeMarkers, LLVMRustSanitizerOptions *SanitizerOptions,
700
+ bool EmitLifetimeMarkers, bool RunEnzyme, LLVMRustSanitizerOptions *SanitizerOptions,
700
701
const char *PGOGenPath, const char *PGOUsePath, bool InstrumentCoverage,
701
702
const char *InstrProfileOutput, const char *PGOSampleUsePath,
702
703
bool DebugInfoForProfiling, void *LlvmSelfProfiler,
@@ -1013,11 +1014,13 @@ extern "C" LLVMRustResult LLVMRustOptimize(
1013
1014
}
1014
1015
1015
1016
// now load "-enzyme" pass:
1016
- registerEnzyme (PB);
1017
- if (auto Err = PB.parsePassPipeline (MPM, " enzyme" )) {
1018
- std::string ErrMsg = toString (std::move (Err));
1019
- LLVMRustSetLastError (ErrMsg.c_str ());
1020
- return LLVMRustResult::Failure;
1017
+ if (RunEnzyme) {
1018
+ registerEnzyme (PB);
1019
+ if (auto Err = PB.parsePassPipeline (MPM, " enzyme" )) {
1020
+ std::string ErrMsg = toString (std::move (Err));
1021
+ LLVMRustSetLastError (ErrMsg.c_str ());
1022
+ return LLVMRustResult::Failure;
1023
+ }
1021
1024
}
1022
1025
1023
1026
// Upgrade all calls to old intrinsics first.
0 commit comments