[llvm] [C API] Add blockaddress getters to C API (PR #77390)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 01:15:14 PST 2024


================
@@ -373,6 +387,22 @@ static LLVMValueRef clone_constant_impl(LLVMValueRef Cst, LLVMModuleRef M) {
     return LLVMConstVector(Elts.data(), EltCount);
   }
 
+  if (LLVMIsABlockAddress(Cst)) {
+    check_value_kind(Cst, LLVMBlockAddressValueKind);
+    LLVMValueRef SrcFunc = LLVMGetBlockAddressFunction(Cst);
+    LLVMBasicBlockRef SrcBB = LLVMGetBlockAddressBasicBlock(Cst);
+
+    LLVMValueRef DstFunc = clone_constant(SrcFunc, M);
+
+    LLVMBasicBlockRef DstBB =
+        find_bb_in_func(DstFunc, LLVMGetBasicBlockName(SrcBB));
----------------
nikic wrote:

This approach is not going to work for unnamed blocks.

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


More information about the llvm-commits mailing list