[llvm] 48c7004 - [OCaml] Fix bindings after br -> uncondbr+condbr split (#186176)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 13 04:11:12 PDT 2026


Author: Nikita Popov
Date: 2026-03-13T12:11:07+01:00
New Revision: 48c70049867759a1d6c9d4268787ab8fcc924375

URL: https://github.com/llvm/llvm-project/commit/48c70049867759a1d6c9d4268787ab8fcc924375
DIFF: https://github.com/llvm/llvm-project/commit/48c70049867759a1d6c9d4268787ab8fcc924375.diff

LOG: [OCaml] Fix bindings after br -> uncondbr+condbr split (#186176)

Update opcode lists after
https://github.com/llvm/llvm-project/pull/184027.

Added: 
    

Modified: 
    llvm/bindings/ocaml/llvm/llvm.ml
    llvm/bindings/ocaml/llvm/llvm.mli

Removed: 
    


################################################################################
diff  --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index eb70cc2ded084..6bf3121cd5c44 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -180,7 +180,7 @@ module Opcode  = struct
   | Invalid (* not an instruction *)
   (* Terminator Instructions *)
   | Ret
-  | Br
+  | Invalid3
   | Switch
   | IndirectBr
   | Invoke
@@ -252,6 +252,9 @@ module Opcode  = struct
   | FNeg
   | CallBr
   | Freeze
+  | PtrToAddr
+  | UncondBr
+  | CondBr
 end
 
 module LandingPadClauseTy = struct
@@ -1089,7 +1092,7 @@ let is_terminator llv =
   let open ValueKind in
   let open Opcode in
   match classify_value llv with
-    | Instruction (Br | IndirectBr | Invoke | Resume | Ret | Switch | Unreachable)
+    | Instruction (UncondBr | CondBr | IndirectBr | Invoke | Resume | Ret | Switch | Unreachable)
       -> true
     | _ -> false
 
@@ -1133,12 +1136,13 @@ external set_condition : llvalue -> llvalue -> unit
 external is_conditional : llvalue -> bool = "llvm_is_conditional"
 
 let get_branch llv =
-  if classify_value llv <> ValueKind.Instruction Opcode.Br then
-    None
-  else if is_conditional llv then
+  let kind = classify_value llv in
+  if kind = ValueKind.Instruction Opcode.UncondBr then
+    Some (`Unconditional (successor llv 0))
+  else if kind = ValueKind.Instruction Opcode.CondBr then
     Some (`Conditional (condition llv, successor llv 0, successor llv 1))
   else
-    Some (`Unconditional (successor llv 0))
+    None
 
 (*--... Operations on phi nodes ............................................--*)
 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit

diff  --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index a7ae10422b931..cee3602f82f7f 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -206,7 +206,7 @@ module Opcode : sig
   | Invalid (** Not an instruction *)
 
   | Ret (** Terminator Instructions *)
-  | Br
+  | Invalid3
   | Switch
   | IndirectBr
   | Invoke
@@ -278,6 +278,9 @@ module Opcode : sig
   | FNeg
   | CallBr
   | Freeze
+  | PtrToAddr
+  | UncondBr
+  | CondBr
 end
 
 (** The type of a clause of a [landingpad] instruction.


        


More information about the llvm-commits mailing list