This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
compiler/rustc_llvm/llvm-wrapper
src/bootstrap/src/core/build_steps Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -688,6 +688,8 @@ struct LLVMRustSanitizerOptions {
688688 bool SanitizeKernelAddressRecover;
689689};
690690
691+ extern " C" void registerEnzyme (llvm::PassBuilder &PB);
692+
691693extern " C" LLVMRustResult LLVMRustOptimize (
692694 LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
693695 LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
@@ -1010,6 +1012,14 @@ extern "C" LLVMRustResult LLVMRustOptimize(
10101012 MPM.addPass (NameAnonGlobalPass ());
10111013 }
10121014
1015+ // 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;
1021+ }
1022+
10131023 // Upgrade all calls to old intrinsics first.
10141024 for (Module::iterator I = TheModule->begin (), E = TheModule->end (); I != E;)
10151025 UpgradeCallsToIntrinsic (&*I++); // must be post-increment, as we remove
Original file line number Diff line number Diff line change @@ -1052,9 +1052,9 @@ pub fn rustc_cargo(
10521052 // We temporarily disable linking here as part of some refactoring.
10531053 // This way, people can manually use -Z llvm-plugins and -C passes=enzyme for now.
10541054 // In a follow-up PR, we will re-enable linking here and load the pass for them.
1055- // if builder.config.llvm_enzyme {
1056- // cargo.rustflag("-l").rustflag("Enzyme-19");
1057- // }
1055+ if builder. config . llvm_enzyme {
1056+ cargo. rustflag ( "-l" ) . rustflag ( "Enzyme-19" ) ;
1057+ }
10581058
10591059 // Building with protected visibility reduces the number of dynamic relocations needed, giving
10601060 // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object
You can’t perform that action at this time.
0 commit comments