blob: 46b6e742f35e76256508877a8120f203ea19a96d [file] [log] [blame]
Douglas Gregor44eac332010-07-13 06:02:28 +00001// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple x86_64-apple-darwin10 %s | FileCheck %s
2
3// Ensure that we don't emit available_externally functions at -O0.
4int x;
5
6inline void f0(int y) { x = y; }
7
8// CHECK: define void @test()
9// CHECK: declare void @f0(i32)
10void test() {
11 f0(17);
12}
Douglas Gregor7feaeee2010-07-15 22:58:18 +000013
Nick Lewycky267ccbc2011-05-22 06:50:05 +000014inline int __attribute__((always_inline)) f1(int x) {
Douglas Gregor7feaeee2010-07-15 22:58:18 +000015 int blarg = 0;
16 for (int i = 0; i < x; ++i)
17 blarg = blarg + x * i;
Nick Lewycky267ccbc2011-05-22 06:50:05 +000018 return blarg;
Douglas Gregor7feaeee2010-07-15 22:58:18 +000019}
20
Douglas Gregor1ce377a2010-07-15 23:04:05 +000021// CHECK: @test1
Nick Lewycky267ccbc2011-05-22 06:50:05 +000022int test1(int x) {
Douglas Gregor7feaeee2010-07-15 22:58:18 +000023 // CHECK: br i1
Nick Lewycky267ccbc2011-05-22 06:50:05 +000024 // CHECK-NOT: call {{.*}} @f1
Douglas Gregor7feaeee2010-07-15 22:58:18 +000025 // CHECK: ret i32
Nick Lewycky267ccbc2011-05-22 06:50:05 +000026 return f1(x);
Douglas Gregor7feaeee2010-07-15 22:58:18 +000027}