brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 7f9670c Raw
105 lines · plain
1; RUN: llc -mtriple=aarch64 -aarch64-min-jump-table-entries=4 %s -o - | FileCheck %s2 3define void @f0() "patchable-function-entry"="0" "branch-target-enforcement" {4; CHECK-LABEL: f0:5; CHECK-NEXT: .Lfunc_begin0:6; CHECK:      // %bb.0:7; CHECK-NEXT:  hint #348; CHECK-NEXT:  ret9; CHECK-NOT:  .section __patchable_function_entries10  ret void11}12 13;; -fpatchable-function-entry=1 -mbranch-protection=bti14;; For M=0, place the label .Lpatch0 after the initial BTI.15define void @f1() "patchable-function-entry"="1" "branch-target-enforcement" {16; CHECK-LABEL: f1:17; CHECK-NEXT: .Lfunc_begin1:18; CHECK-NEXT: .cfi_startproc19; CHECK-NEXT: // %bb.0:20; CHECK-NEXT:  hint #3421; CHECK-NEXT: .Lpatch0:22; CHECK-NEXT:  nop23; CHECK-NEXT:  ret24; CHECK:      .section __patchable_function_entries,"awo",@progbits,f1{{$}}25; CHECK-NEXT: .p2align 326; CHECK-NEXT: .xword .Lpatch027  ret void28}29 30;; -fpatchable-function-entry=2,1 -mbranch-protection=bti31define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement" {32; CHECK-LABEL: .type f2_1,@function33; CHECK-NEXT: .Ltmp0:34; CHECK-NEXT:  nop35; CHECK-NEXT: f2_1:36; CHECK-NEXT: .Lfunc_begin2:37; CHECK-NEXT: .cfi_startproc38; CHECK-NEXT: // %bb.0:39; CHECK-NEXT:  hint #3440; CHECK-NEXT:  nop41; CHECK-NEXT:  ret42; CHECK:      .Lfunc_end2:43; CHECK-NEXT: .size f2_1, .Lfunc_end2-f2_144; CHECK:      .section __patchable_function_entries,"awo",@progbits,f2_1{{$}}45; CHECK-NEXT: .p2align 346; CHECK-NEXT: .xword .Ltmp047  ret void48}49 50;; -fpatchable-function-entry=1 -mbranch-protection=bti51;; We don't add BTI c, because the function has internal linkage52define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement" {53; CHECK-LABEL: f1i:54; CHECK-NEXT: .Lfunc_begin3:55; CHECK:      // %bb.0:56; CHECK-NEXT:  nop57;; Other basic blocks have BTI, but they don't affect our decision to not create .Lpatch058; CHECK:      .LBB{{.+}} // %sw.bb159; CHECK-NEXT:  hint #3660; CHECK:      .section __patchable_function_entries,"awo",@progbits,f1i{{$}}61; CHECK-NEXT: .p2align 362; CHECK-NEXT: .xword .Lfunc_begin363entry:64  switch i64 %v, label %sw.bb0 [65    i64 1, label %sw.bb166    i64 2, label %sw.bb267    i64 3, label %sw.bb368    i64 4, label %sw.bb469  ]70sw.bb0:71  call void asm sideeffect "nop", ""()72  ret void73sw.bb1:74  call void asm sideeffect "", ""()75  ret void76sw.bb2:77  call void asm sideeffect "", ""()78  ret void79sw.bb3:80  call void asm sideeffect "", ""()81  ret void82sw.bb4:83  call void asm sideeffect "", ""()84  ret void85}86 87;; Test the interaction with -fsanitize=function.88; CHECK:      .type sanitize_function,@function89; CHECK-NEXT: .Ltmp{{.*}}:90; CHECK-NEXT:   nop91; CHECK-NEXT:   .word   3238382334  // 0xc105cafe92; CHECK-NEXT:   .word   4293; CHECK-NEXT: sanitize_function:94; CHECK-NEXT: .Lfunc_begin{{.*}}:95; CHECK-NEXT:   .cfi_startproc96; CHECK-NEXT:   // %bb.0:97; CHECK-NEXT:   hint #3498; CHECK-NEXT:   nop99; CHECK-NEXT:   ret100define void @sanitize_function(ptr noundef %x) "patchable-function-prefix"="1" "patchable-function-entry"="1" "branch-target-enforcement" !func_sanitize !0 {101  ret void102}103 104!0 = !{i32 3238382334, i32 42}105