[llvm] [C API] Add blockaddress getters to C API (PR #81382)
Benji Smith via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 11 04:54:45 PST 2024
================
@@ -136,3 +136,31 @@ int llvm_module_list_globals(void) {
return 0;
}
+
+int llvm_module_list_global_block_address_values(void) {
+ LLVMModuleRef M = llvm_load_module(false, false);
+ LLVMValueRef g;
+
+ g = LLVMGetFirstGlobal(M);
+ while (g) {
+ LLVMValueRef GInit = LLVMGetInitializer(g);
+
+ if (GInit && LLVMIsABlockAddress(GInit)) {
+ const char *GlobalName = LLVMGetValueName(g);
+ LLVMValueRef Func = LLVMGetBlockAddressFunction(GInit);
+ LLVMBasicBlockRef BB = LLVMGetBlockAddressBasicBlock(GInit);
+
+ const char *FuncName = LLVMGetValueName(Func);
+ const char *BBName = LLVMGetBasicBlockName(BB);
+
+ printf("BlockAddress '%s' Func '%s' Basic Block '%s'\n", GlobalName,
+ FuncName, BBName);
+ }
+
+ g = LLVMGetNextGlobal(g);
+ }
+
+ LLVMDisposeModule(M);
+
+ return 0;
+}
----------------
Benjins wrote:
Apologies, I didn't realise there was a specific unit test framework. I've changed the test to that in a new commit
https://github.com/llvm/llvm-project/pull/81382
More information about the llvm-commits
mailing list