aboutsummaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorGordon Henriksen <gordonhenriksen@mac.com>2007-12-10 03:18:06 +0000
committerGordon Henriksen <gordonhenriksen@mac.com>2007-12-10 03:18:06 +0000
commit80a75bfae980df96f969f1c05b0c4a80ce975240 (patch)
treeb17b6964d35ffeaa66a62793e9cb123e67b69310 /bindings
parentafba8fe662d65b25b4baf46bb26cc18e1f9cc0a5 (diff)
Adding a collector name attribute to Function in the IR. These
methods are new to Function: bool hasCollector() const; const std::string &getCollector() const; void setCollector(const std::string &); void clearCollector(); The assembly representation is as such: define void @f() gc "shadow-stack" { ... The implementation uses an on-the-side table to map Functions to collector names, such that there is no overhead. A StringPool is further used to unique collector names, which are extremely likely to be unique per process. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44769 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/llvm/llvm.ml2
-rw-r--r--bindings/ocaml/llvm/llvm.mli9
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c23
3 files changed, 34 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index a415b94594..d9ef2d3af3 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -282,6 +282,8 @@ external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
external function_call_conv : llvalue -> int = "llvm_function_call_conv"
external set_function_call_conv : int -> llvalue -> unit
= "llvm_set_function_call_conv"
+external collector : llvalue -> string option = "llvm_collector"
+external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
(* TODO: param attrs *)
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index ac83e42809..02bb58ca6c 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -754,6 +754,15 @@ external function_call_conv : llvalue -> int = "llvm_function_call_conv"
external set_function_call_conv : int -> llvalue -> unit
= "llvm_set_function_call_conv"
+(** [collector f] returns [Some name] if the function [f] has a garbage
+ collection algorithm specified and [None] otherwise.
+ See the method [llvm::Function::getCollector]. **)
+external collector : llvalue -> string option = "llvm_collector"
+
+(** [set_collector gc f] sets the collection algorithm for the function [f] to
+ [gc]. See the method [llvm::Function::setCollector]. **)
+external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
+
(*--... Operations on basic blocks .........................................--*)
(** [basic_blocks fn] returns the basic blocks of the function [f].
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index dd37e3e978..342d890e74 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -536,6 +536,29 @@ CAMLprim value llvm_set_function_call_conv(value Id, LLVMValueRef Fn) {
return Val_unit;
}
+/* llvalue -> string option */
+CAMLprim value llvm_collector(LLVMValueRef Fn) {
+ const char *Collector;
+ CAMLparam0();
+ CAMLlocal2(Name, Option);
+
+ if ((Collector = LLVMGetCollector(Fn))) {
+ Name = copy_string(Collector);
+
+ Option = alloc(1, 0);
+ Field(Option, 0) = Name;
+ CAMLreturn(Option);
+ } else {
+ CAMLreturn(Val_int(0));
+ }
+}
+
+/* string option -> llvalue -> unit */
+CAMLprim value llvm_set_collector(value GC, LLVMValueRef Fn) {
+ LLVMSetCollector(Fn, GC == Val_int(0)? 0 : String_val(Field(GC, 0)));
+ return Val_unit;
+}
+
/*--... Operations on basic blocks .........................................--*/
/* llvalue -> llbasicblock array */