llvm-project/clang/test/CodeGen/available-externally-suppress.c
Aaron Ballman ed509fe296 Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the tenth batch of tests being updated (there are a
significant number of other tests left to be updated).
2022-02-15 09:28:02 -05:00

36 lines
1.0 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 noundef)
// LTO-LABEL: define{{.*}} void @test()
// LTO: define available_externally void @f0
void test(void) {
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-NOT: call {{.*}} @f1
// CHECK: ret i32
// LTO-NOT: call {{.*}} @f1
// LTO: ret i32
return f1(x);
}