[llvm] [C API] Add getters and build function for CallBr (PR #91154)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 21:37:53 PDT 2024


================
@@ -3258,6 +3270,30 @@ LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
   return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
 }
 
+LLVMValueRef LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
+                             LLVMBasicBlockRef DefaultDest,
+                             LLVMBasicBlockRef *IndrectDests,
+                             unsigned NumIndrectDests, LLVMValueRef *Args,
+                             unsigned NumArgs, LLVMOperandBundleRef *Bundles,
+                             unsigned NumBundles, const char *Name) {
+
+  SmallVector<OperandBundleDef, 8> OBs;
+  for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
+    OperandBundleDef *OB = unwrap(Bundle);
+    OBs.push_back(*OB);
+  }
+
+  SmallVector<BasicBlock *, 8> IDs;
----------------
nikic wrote:

It shouldn't be necessary to create a new vector. You should be able to do something like `ArrayRef(unwrap(IndirectDests), NumIndirectDests)`.

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


More information about the llvm-commits mailing list