[fpc-devel] How to view .ll files generated by LLVM backend?

Pierre Muller pierre at freepascal.org
Wed Jul 26 13:43:55 CEST 2023

Le 25/07/2023 à 17:52, Lucian Popescu via fpc-devel a écrit :
> Hi,
> I followed the instructions for building FPC with LLVM presented here [1].
> Now I am interested in generating LLVM assembly from the corresponding
> Pascal code. Is there any method to achieve this?

  Just use -al option, this will leave the generated .ll file present after compilation.

  You can also use -vx option to see how clang is called:


muller at gcc187:~/pas/check$ fpc -al -vx hello.pp
Free Pascal Compiler version 3.3.1-13440-ge4911588c5-unpushed-dirty [2023/07/26] for x86_64
Copyright (c) 1993-2023 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling hello.pp
Assembling program
Executing "/home/muller/bin/clang" with command line "-x ir -O0 -fno-omit-frame-pointer -static -target x86_64-unknown-linux-gnu -c -o hello.o hello.ll "
Linking hello
Executing "/usr/bin/ld.bfd" with command line "-b elf64-x86-64 -m elf_x86_64  --dynamic-linker=/lib64/ld-linux-x86-64.so.2   -s    -L. -o hello -T link3003900.res -e _start --eh-frame-hdr"
Size of Code: 336615 bytes
Size of initialized data: 9568 bytes
Size of initialized data: 6648 bytes
Size of uninitialized data: 7016 bytes
3 lines compiled, 0.1 sec, 336615 bytes code, 23232 bytes data
muller at gcc187:~/pas/check$ ls -altr hello*
-rw-rw-r--. 1 muller muller     32 Aug  4  2022 hello.pp
-rw-rw-r--. 1 muller muller   5220 Jul 26 11:43 hello.ll
-rw-rw-r--. 1 muller muller   2584 Jul 26 11:43 hello.o
-rwxrwxr-x. 1 muller muller 447584 Jul 26 11:43 hello

More information about the fpc-devel mailing list