[llvm] r373170 - [LLVM-C][Ocaml] Add MergeFunctions and DCE pass
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 29 09:06:22 PDT 2019
Author: hiraditya
Date: Sun Sep 29 09:06:22 2019
New Revision: 373170
URL: http://llvm.org/viewvc/llvm-project?rev=373170&view=rev
Log:
[LLVM-C][Ocaml] Add MergeFunctions and DCE pass
MergeFunctions and DCE pass are missing from OCaml/C-api. This patch
adds them.
Differential Revision: https://reviews.llvm.org/D65071
Reviewers: whitequark, hiraditya, deadalnix
Reviewed By: whitequark
Subscribers: llvm-commits
Tags: #llvm
Authored by: kren1
Modified:
llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c
llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml
llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli
llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
llvm/trunk/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
llvm/trunk/include/llvm-c/Transforms/IPO.h
llvm/trunk/include/llvm-c/Transforms/Scalar.h
llvm/trunk/lib/Transforms/IPO/IPO.cpp
llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
Modified: llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c Sun Sep 29 09:06:22 2019
@@ -32,6 +32,12 @@ CAMLprim value llvm_add_constant_merge(L
}
/* [`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);
return Val_unit;
Modified: llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml (original)
+++ llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml Sun Sep 29 09:06:22 2019
@@ -12,6 +12,9 @@ external add_argument_promotion
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"
Modified: llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli (original)
+++ llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli Sun Sep 29 09:06:22 2019
@@ -21,6 +21,11 @@ external add_constant_merge
: [ `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
Modified: llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml (original)
+++ llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml Sun Sep 29 09:06:22 2019
@@ -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"
Modified: llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli (original)
+++ llvm/trunk/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli Sun Sep 29 09:06:22 2019
@@ -16,6 +16,11 @@ external add_aggressive_dce
: [< 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
Modified: llvm/trunk/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c Sun Sep 29 09:06:22 2019
@@ -26,6 +26,11 @@ CAMLprim value llvm_add_aggressive_dce(L
return Val_unit;
}
+CAMLprim value llvm_add_dce(LLVMPassManagerRef PM) {
+ LLVMAddDCEPass(PM);
+ return Val_unit;
+}
+
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_alignment_from_assumptions(LLVMPassManagerRef PM) {
LLVMAddAlignmentFromAssumptionsPass(PM);
Modified: llvm/trunk/include/llvm-c/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Transforms/IPO.h?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Transforms/IPO.h (original)
+++ llvm/trunk/include/llvm-c/Transforms/IPO.h Sun Sep 29 09:06:22 2019
@@ -34,6 +34,9 @@ void LLVMAddArgumentPromotionPass(LLVMPa
/** See llvm::createConstantMergePass function. */
void LLVMAddConstantMergePass(LLVMPassManagerRef PM);
+/** See llvm::createMergeFunctionsPass function. */
+void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM);
+
/** See llvm::createCalledValuePropagationPass function. */
void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM);
Modified: llvm/trunk/include/llvm-c/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Transforms/Scalar.h?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm-c/Transforms/Scalar.h Sun Sep 29 09:06:22 2019
@@ -35,6 +35,9 @@ extern "C" {
/** See llvm::createAggressiveDCEPass function. */
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM);
+/** See llvm::createDeadCodeEliminationPass function. */
+void LLVMAddDCEPass(LLVMPassManagerRef PM);
+
/** See llvm::createBitTrackingDCEPass function. */
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM);
Modified: llvm/trunk/lib/Transforms/IPO/IPO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPO.cpp?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPO.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPO.cpp Sun Sep 29 09:06:22 2019
@@ -114,6 +114,10 @@ void LLVMAddIPSCCPPass(LLVMPassManagerRe
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";
Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=373170&r1=373169&r2=373170&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Sun Sep 29 09:06:22 2019
@@ -123,6 +123,10 @@ void LLVMAddAggressiveDCEPass(LLVMPassMa
unwrap(PM)->add(createAggressiveDCEPass());
}
+void LLVMAddDCEPass(LLVMPassManagerRef PM) {
+ unwrap(PM)->add(createDeadCodeEliminationPass());
+}
+
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createBitTrackingDCEPass());
}
More information about the llvm-commits
mailing list