[llvm-dev] [LLVM LTO]internalize pass

Duncan P. N. Exon Smith via llvm-dev llvm-dev at lists.llvm.org
Fri May 27 09:57:06 PDT 2016


> On 2016-May-27, at 05:55, Teresa Johnson via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 
> 
> On Fri, May 27, 2016 at 3:43 AM, Umesh Kalappa via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi All ,
> 
> We are in process of exploring the  LTO  and found that internalize
> pass is the replacement for whole program optimisation
> (-fwhole-program in gcc)  in clang  and  in the below case
> 
> define i32 @test() #0 {
> 
> entry:
> 
>   ret i32 0
> 
> }
> 
> 
> define i32 @main() #0 {
> 
> entry:
> 
>   %retval = alloca i32, align 4
> 
>   store i32 0, i32* %retval, align 4
> 
>   %call = call i32 @test()
> 
>   ret i32 %call
> 
> }
> 
> *** IR Dump After Internalize Global Symbols ***; ModuleID = 'ld-temp.o'
> 
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> 
> target triple = "x86_64-unknown-linux-gnu"
> 
> 
> ; Function Attrs: nounwind uwtable
> 
> define internal i32 @test() #0 {
> 
> entry:
> 
>   ret i32 0
> 
> }
> 
> 
> ; Function Attrs: nounwind uwtable
> 
> define internal i32 @main() #0 {
> 
> entry:
> 
>   %retval = alloca i32, align 4
> 
>   store i32 0, i32* %retval, align 4
> 
>   %call = call i32 @test()
> 
>   ret i32 %call
> 
> }
> 
> 
> the functions  def like test() and the main()  are marked internal by
> the internalize pass.
> 
> Queries is ,we tried to prevent mark the internal string attribute
> before function name i.e
>  
> The option you would want is -exported-symbol=main,

Note that on some platforms symbol names get lowered differently.

E.g., on Darwin, the correct usage is `-exported-symbol=_main`.

> so that llvm-lto tells internalize to preserve it. No need to list 'test' since presumably it is fine to internalize that (and the use in 'main' will prevent it from being dead code eliminated, which I assume is currently happening to both of these symbols).
> 
> 
> >
> > $bin/llvm-lto -print-after-all  test.o
> -internalize-public-api-list=test,main  -o output.o
> 
> $bin/llvm-lto -print-after-all  test.o
> -internalize-public-api-file=file  -o output.o
> $cat file
>  test
>  main
> 
> Both cases ,no luck here ,still the functions are marked internal :(
> 
> Any suggestions here or its a bug with internalize pass.
> 
> 
> Thank you
> ~Umesh
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> 
> 
> -- 
> Teresa Johnson |	 Software Engineer |	 tejohnson at google.com |	 408-460-2413
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list