2021-10-19 07:35:20 +08:00
|
|
|
// 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
|
2010-07-13 14:02:28 +08:00
|
|
|
|
|
|
|
// Ensure that we don't emit available_externally functions at -O0.
|
2015-07-07 00:23:00 +08:00
|
|
|
// Also should not emit them at -O2, unless -flto is present in which case
|
|
|
|
// we should preserve them for link-time inlining decisions.
|
2010-07-13 14:02:28 +08:00
|
|
|
int x;
|
|
|
|
|
|
|
|
inline void f0(int y) { x = y; }
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test()
|
2022-01-16 17:53:11 +08:00
|
|
|
// CHECK: declare void @f0(i32 noundef)
|
2020-12-31 12:45:56 +08:00
|
|
|
// LTO-LABEL: define{{.*}} void @test()
|
2015-07-07 00:23:00 +08:00
|
|
|
// LTO: define available_externally void @f0
|
2022-02-15 22:27:12 +08:00
|
|
|
void test(void) {
|
2010-07-13 14:02:28 +08:00
|
|
|
f0(17);
|
|
|
|
}
|
2010-07-16 06:58:18 +08:00
|
|
|
|
2011-05-22 14:50:05 +08:00
|
|
|
inline int __attribute__((always_inline)) f1(int x) {
|
2010-07-16 06:58:18 +08:00
|
|
|
int blarg = 0;
|
|
|
|
for (int i = 0; i < x; ++i)
|
|
|
|
blarg = blarg + x * i;
|
2011-05-22 14:50:05 +08:00
|
|
|
return blarg;
|
2010-07-16 06:58:18 +08:00
|
|
|
}
|
|
|
|
|
2010-07-16 07:04:05 +08:00
|
|
|
// CHECK: @test1
|
2015-07-07 00:23:00 +08:00
|
|
|
// LTO: @test1
|
2011-05-22 14:50:05 +08:00
|
|
|
int test1(int x) {
|
|
|
|
// CHECK-NOT: call {{.*}} @f1
|
2010-07-16 06:58:18 +08:00
|
|
|
// CHECK: ret i32
|
2015-07-07 00:23:00 +08:00
|
|
|
// LTO-NOT: call {{.*}} @f1
|
|
|
|
// LTO: ret i32
|
2011-05-22 14:50:05 +08:00
|
|
|
return f1(x);
|
2010-07-16 06:58:18 +08:00
|
|
|
}
|