// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -Werror=ignored-attributes \
// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOM
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -Werror=ignored-attributes -mfunction-return=keep \
// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-KEEP
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -Werror=ignored-attributes -mfunction-return=thunk-extern \
// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -mfunction-return=thunk-extern -fprofile-arcs \
// RUN: | FileCheck %s --check-prefix=CHECK-GCOV
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -mfunction-return=thunk-extern -fsanitize=address \
// RUN: | FileCheck %s --check-prefix=CHECK-ASAN
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -mfunction-return=thunk-extern -fsanitize=thread \
// RUN: | FileCheck %s --check-prefix=CHECK-TSAN
// CHECK: @keep() [[KEEP:#[0-9]+]]
void
// CHECK: @keep2() [[KEEP]]
void
// CHECK: @thunk_extern() [[EXTERN:#[0-9]+]]
void
// CHECK: @thunk_extern2() [[EXTERN]]
void
// CHECK: @double_thunk_keep() [[KEEP]]
// clang-format off
void
// CHECK: @double_thunk_keep2() [[KEEP]]
void
// CHECK: @double_keep_thunk() [[EXTERN]]
void
// CHECK: @double_keep_thunk2() [[EXTERN]]
void
// CHECK: @thunk_keep() [[KEEP]]
void
// CHECK: @thunk_keep2() [[KEEP]]
void
// CHECK: @keep_thunk() [[EXTERN]]
void
// CHECK: @keep_thunk2() [[EXTERN]]
void
// clang-format on
void ;
// CHECK: @undef() [[KEEP]]
void
void ;
// CHECK: @undef2() [[EXTERN]]
void
void ;
// CHECK: @change_def() [[KEEP]]
void
void ;
// CHECK: @change_def2() [[EXTERN]]
void
void ;
// CHECK: @change_def3() [[KEEP]]
void
void ;
// CHECK: @change_def4() [[EXTERN]]
void
// When there is no -mfunction-return= flag set (NOM) or it's set to keep,
// we don't emit anything into the IR for unattributed functions.
// CHECK-NOM: @no_attrs() [[NOATTR:#[0-9]+]]
// CHECK-KEEP: @no_attrs() [[NOATTR:#[0-9]+]]
// CHECK-EXTERN: @no_attrs() [[EXTERN]]
void
// Test synthetic functions.
// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]
// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]
// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]
// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]
// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]
// CHECK-NOM-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
// CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
// CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern
// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern
// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern
// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern