<html dir=""><head><style id="axi-htmleditor-style" type="text/css">p { margin: 0px; }</style></head><body style="font-size: 10pt; font-family: Arial; background-image: none; background-repeat: repeat; background-attachment: fixed;">Thank you for your reply. The problem is that I have a python code and not all of the functions of that are convertible to c code. Moreover, may I see your combined_module.ll file ?Thank you<br><br><br>On Fri, 06/16/2017 05:13 PM, Tim Northover &lt;t.p.northover@gmail.com&gt; wrote:<br><blockquote style="border-left: 2px solid rgb(00, 00, 204); padding-left: 4px; margin-left: 16px;"><div style="font-family: Arial; font-size: 10pt;">(Adding llvm-dev back to the thread in case anyone else comes along<br>later with the same problem).<br><br>Your problem now is this prototype:<br><br>> define i64 @"main"(i64 %".1")<br><br>That's almost certainly not how main is called on your system<br>(typically it has to be "i32 @main(i32, i8**)" or "i32 @main()" though<br>odder platforms will differ.<br><br>What value do you expect %.1 to have on entry? What do you expect to<br>happen to the value returned?<br><br>I suspect what you really want is to call your function "@fib" and<br>write a separate wrapper-function @main that calls @fib with sensible<br>arguments and maybe prints out the result afterwards. You could write<br>this in C and let Clang give you the IR you need. For example to take<br>the input as a command-line argument:<br><br>#include <stdio.h><br>#include <stdlib.h><br>long long fib(long long);<br>int main(int argc, char *argv[]) {<br>  printf("%lld\n", fib(atoi(argv[1])));<br>}<br><br>Clang (when I run "clang -Os -S -o- -emit-llvm file.c") tells me the<br>IR for this is:<br><br>@.str = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1<br>define i32 @main(i32, i8** nocapture readonly)  {<br>  %3 = getelementptr inbounds i8*, i8** %1, i64 1<br>  %4 = load i8*, i8** %3, align 8<br>  %5 = tail call i32 @atoi(i8* %4)<br>  %6 = sext i32 %5 to i64<br>  %7 = tail call i64 @fib(i64 %6)<br>  %8 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6<br>x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %7)<br>  ret i32 0<br>}<br>declare i32 @printf(i8* nocapture readonly, ...)<br>declare i32 @atoi(i8* nocapture)<br><br>Put that into a module with your @fib definition and you should be<br>able to run lli on it:<br><br>$ lli combined_module.ll 12<br>233<br>$<br><br>Cheers.<br><br>Tim.<br><br>On 16 June 2017 at 13:54, Samaneh Berenjian <a href="mailto:<sama.scientist@aut.ac.ir>" target="_blank"><sama.scientist@aut.ac.ir></a> wrote:<br>> Thank you for your kind reply. my IR looks like the following and I have<br>> gotten it from the code in<br>> <a href="https://ian-bertolacci.github.io/llvm/llvmlite/python/compilers/programming/2016/03/06/LLVMLite_fibonacci.html" target="_blank">https://ian-bertolacci.github.io/llvm/llvmlite/python/compilers/programming/2016/03/06/LLVMLite_fibonacci.html</a>.<br>> How can I make it looks like what you said me?<br>> ; ModuleID = "m_fibonacci_example"<br>> target triple = "unknown-unknown-unknown"<br>> target datalayout = ""<br>><br>> define i64 @"main"(i64 %".1")<br>> {<br>> fn_fib_entry:<br>>   %".3" = icmp sle i64 %".1", 1<br>>   br i1 %".3", label %"fn_fib_entry.if", label %"fn_fib_entry.endif"<br>> fn_fib_entry.if:<br>>   ret i64 1<br>> fn_fib_entry.endif:<br>>   %".6" = sub i64 %".1", 1<br>>   %".7" = sub i64 %".1", 2<br>>   %".8" = call i64 @"main"(i64 %".6")<br>>   %".9" = call i64 @"main"(i64 %".7")<br>>   %".10" = add i64 %".8", %".9"<br>>   ret i64 %".10"<br>> }<br>><br>> Thank you in advance<br>><br>><br>><br>><br>> On Fri, 06/16/2017 03:50 PM, Tim Northover &lt;<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>&gt;<br>> wrote:<br>><br>> On 16 June 2017 at 12:19, Samaneh Berenjian via llvm-dev<br>> <a href="mailto:<llvm-dev@lists.llvm.org>" target="_blank"><llvm-dev@lists.llvm.org></a> wrote:<br>>> I have written a code in llvmlite. Using command numba --dump-llvm<br>>> example.py > example.ll I can have .ll file. However, using lli<br>>> example.ll,<br>>> I am stopped with error: 'main' function not found in module. Is there<br>>> anyway at which it can be executed using lli?<br>><br>> By default lli looks for a function named @main since that's the<br>> traditional C and C++ entry point (amongst others these days). You can<br>> override that and tell it to execute an arbitrary function with the<br>> "-entry-function" argument. Probably wise to make sure the prototype<br>> matches main though (i.e. return and int and take either northing or<br>> an argc, argv pair).<br>><br>> Cheers.<br>><br>> Tim.<br>><br>> --<br>> This email was Anti Virus checked by Security Gateway.<br></div></blockquote></body></html>