Debian Codegraph @

clang/test/CodeGen/fat-lto-objects.c

raw
1 // REQUIRES: x86-registered-target
2
3 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -emit-llvm < %s | FileCheck %s --check-prefixes=FULL,SPLIT
4 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-llvm < %s | FileCheck %s --check-prefixes=FULL,SPLIT
5
6 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -fsplit-lto-unit -ffat-lto-objects -emit-llvm < %s | FileCheck %s --check-prefixes=THIN,SPLIT
7 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -ffat-lto-objects -emit-llvm < %s | FileCheck %s --check-prefixes=THIN,NOSPLIT
8
9 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -emit-obj < %s -o %t.full.split.o
10 // RUN: llvm-readelf -S %t.full.split.o | FileCheck %s --check-prefixes=ELF
11 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.full.split.bc %t.full.split.o
12 // RUN: llvm-dis %t.full.split.bc -o - | FileCheck %s --check-prefixes=FULL,SPLIT,NOUNIFIED
13
14 /// Full LTO always sets EnableSplitLTOUnit when the summary is used.
15 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-obj < %s -o %t.full.nosplit.o
16 // RUN: llvm-readelf -S %t.full.nosplit.o | FileCheck %s --check-prefixes=ELF
17 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.full.nosplit.bc %t.full.nosplit.o
18 // RUN: llvm-dis %t.full.nosplit.bc -o - | FileCheck %s --check-prefixes=FULL,SPLIT,NOUNIFIED
19
20 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -fsplit-lto-unit -ffat-lto-objects -emit-obj < %s -o %t.thin.split.o
21 // RUN: llvm-readelf -S %t.thin.split.o | FileCheck %s --check-prefixes=ELF
22 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.thin.split.bc %t.thin.split.o
23 // RUN: llvm-dis %t.thin.split.bc -o - | FileCheck %s --check-prefixes=THIN,SPLIT,NOUNIFIED
24
25 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -ffat-lto-objects -emit-obj < %s -o %t.thin.nosplit.o
26 // RUN: llvm-readelf -S %t.thin.nosplit.o | FileCheck %s --check-prefixes=ELF
27 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.thin.nosplit.bc %t.thin.nosplit.o
28 // RUN: llvm-dis %t.thin.nosplit.bc -o - | FileCheck %s --check-prefixes=THIN,NOSPLIT,NOUNIFIED
29
30 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -funified-lto -ffat-lto-objects -emit-obj < %s -o %t.unified.o
31 // RUN: llvm-readelf -S %t.unified.o | FileCheck %s --check-prefixes=ELF
32 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.unified.bc %t.unified.o
33 // RUN: llvm-dis %t.unified.bc -o - | FileCheck %s --check-prefixes=THIN,NOSPLIT,UNIFIED
34
35 // RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -S < %s -o - \
36 // RUN: | FileCheck %s --check-prefixes=ASM
37
38 // RUN: %clang -cc1 -triple i386-pc-win32 -flto=full -ffat-lto-objects -fsplit-lto-unit -S < %s -o - \
39 // RUN: | FileCheck %s --check-prefixes=ASM-COFF
40
41 /// Make sure that FatLTO generates .llvm.lto sections that are the same as the output from normal LTO compilations
42 // RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=full -ffat-lto-objects -c %s -o %t.fatlto.full.o
43 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.fatlto.full.bc %t.fatlto.full.o
44 // RUN: llvm-dis < %t.fatlto.full.bc -o %t.fatlto.full.ll
45 // RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=full -c %s -o %t.nofat.full.bc
46 // RUN: llvm-dis < %t.nofat.full.bc -o %t.nofat.full.ll
47 // RUN: diff %t.fatlto.full.ll %t.nofat.full.ll
48
49 // RUN: %clang -O2 --target=i386-pc-win32 -flto=full -ffat-lto-objects -c %s -o %t.fatlto.full.coff.o
50 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.fatlto.full.coff.bc %t.fatlto.full.coff.o
51 // RUN: llvm-dis < %t.fatlto.full.coff.bc -o %t.fatlto.full.coff.ll
52 // RUN: %clang -O2 --target=i386-pc-win32 -flto=full -c %s -o %t.nofat.full.coff.bc
53 // RUN: llvm-dis < %t.nofat.full.coff.bc -o %t.nofat.full.coff.ll
54 // RUN: diff %t.fatlto.full.coff.ll %t.nofat.full.coff.ll
55
56 // RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=thin -ffat-lto-objects -c %s -o %t.fatlto.thin.o
57 // RUN: llvm-objcopy --dump-section=.llvm.lto=%t.fatlto.thin.bc %t.fatlto.thin.o
58 // RUN: llvm-dis < %t.fatlto.thin.bc -o %t.fatlto.thin.ll
59 // RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=thin -c %s -o %t.nofat.thin.bc
60 // RUN: llvm-dis < %t.nofat.thin.bc -o %t.nofat.thin.ll
61 // RUN: diff %t.fatlto.thin.ll %t.nofat.thin.ll
62
63 /// Be sure we enable split LTO units correctly under -ffat-lto-objects.
64 // SPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 1}
65 // NOSPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 0}
66
67 // FULL-NOT: ![[#]] = !{i32 1, !"ThinLTO", i32 0}
68 // THIN-NOT: ![[#]] = !{i32 1, !"ThinLTO", i32 0}
69
70 // UNIFIED: ![[#]] = !{i32 1, !"UnifiedLTO", i32 1}
71 // NOUNIFIED-NOT: ![[#]] = !{i32 1, !"UnifiedLTO", i32 1}
72
73 // ELF: .llvm.lto
74
75 // ASM: .section .llvm.lto,"e",@llvm_lto
76 // ASM-NEXT: .Lllvm.embedded.object:
77 // ASM-NEXT: .asciz "BC
78 // ASM-NEXT: .size .Lllvm.embedded.object
79
80 // ASM-COFF: .section .llvm.lto,"ynD"
81 // ASM-COFF-NEXT: L_llvm.embedded.object:
82 // ASM-COFF-NEXT: .asciz "BC
83
84 const char* foo = "foo";
85
86 int test(void) {
87 const char* bar = "bar";
88 return 0xabcd;
89 }