[llvm-dev] How does -fPIE get passed from clang to llc when run on a .ll file?

Phil Tomson via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 6 10:32:36 PST 2015


If I create an llvm IR file (.ll) using clang like this:

  clang -v -emit-llvm -fPIC -O0 -S global_dat.c -o global_dat_x86_pic.ll

And then take a look at the resulting .ll file, I see near the bottom:

  !0 = !{i32 1, !"PIC Level", i32 2}

Now if I do the same, but specify -fPIE:

  clang -v -emit-llvm -fPIE -O0 -S global_dat.c -o global_dat_x86_pie.ll

And then look at the resulting global_dat_x86_pie.ll file, I see it is
identical to the one where I specified -fPIC (global_dat_x86_pic.ll).
There's no indication of the PIE level in the .ll file.

However, I can see (based on the verbose output) that the PIE Level should
be 2:

   "clang-3.6" -cc1 -triple xstg--linux-elf -emit-llvm -disable-free
-main-file-name global_dat.c -mrelocation-model pic -pic-level 2 -pie-level
2 ...

So if I were to pass this .ll file (global_dat_x86_pie.ll) to llc how would
llc know that the PIE Level is 2? Is this an oversight, bug, or expetcted
behaviour with a different workaround?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151106/fab24abd/attachment.html>


More information about the llvm-dev mailing list