diff --git a/llvm/include/llvm-c/Transforms/Scalar.h b/llvm/include/llvm-c/Transforms/Scalar.h --- a/llvm/include/llvm-c/Transforms/Scalar.h +++ b/llvm/include/llvm-c/Transforms/Scalar.h @@ -67,6 +67,9 @@ /** See llvm::createInstructionCombiningPass function. */ void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM); +/** See llvm::createInstSimplifyLegacyPass function. */ +void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM); + /** See llvm::createJumpThreadingPass function. */ void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM); diff --git a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp --- a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp +++ b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp @@ -17,12 +17,14 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" +#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Type.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/Local.h" + using namespace llvm; #define DEBUG_TYPE "instsimplify" @@ -129,6 +131,10 @@ return new InstSimplifyLegacyPass(); } +void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createInstSimplifyLegacyPass()); +} + PreservedAnalyses InstSimplifyPass::run(Function &F, FunctionAnalysisManager &AM) { auto &DT = AM.getResult(F);