[llvm] [RemoveDIs] Add a 'BeforeDbgRecords' parameter to C API isnt insertion functions (PR #92417)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 16:13:26 PDT 2024


================
@@ -2016,18 +2016,28 @@ value llvm_builder(value C) {
   return alloc_builder(LLVMCreateBuilderInContext(Context_val(C)));
 }
 
-/* (llbasicblock, llvalue) llpos -> llbuilder -> unit */
-value llvm_position_builder(value Pos, value B) {
+static value llvm_position_builder_impl(value Pos, value B,
+                                        LLVMBool BeforeDbgRecords) {
   if (Tag_val(Pos) == 0) {
     LLVMBasicBlockRef BB = BasicBlock_val(Field(Pos, 0));
     LLVMPositionBuilderAtEnd(Builder_val(B), BB);
   } else {
     LLVMValueRef I = Value_val(Field(Pos, 0));
-    LLVMPositionBuilderBefore(Builder_val(B), I);
+    LLVMPositionBuilderBefore2(Builder_val(B), I, BeforeDbgRecords);
   }
   return Val_unit;
 }
 
+/* (llbasicblock, llvalue) llpos -> bool -> llbuilder -> unit */
+value llvm_position_builder2(value Pos, value BeforeDbgRecords, value B) {
+  return llvm_position_builder_impl(Pos, B, Bool_val(BeforeDbgRecords));
+}
+
+/* (llbasicblock, llvalue) llpos -> llbuilder -> unit */
+value llvm_position_builder(value Pos, value B) {
+  return llvm_position_builder_impl(Pos, B, /*BeforeDbgRecords=*/0);
+}
----------------
alan-j-hu wrote:

Whoops, somehow this didn't get attached in my code review.

I would very much rather implement this in `llvm.ml` as:

```ocaml
let position_builder llpos llbuilder = position_builder2 llpos false llbuilder
```

That being said, I am questioning whether `position_builder` and `position_buidler2` should co-exist. OCaml doesn't have the ABI compatibility concerns between major library releases, so it's likely much better to rip off the bandaid with a single change to the type of `position_builder`, instead of going through the process of with the `2`.

https://github.com/llvm/llvm-project/pull/92417


More information about the llvm-commits mailing list