Skip to content

Commit 9aea41c

Browse files
committed
fixing flag passing for PrintTAFn function
1 parent a968666 commit 9aea41c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,10 @@ struct LLVMRustSanitizerOptions {
700700
#ifdef ENZYME
701701
extern "C" void registerEnzymeAndPassPipeline(llvm::PassBuilder &PB,
702702
/* augmentPassBuilder */ bool);
703+
704+
extern "C" {
705+
extern llvm::cl::opt<std::string> EnzymeFunctionToAnalyze;
706+
}
703707
#endif
704708

705709
extern "C" LLVMRustResult LLVMRustOptimize(
@@ -1069,6 +1073,15 @@ extern "C" LLVMRustResult LLVMRustOptimize(
10691073
return LLVMRustResult::Failure;
10701074
}
10711075

1076+
// Check if PrintTAFn was used and add type analysis pass if needed
1077+
if (!EnzymeFunctionToAnalyze.empty()) {
1078+
if (auto Err = PB.parsePassPipeline(MPM, "print-type-analysis")) {
1079+
std::string ErrMsg = toString(std::move(Err));
1080+
LLVMRustSetLastError(ErrMsg.c_str());
1081+
return LLVMRustResult::Failure;
1082+
}
1083+
}
1084+
10721085
if (PrintAfterEnzyme) {
10731086
// Handle the Rust flag `-Zautodiff=PrintModAfter`.
10741087
std::string Banner = "Module after EnzymeNewPM";

0 commit comments

Comments
 (0)