getting nowhere with thinLTO

Teresa, thanks, that’s helpful.

I discovered the resolution-based API and am now converting to that. I can also see that the summaries are in the bitcode files, via llvm-bcanalyzer.

I hope the llvm-dis support will happen. Also it would be nice if the documentation were more up-to-date. But this will definitely help get me moving again.

For whatever reason in this simple example t3 is not being inlined, but I can set that aside for now.

// t2.c:

int t3();

int t2()

{

if (t3()) return 1;

else return 0;

}

// t3.c:

int t3()

{

return 10;

}

% clang -c -O2 -flto=thin t2.c t3.c

% llvm-lto t2.o t3.o --exported-symbol=t2 --thinlto-action=run -debug-only=function-import -thinlto-save-temps=.

Live root: 11079814748834529807

2 symbols Live, and 1 symbols Dead

Computing import for Module ‘t3.o’

Ignores Dead GUID: 8059958135287337232

Initialize import for 14314392591860533259

Computing import for Module ‘t2.o’

Initialize import for 11079814748834529807

Import/Export lists for 2 modules:

  • Module t3.o exports 0 functions. Imports from 0 modules.

  • Module t2.o exports 0 functions. Imports from 0 modules.

Starting import for Module t2.o

Imported 0 functions for Module t2.o

Starting import for Module t3.o

Imported 0 functions for Module t3.o

-Alan

Hi Alan,

I am seeing the inline of t3 into t2 after it is imported. Look at the post-opt bitcode file generated by -thinlto-save-temps:

llvm-dis -o - .0.4.opt.bc
; ModuleID = ‘.0.4.opt.bc’
source_filename = “t2.c”
target datalayout = “e-m:e-i64:64-f80:128-n8:16:32:64-S128”
target triple = “x86_64-unknown-linux-gnu”

; Function Attrs: norecurse nounwind readnone uwtable
define i32 @t2() local_unnamed_addr #0 {
entry:
ret i32 1
}

Also, if you do -debug-only=inline instead of -debug-only=function-import, you will see:

llvm-lto t2.o t3.o --exported-symbol=t2 --thinlto-action=run -debug-only=inline -thinlto-save-temps=.Inliner visiting SCC: t3: 0 call sites.
Inliner visiting SCC: t3: 0 call sites.
Inliner visiting SCC: INDIRECTNODE: 0 call sites.
Inliner visiting SCC: t2: 1 call sites.
Inlining: cost=-30, thres=337, Call: %call = tail call i32 @t3() #2
Inliner visiting SCC: INDIRECTNODE: 0 call sites.

Are you seeing something different?
Teresa

For whatever reason in this simple example t3 is not being inlined, but I can set that aside for now.

// t2.c:

int t3();