120 lines · plain
1// RUN: split-file %s %t2// RUN: cd %t3//4 5//--- foo.c6int foo() { return 3; }7 8//--- main.c9int foo();10int main() { return foo() - 3; }11 12// # no LTO13// ## PGO, with and without function-sections, and all permutations of -bcdtors14// RUN: %clang_pgogen -O2 -c -fno-function-sections foo.c15// RUN: %clang_pgogen -O2 -c -fno-function-sections main.c16//17// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o18// RUN: rm -f default* && %run ./a.out19// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH20//21// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o22// RUN: rm -f default* && %run ./a.out23// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH24 25// RUN: %clang_pgogen -O2 -c -ffunction-sections foo.c26// RUN: %clang_pgogen -O2 -c -ffunction-sections main.c27//28// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o29// RUN: rm -f default* && %run ./a.out30// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH31//32// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o33// RUN: rm -f default* && %run ./a.out34// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH35 36// ## no PGO at compile step, but PGO at link step.37// RUN: %clang -O2 -c foo.c38// RUN: %clang -O2 -c main.c39//40// RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o41// RUN: rm -f default* && %run ./a.out42// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE43//44// RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o45// RUN: rm -f default* && %run ./a.out46// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE47 48// # LTO, with and without function-sections, and all permutations of -bcdtors49// ## LTO one file, no PGO at compile, PGO at link50// RUN: %clang -O2 -c foo.c51// RUN: %clang -O2 -c -flto main.c52//53// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o54// RUN: rm -f default* && %run ./a.out55// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE56//57// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o58// RUN: rm -f default* && %run ./a.out59// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE60//61// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o62// RUN: rm -f default* && %run ./a.out63// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE64//65// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o66// RUN: rm -f default* && %run ./a.out67// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=NONE68 69// ## LTO one file, PGO at compile and link70// RUN: %clang -O2 -c -fno-function-sections foo.c71// RUN: %clang_pgogen -O2 -c -flto main.c72// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o73// RUN: rm -f default* && %run ./a.out74// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN75 76// RUN: %clang -O2 -c -flto foo.c77// RUN: %clang_pgogen -O2 -c -fno-function-sections main.c78// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o79// RUN: rm -f default* && %run ./a.out80// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN81 82// RUN: %clang -O2 -c -flto foo.c83// RUN: %clang_pgogen -O2 -c -ffunction-sections main.c84// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o85// RUN: rm -f default* && %run ./a.out86// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN87 88// RUN: %clang -O2 -c -ffunction-sections foo.c89// RUN: %clang_pgogen -O2 -c -flto main.c90// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o91// RUN: rm -f default* && %run ./a.out92// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=MAIN93 94// ## LTO and PGO both files95// RUN: %clang_pgogen -O2 -c -flto foo.c96// RUN: %clang_pgogen -O2 -c -flto main.c97//98// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o99// RUN: rm -f default* && %run ./a.out100// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH101//102// RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o103// RUN: rm -f default* && %run ./a.out104// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH105//106// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o107// RUN: rm -f default* && %run ./a.out108// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH109//110// RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o111// RUN: rm -f default* && %run ./a.out112// RUN: llvm-profdata show --all-functions default* | FileCheck %s -check-prefix=BOTH113 114// BOTH-DAG: foo:115// BOTH-DAG: main:116// MAIN-NOT: foo:117// MAIN: main:118// MAIN-NOT: foo:119// NONE: Total functions: 0120