File: unified-lto.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (57 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
; Check that we can use full LTO with gold plugin when inputs
; are compiled using unified LTO pipeline
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-as %p/Inputs/unified-lto-foo.ll -o %t-foo.bc
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
; RUN:    -m elf_x86_64 \
; RUN:    -plugin-opt=unifiedlto \
; RUN:    -plugin-opt=save-temps \
; RUN:    -u main \
; RUN:    %t.bc %t-foo.bc \
; RUN:    -o %t-out
; RUN: llvm-dis %t-out.0.5.precodegen.bc -o - | FileCheck %s

; Check thin LTO as well
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
; RUN:    -m elf_x86_64 \
; RUN:    -plugin-opt=unifiedlto \
; RUN:    -plugin-opt=thinlto \
; RUN:    -plugin-opt=save-temps \
; RUN:    -u main \
; RUN:    %t.bc %t-foo.bc \
; RUN:    -o %t-out
; RUN: llvm-dis %t.bc.5.precodegen.bc -o - | FileCheck %s --check-prefix=THIN

; Constant propagation is not supported by thin LTO.
; With full LTO we fold argument into constant 43
; CHECK:       define dso_local noundef i32 @main()
; CHECK-NEXT:    tail call fastcc void @foo()
; CHECK-NEXT:    ret i32 43

; CHECK:       define internal fastcc void @foo()
; CHECK-NEXT:    store i32 43, ptr @_g, align 4

; ThinLTO doesn't import foo, because the latter has noinline attribute
; THIN:      define dso_local i32 @main()
; THIN-NEXT:   %1 = tail call i32 @foo(i32 noundef 1)

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"
target triple = "x86_64-pc-linux-gnu"

define dso_local i32 @main() {
  %1 = tail call i32 @foo(i32 noundef 1)
  ret i32 %1
}

declare i32 @foo(i32 noundef)

!llvm.module.flags = !{!0, !1}

!0 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
!1 = !{i32 1, !"UnifiedLTO", i32 1}

^0 = module: (path: "unified-lto.o", hash: (2850108895, 1189778381, 479678006, 1191715608, 4095117687))
^1 = gv: (name: "foo") ; guid = 6699318081062747564
^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
^3 = flags: 520
^4 = blockcount: 0