Index: bindings/ocaml/transforms/ipo/ipo_ocaml.c =================================================================== --- bindings/ocaml/transforms/ipo/ipo_ocaml.c +++ bindings/ocaml/transforms/ipo/ipo_ocaml.c @@ -31,6 +31,12 @@ return Val_unit; } +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_merge_functions(LLVMPassManagerRef PM) { + LLVMAddMergeFunctionsPass(PM); + return Val_unit; +} + /* [`Module] Llvm.PassManager.t -> unit */ CAMLprim value llvm_add_dead_arg_elimination(LLVMPassManagerRef PM) { LLVMAddDeadArgEliminationPass(PM); Index: bindings/ocaml/transforms/ipo/llvm_ipo.ml =================================================================== --- bindings/ocaml/transforms/ipo/llvm_ipo.ml +++ bindings/ocaml/transforms/ipo/llvm_ipo.ml @@ -12,6 +12,9 @@ external add_constant_merge : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_constant_merge" +external add_merge_functions + : [ `Module ] Llvm.PassManager.t -> unit + = "llvm_add_merge_functions" external add_dead_arg_elimination : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_dead_arg_elimination" Index: bindings/ocaml/transforms/ipo/llvm_ipo.mli =================================================================== --- bindings/ocaml/transforms/ipo/llvm_ipo.mli +++ bindings/ocaml/transforms/ipo/llvm_ipo.mli @@ -21,6 +21,11 @@ : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_constant_merge" +(** See the [llvm::createMergeFunctionsPass] function. *) +external add_merge_functions + : [ `Module ] Llvm.PassManager.t -> unit + = "llvm_add_merge_functions" + (** See the [llvm::createDeadArgEliminationPass] function. *) external add_dead_arg_elimination : [ `Module ] Llvm.PassManager.t -> unit Index: bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml =================================================================== --- bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml +++ bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml @@ -9,6 +9,9 @@ external add_aggressive_dce : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_aggressive_dce" +external add_dce + : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit + = "llvm_add_dce" external add_alignment_from_assumptions : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_alignment_from_assumptions" Index: bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli =================================================================== --- bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli +++ bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli @@ -16,6 +16,11 @@ : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_aggressive_dce" +(** See the [llvm::createDCEPass] function. *) +external add_dce + : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit + = "llvm_add_dce" + (** See the [llvm::createAlignmentFromAssumptionsPass] function. *) external add_alignment_from_assumptions : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit Index: bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c =================================================================== --- bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c +++ bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c @@ -26,6 +26,11 @@ return Val_unit; } +CAMLprim value llvm_add_dce(LLVMPassManagerRef PM) { + LLVMAddDCEPass(PM); + return Val_unit; +} + /* [ unit */ CAMLprim value llvm_add_alignment_from_assumptions(LLVMPassManagerRef PM) { LLVMAddAlignmentFromAssumptionsPass(PM); Index: include/llvm-c/Transforms/IPO.h =================================================================== --- include/llvm-c/Transforms/IPO.h +++ include/llvm-c/Transforms/IPO.h @@ -34,6 +34,9 @@ /** See llvm::createConstantMergePass function. */ void LLVMAddConstantMergePass(LLVMPassManagerRef PM); +/** See llvm::createMergeFunctionsPass function. */ +void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM); + /** See llvm::createCalledValuePropagationPass function. */ void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM); Index: include/llvm-c/Transforms/Scalar.h =================================================================== --- include/llvm-c/Transforms/Scalar.h +++ include/llvm-c/Transforms/Scalar.h @@ -35,6 +35,9 @@ /** See llvm::createAggressiveDCEPass function. */ void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM); +/** See llvm::createDeadCodeEliminationPass function. */ +void LLVMAddDCEPass(LLVMPassManagerRef PM); + /** See llvm::createBitTrackingDCEPass function. */ void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM); Index: lib/Transforms/IPO/IPO.cpp =================================================================== --- lib/Transforms/IPO/IPO.cpp +++ lib/Transforms/IPO/IPO.cpp @@ -114,6 +114,10 @@ unwrap(PM)->add(createIPSCCPPass()); } +void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createMergeFunctionsPass()); +} + void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) { auto PreserveMain = [=](const GlobalValue &GV) { return AllButMain && GV.getName() == "main"; Index: lib/Transforms/Scalar/Scalar.cpp =================================================================== --- lib/Transforms/Scalar/Scalar.cpp +++ lib/Transforms/Scalar/Scalar.cpp @@ -123,6 +123,10 @@ unwrap(PM)->add(createAggressiveDCEPass()); } +void LLVMAddDCEPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createDeadCodeEliminationPass()); +} + void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createBitTrackingDCEPass()); }