[llvm-dev] LLVMGetFirstFunction() / LLVMGetNextFunction( ) problem

Toshiyasu Morita via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 28 13:23:51 PDT 2017


Hi, I have a problem - looking for advice.

I have a source code file with two functions which are compiled into a .bc
file.
When the bitcode file is loaded, I can dump the module and see the two
functions:

...
; Materializable
; Function Attrs: noinline nounwind uwtable
define void @matmul(double*, double*, double*, i32, i32, i32) #0 {}

; Materializable
; Function Attrs: noinline nounwind uwtable
define i32 @main() #0 {}
...

However, when I use LLVMGetirstFunction() and LLVMGetNextFunction() to
iterate through the functions in the module, it only iterates through the
function "matmul".
It never finds main().

50      first_func = LLVMGetFirstFunction(module);
(gdb) next
151      last_func = LLVMGetLastFunction(module);
(gdb)
154      for (func = first_func; func != last_func; func =
LLVMGetNextFunction(func)) {
(gdb)
155        func_name = LLVMGetValueName(func);
(gdb)
156        func_addr = LLVMGetFunctionAddress(engine, func_name);
(gdb) print func_name
$9 = 0x1efe180 "matmul"
(gdb) next
159        if (!func_addr) continue;
(gdb)
161        symbol_table_add(symbol_table, func_name, func_addr);
(gdb)
164        if ((size = mem_region_lookup(mem_region_anchor, func_addr))) {
symbol_table_add(symbol_table, "dummy_symbol", func_addr + size); }
(gdb)
154      for (func = first_func; func != last_func; func =
LLVMGetNextFunction(func)) {
(gdb)
168      symbol_table_calc_symbol_sizes(symbol_table);

Any suggestions appreciated.

Toshi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170428/ad81436e/attachment.html>


More information about the llvm-dev mailing list