1; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s 2 3define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" { 4; CHECK-LABEL: f0: 5; CHECK-NEXT: .Lfunc_begin0: 6; CHECK: // %bb.0: 7; CHECK-NEXT: hint #34 8; CHECK-NEXT: ret 9; CHECK-NOT: .section __patchable_function_entries 10 ret void 11} 12 13;; -fpatchable-function-entry=1 -mbranch-protection=bti 14;; For M=0, place the label .Lpatch0 after the initial BTI. 15define void @f1() "patchable-function-entry"="1" "branch-target-enforcement"="true" { 16; CHECK-LABEL: f1: 17; CHECK-NEXT: .Lfunc_begin1: 18; CHECK-NEXT: .cfi_startproc 19; CHECK-NEXT: // %bb.0: 20; CHECK-NEXT: hint #34 21; CHECK-NEXT: .Lpatch0: 22; CHECK-NEXT: nop 23; CHECK-NEXT: ret 24; CHECK: .section __patchable_function_entries,"awo",@progbits,f1{{$}} 25; CHECK-NEXT: .p2align 3 26; CHECK-NEXT: .xword .Lpatch0 27 ret void 28} 29 30;; -fpatchable-function-entry=2,1 -mbranch-protection=bti 31define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement"="true" { 32; CHECK-LABEL: .type f2_1,@function 33; CHECK-NEXT: .Ltmp0: 34; CHECK-NEXT: nop 35; CHECK-NEXT: f2_1: 36; CHECK-NEXT: .Lfunc_begin2: 37; CHECK-NEXT: .cfi_startproc 38; CHECK-NEXT: // %bb.0: 39; CHECK-NEXT: hint #34 40; CHECK-NEXT: nop 41; CHECK-NEXT: ret 42; CHECK: .Lfunc_end2: 43; CHECK-NEXT: .size f2_1, .Lfunc_end2-f2_1 44; CHECK: .section __patchable_function_entries,"awo",@progbits,f2_1{{$}} 45; CHECK-NEXT: .p2align 3 46; CHECK-NEXT: .xword .Ltmp0 47 ret void 48} 49 50;; -fpatchable-function-entry=1 -mbranch-protection=bti 51;; For M=0, don't create .Lpatch0 if the initial instruction is not BTI, 52;; even if other basic blocks may have BTI. 53define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement"="true" { 54; CHECK-LABEL: f1i: 55; CHECK-NEXT: .Lfunc_begin3: 56; CHECK: // %bb.0: 57; CHECK-NEXT: nop 58;; Other basic blocks have BTI, but they don't affect our decision to not create .Lpatch0 59; CHECK: .LBB{{.+}} // %sw.bb1 60; CHECK-NEXT: hint #36 61; CHECK: .section __patchable_function_entries,"awo",@progbits,f1i{{$}} 62; CHECK-NEXT: .p2align 3 63; CHECK-NEXT: .xword .Lfunc_begin3 64entry: 65 switch i64 %v, label %sw.bb0 [ 66 i64 1, label %sw.bb1 67 i64 2, label %sw.bb2 68 i64 3, label %sw.bb3 69 i64 4, label %sw.bb4 70 ] 71sw.bb0: 72 call void asm sideeffect "", ""() 73 ret void 74sw.bb1: 75 call void asm sideeffect "", ""() 76 ret void 77sw.bb2: 78 call void asm sideeffect "", ""() 79 ret void 80sw.bb3: 81 call void asm sideeffect "", ""() 82 ret void 83sw.bb4: 84 call void asm sideeffect "", ""() 85 ret void 86} 87