Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
      2 // RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
      3 // RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO
      4 
      5 // Ensure that we don't emit available_externally functions at -O0.
      6 // Also should not emit them at -O2, unless -flto is present in which case
      7 // we should preserve them for link-time inlining decisions.
      8 int x;
      9 
     10 inline void f0(int y) { x = y; }
     11 
     12 // CHECK-LABEL: define void @test()
     13 // CHECK: declare void @f0(i32)
     14 // LTO-LABEL: define void @test()
     15 // LTO: define available_externally void @f0
     16 void test() {
     17   f0(17);
     18 }
     19 
     20 inline int __attribute__((always_inline)) f1(int x) {
     21   int blarg = 0;
     22   for (int i = 0; i < x; ++i)
     23     blarg = blarg + x * i;
     24   return blarg;
     25 }
     26 
     27 // CHECK: @test1
     28 // LTO: @test1
     29 int test1(int x) {
     30   // CHECK: br i1
     31   // CHECK-NOT: call {{.*}} @f1
     32   // CHECK: ret i32
     33   // LTO: br i1
     34   // LTO-NOT: call {{.*}} @f1
     35   // LTO: ret i32
     36   return f1(x);
     37 }
     38