diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-10 03:18:06 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-10 03:18:06 +0000 |
commit | 13fe5e35f69016557bde1eb0fd2229fa3b762a7a (patch) | |
tree | b17b6964d35ffeaa66a62793e9cb123e67b69310 /bindings/ocaml/llvm/llvm_ocaml.c | |
parent | c8ddfa60b8711b95e3c46a73257cab15b3f7bbed (diff) | |
download | external_llvm-13fe5e35f69016557bde1eb0fd2229fa3b762a7a.zip external_llvm-13fe5e35f69016557bde1eb0fd2229fa3b762a7a.tar.gz external_llvm-13fe5e35f69016557bde1eb0fd2229fa3b762a7a.tar.bz2 |
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/ocaml/llvm/llvm_ocaml.c')
-rw-r--r-- | bindings/ocaml/llvm/llvm_ocaml.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index dd37e3e..342d890 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 */ |