Skip to content

Commit 82adae1

Browse files
committed
update ocaml bindings
1 parent 585b9d5 commit 82adae1

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

llvm/bindings/ocaml/llvm/llvm.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,8 @@ external delete_instruction : llvalue -> unit = "llvm_delete_instruction"
11351135
external builder : llcontext -> llbuilder = "llvm_builder"
11361136
external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
11371137
= "llvm_position_builder"
1138+
external position_builder2 : (llbasicblock, llvalue) llpos -> bool -> llbuilder ->
1139+
unit = "llvm_position_builder2"
11381140
external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
11391141
external insert_into_builder : llvalue -> string -> llbuilder -> unit
11401142
= "llvm_insert_into_builder"
@@ -1148,6 +1150,7 @@ let builder_before context i = builder_at context (Before i)
11481150
let builder_at_end context bb = builder_at context (At_end bb)
11491151

11501152
let position_before i = position_builder (Before i)
1153+
let position_before_dbg_records i = position_builder2 (Before i) true
11511154
let position_at_end bb = position_builder (At_end bb)
11521155

11531156

llvm/bindings/ocaml/llvm/llvm.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,10 +1874,22 @@ val builder_at_end : llcontext -> llbasicblock -> llbuilder
18741874
See the constructor for [llvm::LLVMBuilder]. *)
18751875
val position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
18761876

1877+
(** [position_builder2 ip bb before_dbg_records] moves the instruction builder
1878+
[bb] to the position [ip]. [before_dbg_records] determines whether the
1879+
insertion point is before debug records attached to [ip].
1880+
See the constructor for [llvm::LLVMBuilder]. *)
1881+
val position_builder2 : (llbasicblock, llvalue) llpos -> bool -> llbuilder ->
1882+
unit
1883+
18771884
(** [position_before ins b] moves the instruction builder [b] to before the
18781885
instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
18791886
val position_before : llvalue -> llbuilder -> unit
18801887

1888+
(** [position_before_dbg_records ins b] moves the instruction builder [b] to
1889+
before the instruction [isn] and any debug records attached to it.
1890+
See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1891+
val position_before : llvalue -> llbuilder -> unit
1892+
18811893
(** [position_at_end bb b] moves the instruction builder [b] to the end of the
18821894
basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
18831895
val position_at_end : llbasicblock -> llbuilder -> unit

llvm/bindings/ocaml/llvm/llvm_ocaml.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,18 +2004,28 @@ value llvm_builder(value C) {
20042004
return alloc_builder(LLVMCreateBuilderInContext(Context_val(C)));
20052005
}
20062006

2007-
/* (llbasicblock, llvalue) llpos -> llbuilder -> unit */
2008-
value llvm_position_builder(value Pos, value B) {
2007+
static value llvm_position_builder_impl(value Pos, value B,
2008+
LLVMBool BeforeDbgRecords) {
20092009
if (Tag_val(Pos) == 0) {
20102010
LLVMBasicBlockRef BB = BasicBlock_val(Field(Pos, 0));
20112011
LLVMPositionBuilderAtEnd(Builder_val(B), BB);
20122012
} else {
20132013
LLVMValueRef I = Value_val(Field(Pos, 0));
2014-
LLVMPositionBuilderBefore(Builder_val(B), I);
2014+
LLVMPositionBuilderBefore2(Builder_val(B), I, BeforeDbgRecords);
20152015
}
20162016
return Val_unit;
20172017
}
20182018

2019+
/* (llbasicblock, llvalue) llpos -> bool -> llbuilder -> unit */
2020+
value llvm_position_builder2(value Pos, value BeforeDbgRecords, value B) {
2021+
return llvm_position_builder_impl(Pos, B, Bool_val(BeforeDbgRecords));
2022+
}
2023+
2024+
/* (llbasicblock, llvalue) llpos -> llbuilder -> unit */
2025+
value llvm_position_builder(value Pos, value B) {
2026+
return llvm_position_builder_impl(Pos, B, /*BeforeDbgRecords=*/0);
2027+
}
2028+
20192029
/* llbuilder -> llbasicblock */
20202030
value llvm_insertion_block(value B) {
20212031
LLVMBasicBlockRef InsertBlock = LLVMGetInsertBlock(Builder_val(B));

llvm/test/Bindings/OCaml/core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ let test_builder () =
11501150
(* CHECK: ret{{.*}}P1
11511151
*)
11521152
let ret = build_ret p1 atentry in
1153-
position_before ret atentry
1153+
position_before_dbg_records ret atentry
11541154
end;
11551155

11561156
(* see test/Feature/exception.ll *)

0 commit comments

Comments
 (0)