brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · df2cabf Raw
117 lines · c
1// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \2// RUN:   -Werror=ignored-attributes \3// RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-NOM4// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \5// RUN:   -Werror=ignored-attributes -mfunction-return=keep \6// RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-KEEP7// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \8// RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \9// RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN10// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \11// RUN:  -mfunction-return=thunk-extern -coverage-data-file=/dev/null \12// RUN:   | FileCheck %s --check-prefix=CHECK-GCOV13// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \14// RUN:  -mfunction-return=thunk-extern -fsanitize=address \15// RUN:   | FileCheck %s --check-prefix=CHECK-ASAN16// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \17// RUN:  -mfunction-return=thunk-extern -fsanitize=thread \18// RUN:   | FileCheck %s --check-prefix=CHECK-TSAN19 20#if !__has_attribute(function_return)21#error "missing attribute support for function_return"22#endif23 24// CHECK: @keep() [[KEEP:#[0-9]+]]25__attribute__((function_return("keep"))) void keep(void) {}26 27// CHECK: @keep2() [[KEEP]]28[[gnu::function_return("keep")]] void keep2(void) {}29 30// CHECK: @thunk_extern() [[EXTERN:#[0-9]+]]31__attribute__((function_return("thunk-extern"))) void thunk_extern(void) {}32 33// CHECK: @thunk_extern2() [[EXTERN]]34[[gnu::function_return("thunk-extern")]] void thunk_extern2(void) {}35 36// CHECK: @double_thunk_keep() [[KEEP]]37// clang-format off38__attribute__((function_return("thunk-extern")))39__attribute__((function_return("keep")))40void double_thunk_keep(void) {}41 42// CHECK: @double_thunk_keep2() [[KEEP]]43[[gnu::function_return("thunk-extern")]][[gnu::function_return("keep")]]44void double_thunk_keep2(void) {}45 46// CHECK: @double_keep_thunk() [[EXTERN]]47__attribute__((function_return("keep")))48__attribute__((function_return("thunk-extern")))49void double_keep_thunk(void) {}50 51// CHECK: @double_keep_thunk2() [[EXTERN]]52[[gnu::function_return("keep")]][[gnu::function_return("thunk-extern")]]53void double_keep_thunk2(void) {}54 55// CHECK: @thunk_keep() [[KEEP]]56__attribute__((function_return("thunk-extern"), function_return("keep")))57void thunk_keep(void) {}58 59// CHECK: @thunk_keep2() [[KEEP]]60[[gnu::function_return("thunk-extern"), gnu::function_return("keep")]]61void thunk_keep2(void) {}62 63// CHECK: @keep_thunk() [[EXTERN]]64__attribute__((function_return("keep"), function_return("thunk-extern")))65void keep_thunk(void) {}66 67// CHECK: @keep_thunk2() [[EXTERN]]68[[gnu::function_return("keep"), gnu::function_return("thunk-extern")]]69void keep_thunk2(void) {}70// clang-format on71 72void undef(void);73// CHECK: @undef() [[KEEP]]74__attribute__((function_return("keep"))) void undef(void) {}75 76void undef2(void);77// CHECK: @undef2() [[EXTERN]]78__attribute__((function_return("thunk-extern"))) void undef2(void) {}79 80__attribute__((function_return("thunk-extern"))) void change_def(void);81// CHECK: @change_def() [[KEEP]]82__attribute__((function_return("keep"))) void change_def(void) {}83 84__attribute__((function_return("keep"))) void change_def2(void);85// CHECK: @change_def2() [[EXTERN]]86__attribute__((function_return("thunk-extern"))) void change_def2(void) {}87 88__attribute__((function_return("thunk-extern"))) void change_def3(void);89// CHECK: @change_def3() [[KEEP]]90[[gnu::function_return("keep")]] void change_def3(void) {}91 92[[gnu::function_return("keep")]] void change_def4(void);93// CHECK: @change_def4() [[EXTERN]]94__attribute__((function_return("thunk-extern"))) void change_def4(void) {}95 96// When there is no -mfunction-return= flag set (NOM) or it's set to keep,97// we don't emit anything into the IR for unattributed functions.98 99// CHECK-NOM:    @no_attrs() [[NOATTR:#[0-9]+]]100// CHECK-KEEP:   @no_attrs() [[NOATTR:#[0-9]+]]101// CHECK-EXTERN: @no_attrs() [[EXTERN]]102void no_attrs(void) {}103 104// Test synthetic functions.105// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]106// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]107// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]108// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]109// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]110 111// CHECK-NOM-NOT:  [[NOATTR]] = {{.*}}fn_ret_thunk_extern112// CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern113// CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern114// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern115// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern116// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern117