|
| 1 | +// RUN: split-file %s %t |
| 2 | +// RUN: cd %t |
| 3 | +// |
| 4 | + |
| 5 | +//--- foo.c |
| 6 | +int foo() { return 3; } |
| 7 | + |
| 8 | +//--- main.c |
| 9 | +int foo(); |
| 10 | +int main() { return foo() - 3; } |
| 11 | + |
| 12 | +// # no LTO |
| 13 | +// ## PGO, with and without function-sections, and all permutations of -bcdtors |
| 14 | +// RUN: %clang_pgogen -O2 -c -fno-function-sections foo.c |
| 15 | +// RUN: %clang_pgogen -O2 -c -fno-function-sections main.c |
| 16 | +// |
| 17 | +// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o |
| 18 | +// RUN: rm -f default* && %run a.out |
| 19 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 20 | +// |
| 21 | +// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o |
| 22 | +// RUN: rm -f default* && %run a.out |
| 23 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 24 | + |
| 25 | +// RUN: %clang_pgogen -O2 -c -ffunction-sections foo.c |
| 26 | +// RUN: %clang_pgogen -O2 -c -ffunction-sections main.c |
| 27 | +// |
| 28 | +// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o |
| 29 | +// RUN: rm -f default* && %run a.out |
| 30 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 31 | +// |
| 32 | +// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o |
| 33 | +// RUN: rm -f default* && %run a.out |
| 34 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 35 | + |
| 36 | +// ## no PGO at compile step, but PGO at link step. |
| 37 | +// RUN: %clang -O2 -c foo.c |
| 38 | +// RUN: %clang -O2 -c main.c |
| 39 | +// |
| 40 | +// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o |
| 41 | +// RUN: rm -f default* && %run a.out |
| 42 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 43 | +// |
| 44 | +// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o |
| 45 | +// RUN: rm -f default* && %run a.out |
| 46 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 47 | + |
| 48 | +// # LTO, with and without function-sections, and all permutations of -bcdtors |
| 49 | +// ## LTO one file, no PGO at compile, PGO at link |
| 50 | +// RUN: %clang -O2 -c foo.c |
| 51 | +// RUN: %clang -O2 -c -flto main.c |
| 52 | +// |
| 53 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o |
| 54 | +// RUN: rm -f default* && %run a.out |
| 55 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 56 | +// |
| 57 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o |
| 58 | +// RUN: rm -f default* && %run a.out |
| 59 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 60 | +// |
| 61 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o |
| 62 | +// RUN: rm -f default* && %run a.out |
| 63 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 64 | +// |
| 65 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o |
| 66 | +// RUN: rm -f default* && %run a.out |
| 67 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE |
| 68 | + |
| 69 | +// ## LTO one file, PGO at compile and link |
| 70 | +// RUN: %clang -O2 -c -fno-function-sections foo.c |
| 71 | +// RUN: %clang_pgogen -O2 -c -flto main.c |
| 72 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o |
| 73 | +// RUN: rm -f default* && %run a.out |
| 74 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN |
| 75 | + |
| 76 | +// RUN: %clang -O2 -c -flto foo.c |
| 77 | +// RUN: %clang_pgogen -O2 -c -fno-function-sections main.c |
| 78 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o |
| 79 | +// RUN: rm -f default* && %run a.out |
| 80 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN |
| 81 | + |
| 82 | +// RUN: %clang -O2 -c -flto foo.c |
| 83 | +// RUN: %clang_pgogen -O2 -c -ffunction-sections main.c |
| 84 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o |
| 85 | +// RUN: rm -f default* && %run a.out |
| 86 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN |
| 87 | + |
| 88 | +// RUN: %clang -O2 -c -ffunction-sections foo.c |
| 89 | +// RUN: %clang_pgogen -O2 -c -flto main.c |
| 90 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o |
| 91 | +// RUN: rm -f default* && %run a.out |
| 92 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN |
| 93 | + |
| 94 | +// ## LTO and PGO both files |
| 95 | +// RUN: %clang_pgogen -O2 -c -flto foo.c |
| 96 | +// RUN: %clang_pgogen -O2 -c -flto main.c |
| 97 | +// |
| 98 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o |
| 99 | +// RUN: rm -f default* && %run a.out |
| 100 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 101 | +// |
| 102 | +// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o |
| 103 | +// RUN: rm -f default* && %run a.out |
| 104 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 105 | +// |
| 106 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o |
| 107 | +// RUN: rm -f default* && %run a.out |
| 108 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 109 | +// |
| 110 | +// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o |
| 111 | +// RUN: rm -f default* && %run a.out |
| 112 | +// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH |
| 113 | + |
| 114 | +// BOTH-DAG: foo: |
| 115 | +// BOTH-DAG: main: |
| 116 | +// MAIN-NOT: foo: |
| 117 | +// MAIN: main: |
| 118 | +// MAIN-NOT: foo: |
| 119 | +// NONE: Total functions: 0 |
0 commit comments