teak-llvm/clang/test/CodeGen/available-externally-suppress.c
Teresa Johnson 8749d80431 Resubmit "Pass down the -flto option to the -cc1 job" (r239481)
The patch is the same except for the addition of a new test for the
issue that required reverting the dependent llvm commit.

--Original Commit Message--

Pass down the -flto option to the -cc1 job, and from there into the
CodeGenOptions and onto the PassManagerBuilder. This enables gating
the new EliminateAvailableExternally module pass on whether we are
preparing for LTO.

If we are preparing for LTO (e.g. a -flto -c compile), the new pass is not
included as we want to preserve available externally functions for possible
link time inlining.

llvm-svn: 241467
2015-07-06 16:23:00 +00:00

38 lines
1.1 KiB
C

// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
// RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
// RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO
// Ensure that we don't emit available_externally functions at -O0.
// Also should not emit them at -O2, unless -flto is present in which case
// we should preserve them for link-time inlining decisions.
int x;
inline void f0(int y) { x = y; }
// CHECK-LABEL: define void @test()
// CHECK: declare void @f0(i32)
// LTO-LABEL: define void @test()
// LTO: define available_externally void @f0
void test() {
f0(17);
}
inline int __attribute__((always_inline)) f1(int x) {
int blarg = 0;
for (int i = 0; i < x; ++i)
blarg = blarg + x * i;
return blarg;
}
// CHECK: @test1
// LTO: @test1
int test1(int x) {
// CHECK: br i1
// CHECK-NOT: call {{.*}} @f1
// CHECK: ret i32
// LTO: br i1
// LTO-NOT: call {{.*}} @f1
// LTO: ret i32
return f1(x);
}