From d60eaa930d3818bc481e4b1621a8aeb4716bb1d1 Mon Sep 17 00:00:00 2001 From: Matt Bolitho Date: Fri, 18 Oct 2024 00:21:04 +0100 Subject: [PATCH 1/3] Removes unused PB0 variable --- enzyme/Enzyme/Enzyme.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/enzyme/Enzyme/Enzyme.cpp b/enzyme/Enzyme/Enzyme.cpp index 1f902396e6d..04dbf66516f 100644 --- a/enzyme/Enzyme/Enzyme.cpp +++ b/enzyme/Enzyme/Enzyme.cpp @@ -3333,8 +3333,7 @@ extern cl::opt SetLicmMssaOptCap; void augmentPassBuilder(llvm::PassBuilder &PB) { - auto PB0 = new llvm::PassBuilder(PB); - auto prePass = [PB0](ModulePassManager &MPM, OptimizationLevel Level) { + auto prePass = [](ModulePassManager &MPM, OptimizationLevel Level) { FunctionPassManager OptimizePM; OptimizePM.addPass(Float2IntPass()); OptimizePM.addPass(LowerConstantIntrinsicsPass()); From de07e24da9da421a17c0177e407dec0e82fc8638 Mon Sep 17 00:00:00 2001 From: Matt Bolitho Date: Fri, 18 Oct 2024 18:58:48 +0100 Subject: [PATCH 2/3] Removes unused modrefinfo operator<< --- enzyme/Enzyme/EnzymeLogic.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/enzyme/Enzyme/EnzymeLogic.cpp b/enzyme/Enzyme/EnzymeLogic.cpp index ce9bdc3ef43..ccd6a682121 100644 --- a/enzyme/Enzyme/EnzymeLogic.cpp +++ b/enzyme/Enzyme/EnzymeLogic.cpp @@ -1352,21 +1352,6 @@ bool shouldAugmentCall(CallInst *op, const GradientUtils *gutils) { return modifyPrimal; } -static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - ModRefInfo mri) { - if (mri == ModRefInfo::NoModRef) - return os << "nomodref"; - else if (mri == ModRefInfo::ModRef) - return os << "modref"; - else if (mri == ModRefInfo::Mod) - return os << "mod"; - else if (mri == ModRefInfo::Ref) - return os << "ref"; - else - llvm_unreachable("unknown modref"); - return os; -} - bool legalCombinedForwardReverse( CallInst *origop, const std::map &replacedReturns, From a586c7467bfe6ddd9376de842e45ced05ba0df79 Mon Sep 17 00:00:00 2001 From: Matt Bolitho Date: Fri, 18 Oct 2024 21:14:01 +0100 Subject: [PATCH 3/3] Adds missing header guards --- enzyme/Enzyme/ActivityAnalysisPrinter.h | 6 ++++++ enzyme/Enzyme/AdjointGenerator.h | 6 ++++++ enzyme/Enzyme/Enzyme.h | 5 +++++ enzyme/Enzyme/JLInstSimplify.h | 6 ++++++ enzyme/Enzyme/MLIR/Interfaces/GradientUtilsReverse.h | 5 +++++ enzyme/Enzyme/PreserveNVVM.h | 5 +++++ enzyme/Enzyme/TypeAnalysis/TypeAnalysisPrinter.h | 5 +++++ 7 files changed, 38 insertions(+) diff --git a/enzyme/Enzyme/ActivityAnalysisPrinter.h b/enzyme/Enzyme/ActivityAnalysisPrinter.h index 9ea19ded8dd..0855dd32a43 100644 --- a/enzyme/Enzyme/ActivityAnalysisPrinter.h +++ b/enzyme/Enzyme/ActivityAnalysisPrinter.h @@ -22,6 +22,10 @@ // results of a given function. // //===----------------------------------------------------------------------===// + +#ifndef ENZYME_ACTIVITY_ANALYSIS_PRINTER_H +#define ENZYME_ACTIVITY_ANALYSIS_PRINTER_H + #include #include "llvm/IR/PassManager.h" @@ -46,3 +50,5 @@ class ActivityAnalysisPrinterNewPM final static bool isRequired() { return true; } }; + +#endif // ENZYME_ACTIVITY_ANALYSIS_PRINTER_H diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index bc1eab9283e..ee62db6576d 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -23,6 +23,10 @@ // LLVM instructions. // //===----------------------------------------------------------------------===// + +#ifndef ENZYME_ADJOINT_GENERATOR_H +#define ENZYME_ADJOINT_GENERATOR_H + #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" @@ -6414,3 +6418,5 @@ class AdjointGenerator : public llvm::InstVisitor { subretused); } }; + +#endif // ENZYME_ADJOINT_GENERATOR_H diff --git a/enzyme/Enzyme/Enzyme.h b/enzyme/Enzyme/Enzyme.h index c3e9673d6bd..3bbef06b131 100644 --- a/enzyme/Enzyme/Enzyme.h +++ b/enzyme/Enzyme/Enzyme.h @@ -24,8 +24,13 @@ // //===----------------------------------------------------------------------===// +#ifndef ENZYME_H +#define ENZYME_H + #include "llvm/Pass.h" #include "llvm/Passes/PassBuilder.h" llvm::ModulePass *createEnzymePass(bool PostOpt = false); void augmentPassBuilder(llvm::PassBuilder &PB); + +#endif // ENZYME_H diff --git a/enzyme/Enzyme/JLInstSimplify.h b/enzyme/Enzyme/JLInstSimplify.h index c1ebd77f85c..9140d3b2656 100644 --- a/enzyme/Enzyme/JLInstSimplify.h +++ b/enzyme/Enzyme/JLInstSimplify.h @@ -17,6 +17,10 @@ // } // //===----------------------------------------------------------------------===// + +#ifndef ENZYME_JL_INST_SIMPLIFY_H +#define ENZYME_JL_INST_SIMPLIFY_H + #include #include "llvm/IR/PassManager.h" @@ -41,3 +45,5 @@ class JLInstSimplifyNewPM final static bool isRequired() { return true; } }; + +#endif // ENZYME_JL_INST_SIMPLIFY_H diff --git a/enzyme/Enzyme/MLIR/Interfaces/GradientUtilsReverse.h b/enzyme/Enzyme/MLIR/Interfaces/GradientUtilsReverse.h index f1a81a7510a..b6b63c6d13d 100644 --- a/enzyme/Enzyme/MLIR/Interfaces/GradientUtilsReverse.h +++ b/enzyme/Enzyme/MLIR/Interfaces/GradientUtilsReverse.h @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +#ifndef ENZYME_MLIR_INTERFACES_GRADIENT_UTILS_REVERSE_H +#define ENZYME_MLIR_INTERFACES_GRADIENT_UTILS_REVERSE_H + #include "mlir/IR/IRMapping.h" #include "mlir/Interfaces/FunctionInterfaces.h" @@ -71,3 +74,5 @@ class MGradientUtilsReverse : public MDiffeGradientUtils { } // namespace enzyme } // namespace mlir + +#endif // ENZYME_MLIR_INTERFACES_GRADIENT_UTILS_REVERSE_H diff --git a/enzyme/Enzyme/PreserveNVVM.h b/enzyme/Enzyme/PreserveNVVM.h index c8aca99e5ec..46b5282df5e 100644 --- a/enzyme/Enzyme/PreserveNVVM.h +++ b/enzyme/Enzyme/PreserveNVVM.h @@ -24,6 +24,9 @@ // //===----------------------------------------------------------------------===// +#ifndef ENZYME_PRESERVE_NVVM_H +#define ENZYME_PRESERVE_NVVM_H + #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassPlugin.h" @@ -50,3 +53,5 @@ class PreserveNVVMNewPM final static bool isRequired() { return true; } }; + +#endif // ENZYME_PRESERVE_NVVM_H diff --git a/enzyme/Enzyme/TypeAnalysis/TypeAnalysisPrinter.h b/enzyme/Enzyme/TypeAnalysis/TypeAnalysisPrinter.h index 9f996316fa1..d7f7ff3cf2f 100644 --- a/enzyme/Enzyme/TypeAnalysis/TypeAnalysisPrinter.h +++ b/enzyme/Enzyme/TypeAnalysis/TypeAnalysisPrinter.h @@ -23,6 +23,9 @@ // //===----------------------------------------------------------------------===// +#ifndef ENZYME_TYPE_ANALYSIS_TYPE_ANALYSIS_PRINTER_H +#define ENZYME_TYPE_ANALYSIS_TYPE_ANALYSIS_PRINTER_H + #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassPlugin.h" @@ -45,3 +48,5 @@ class TypeAnalysisPrinterNewPM final static bool isRequired() { return true; } }; + +#endif // ENZYME_TYPE_ANALYSIS_TYPE_ANALYSIS_PRINTER_H