| 1 |
; Check that we can use full LTO with gold plugin when inputs |
| 2 |
; are compiled using unified LTO pipeline |
| 3 |
; RUN: llvm-as %s -o %t.bc |
| 4 |
; RUN: llvm-as %p/Inputs/unified-lto-foo.ll -o %t-foo.bc |
| 5 |
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ |
| 6 |
; RUN: -m elf_x86_64 \ |
| 7 |
; RUN: -plugin-opt=unifiedlto \ |
| 8 |
; RUN: -plugin-opt=save-temps \ |
| 9 |
; RUN: -u main \ |
| 10 |
; RUN: %t.bc %t-foo.bc \ |
| 11 |
; RUN: -o %t-out |
| 12 |
; RUN: llvm-dis %t-out.0.5.precodegen.bc -o - | FileCheck %s |
| 13 |
|
| 14 |
; Check thin LTO as well |
| 15 |
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ |
| 16 |
; RUN: -m elf_x86_64 \ |
| 17 |
; RUN: -plugin-opt=unifiedlto \ |
| 18 |
; RUN: -plugin-opt=thinlto \ |
| 19 |
; RUN: -plugin-opt=save-temps \ |
| 20 |
; RUN: -u main \ |
| 21 |
; RUN: %t.bc %t-foo.bc \ |
| 22 |
; RUN: -o %t-out |
| 23 |
; RUN: llvm-dis %t.bc.5.precodegen.bc -o - | FileCheck %s --check-prefix=THIN |
| 24 |
|
| 25 |
; Constant propagation is not supported by thin LTO. |
| 26 |
; With full LTO we fold argument into constant 43 |
| 27 |
; CHECK: define dso_local noundef i32 @main() |
| 28 |
; CHECK-NEXT: tail call fastcc void @foo() |
| 29 |
; CHECK-NEXT: ret i32 43 |
| 30 |
|
| 31 |
; CHECK: define internal fastcc void @foo() |
| 32 |
; CHECK-NEXT: store i32 43, ptr @_g, align 4 |
| 33 |
|
| 34 |
; ThinLTO doesn't import foo, because the latter has noinline attribute |
| 35 |
; THIN: define dso_local i32 @main() |
| 36 |
; THIN-NEXT: %1 = tail call i32 @foo(i32 noundef 1) |
| 37 |
|
| 38 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 39 |
target triple = "x86_64-pc-linux-gnu" |
| 40 |
|
| 41 |
define dso_local i32 @main() { |
| 42 |
%1 = tail call i32 @foo(i32 noundef 1) |
| 43 |
ret i32 %1 |
| 44 |
} |
| 45 |
|
| 46 |
declare i32 @foo(i32 noundef) |
| 47 |
|
| 48 |
!llvm.module.flags = !{!0, !1} |
| 49 |
|
| 50 |
!0 = !{i32 1, !"EnableSplitLTOUnit", i32 1} |
| 51 |
!1 = !{i32 1, !"UnifiedLTO", i32 1} |
| 52 |
|
| 53 |
^0 = module: (path: "unified-lto.o", hash: (2850108895, 1189778381, 479678006, 1191715608, 4095117687)) |
| 54 |
^1 = gv: (name: "foo") ; guid = 6699318081062747564 |
| 55 |
^2 = gv: (name: "main", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^1, tail: 1))))) ; guid = 15822663052811949562 |
| 56 |
^3 = flags: 520 |
| 57 |
^4 = blockcount: 0 |