blob: f41f12d066955381ce0ca7ab18198d034c8fd059 [file] [log] [blame]
Fangrui Songa44c4342020-01-04 15:39:19 -08001// RUN: %clang_cc1 -triple aarch64 -emit-llvm %s -o - | FileCheck %s
Fangrui Songf17ae662020-01-04 16:58:11 -08002// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s -fpatchable-function-entry=1 -o - | FileCheck --check-prefixes=CHECK,OPT %s
Fangrui Songa44c4342020-01-04 15:39:19 -08003
Fangrui Songdbc96b52020-02-03 10:09:39 -08004// CHECK: define void @f0() #0
Fangrui Songa44c4342020-01-04 15:39:19 -08005__attribute__((patchable_function_entry(0))) void f0() {}
6
Fangrui Songdbc96b52020-02-03 10:09:39 -08007// CHECK: define void @f00() #0
Fangrui Songa44c4342020-01-04 15:39:19 -08008__attribute__((patchable_function_entry(0, 0))) void f00() {}
9
Fangrui Songdbc96b52020-02-03 10:09:39 -080010// CHECK: define void @f2() #1
Fangrui Songa44c4342020-01-04 15:39:19 -080011__attribute__((patchable_function_entry(2))) void f2() {}
12
Fangrui Songdbc96b52020-02-03 10:09:39 -080013// CHECK: define void @f20() #1
Fangrui Songa44c4342020-01-04 15:39:19 -080014__attribute__((patchable_function_entry(2, 0))) void f20() {}
15
Fangrui Songdbc96b52020-02-03 10:09:39 -080016// CHECK: define void @f20decl() #1
Fangrui Songa44c4342020-01-04 15:39:19 -080017__attribute__((patchable_function_entry(2, 0))) void f20decl();
18void f20decl() {}
19
Fangrui Songdbc96b52020-02-03 10:09:39 -080020// CHECK: define void @f44() #2
Fangrui Song69bf40c2020-01-20 14:30:06 -080021__attribute__((patchable_function_entry(4, 4))) void f44() {}
22
Fangrui Songdbc96b52020-02-03 10:09:39 -080023// CHECK: define void @f52() #3
Fangrui Song69bf40c2020-01-20 14:30:06 -080024__attribute__((patchable_function_entry(5, 2))) void f52() {}
25
Fangrui Songdbc96b52020-02-03 10:09:39 -080026// OPT: define void @f() #4
Fangrui Songf17ae662020-01-04 16:58:11 -080027void f() {}
28
Fangrui Song69bf40c2020-01-20 14:30:06 -080029/// No need to emit "patchable-function-entry"="0"
30// CHECK: attributes #0 = { {{.*}}
31// CHECK-NOT: "patchable-function-entry"
32
Fangrui Songa44c4342020-01-04 15:39:19 -080033// CHECK: attributes #1 = { {{.*}} "patchable-function-entry"="2"
Fangrui Song69bf40c2020-01-20 14:30:06 -080034// CHECK: attributes #2 = { {{.*}} "patchable-function-entry"="0" "patchable-function-prefix"="4"
35// CHECK: attributes #3 = { {{.*}} "patchable-function-entry"="3" "patchable-function-prefix"="2"
36// OPT: attributes #4 = { {{.*}} "patchable-function-entry"="1"