[llvm-dev] LLVM JIT Compilation

hameeza ahmed via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 16 12:05:25 PDT 2017


ok i have managed to compile using lli (jit) as follows: but i dont get
assembly file?

my sum-main.c file is:

#include <stdio.h>
#include<stdlib.h>
int sum(int a, int b) {
return a + b;
}
int main(int argc, char** argv) {
printf("sum: %d\n", sum(atoi(argv[1]), atoi(argv[2])) + sum(atoi(argv[1]),
atoi(argv[2])));
return 0;
}

and i used the following steps to compile.
clang -S -emit-llvm sum-main.c -o sum-main.ll
lli sum-main.ll  5 2

it gives 7. i believe that it is compiling at run time.

now how to obtain assembly file generated at run time. and do a detailed
debugging of this code.

please help.



On Wed, Aug 16, 2017 at 10:49 PM, hameeza ahmed <hahmed2305 at gmail.com>
wrote:

> Hello,
>
> Can someone point me to some good tutorials for JIT in LLVM.
>
> My understanding of JIT is it is like llc; it takes optimized bit code
> (generated via opt) and compiles it at run time instead of static
> compilation. for example i have a loop which adds 2 user  input numbers. so
> my cpp file becomes:
>
> int main()
> {
> num1[1000], num2[1000];
> //take input in these arrays at run time using scanf.
>
> scanf("%d",num1);
> scanf("%d",num2);
>
> for (int i=0;i<1000;i++);
> {
> num1+num2;
> }
>
> so if i pass this through opt for auto vectorization. i keep vector
> width=32, i get optimized IR.
> then instead of passing the IR through llc i pass it through jit (lli).
> now i get run  time compilation. at run time my vectorized IR code
> <32xi32>emits vector assembly something like avx/ simd instructions.
>
> Am i right? please guide me.
>
> Thank You
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170817/d234b288/attachment.html>


More information about the llvm-dev mailing list