I have two *.ll files, How inline them when the clang compiling and the lli running?

main.ll :

Summary
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"

$".%d " = comdat any

@".%d " = linkonce_odr unnamed_addr constant [4 x i8] c"%d \00", comdat

declare i64 @printf(ptr, i64)

declare ptr @print_frame()

define i64 @main() {
  %1 = call ptr @print_frame()

  %2 = call ptr @llvm.frameaddress.p0(i32 0)
  %3 = ptrtoint ptr %2 to i64
  %4 = call i64 @printf(ptr @".%d ", i64 %3)

  ret i64 0
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.frameaddress.p0(i32 immarg) #1

attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }

test.ll :

Summary
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"

$".%d " = comdat any

@".%d " = linkonce_odr unnamed_addr constant [4 x i8] c"%d \00", comdat

declare i64 @printf(ptr, i64)

; Function Attrs: alwaysinline
define ptr @print_frame() #1 {

  %1 = call ptr @llvm.frameaddress.p0(i32 0)
  %2 = ptrtoint ptr %1 to i64
  %3 = call i64 @printf(ptr @".%d ", i64 %2)

  ret ptr %1
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.frameaddress.p0(i32 immarg) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { alwaysinline }
  • Using “clang main.ll test.ll -o a.out” will print two different number. i.e. it has not be inlined.
  • Using “llvm-link main.ll test.ll -o out.bc”, then using “lli out.bc” will print two different number. i.e. it has not be inlined.
  • Using “llvm-link main.ll test.ll -o out.bc”, then using “clang out.bc -o a.out” will print two same number. i.e. it has be inlined.

How should I make the clang and the lli produce inlined result ?