Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / attr-function-return.cpp
blob75cecc99ad490b55e89b1bca52c7725577faa624
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -emit-llvm -o - \
2 // RUN: -Werror=unknown-attributes \
3 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOM
4 // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -emit-llvm -o - \
5 // RUN: -Werror=unknown-attributes -mfunction-return=keep \
6 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-KEEP
7 // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -emit-llvm -o - \
8 // RUN: -Werror=unknown-attributes -mfunction-return=thunk-extern \
9 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
11 int foo(void) {
12 // CHECK: @"_ZZ3foovENK3$_0clEv"({{.*}}) [[NOATTR:#[0-9]+]]
13 return []() {
14 return 42;
15 }();
17 int bar(void) {
18 // CHECK: @"_ZZ3barvENK3$_0clEv"({{.*}}) [[EXTERN:#[0-9]+]]
19 return []() __attribute__((function_return("thunk-extern"))) {
20 return 42;
22 ();
24 int baz(void) {
25 // CHECK: @"_ZZ3bazvENK3$_0clEv"({{.*}}) [[KEEP:#[0-9]+]]
26 return []() __attribute__((function_return("keep"))) {
27 return 42;
29 ();
32 class Foo {
33 public:
34 // CHECK: @_ZN3Foo3fooEv({{.*}}) [[EXTERN]]
35 __attribute__((function_return("thunk-extern"))) int foo() { return 42; }
38 int quux() {
39 Foo my_foo;
40 return my_foo.foo();
43 // CHECK: @extern_c() [[EXTERN]]
44 extern "C" __attribute__((function_return("thunk-extern"))) void extern_c() {}
45 extern "C" {
46 // CHECK: @extern_c2() [[EXTERN]]
47 __attribute__((function_return("thunk-extern"))) void extern_c2() {}
50 // CHECK-NOM-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
51 // CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
52 // CHECK-KEEP-NOT: [[KEEP]] = {{.*}}fn_ret_thunk_extern
53 // CHECK-EXTERN: [[EXTERN]] = {{.*}}fn_ret_thunk_extern