589 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22 3; PauthLR is controlled via a combination of -mbranch-protection and +pauth-lr.4; -mbranch-protection=+pc enables branch protection. If the feature +pauth-lr5; is available (v9.5a onwards) then non-NOP instructions are used; otherwise6; NOP instructions are used.7 8; There are 6 cases to cover:9 10; feature \ -mbranch-protection= | none | pac-ret | pac-ret+pc11; ------------------------------------------------------------------------12; without +pauth-lr | no codegen | old pac | NOP pauth-lr13; with +pauth-lr | no codegen | old pac | non-NOP pauth-lr14 15; sign-return-address.ll tests combinations of -mbranch-protection=none/pac-ret16; and whether +pauth-lr is present or not.17 18; sign-return-address-pauth-lr.ll is identical, with the addition of the function19; attribute, which enables -mbranch-protection=pac-ret+pc, and therefore tests20; the remaining parameter combinations in the table:21 22; RUN: llc -mtriple=aarch64 < %s | FileCheck --check-prefixes=CHECK,COMPAT %s23; RUN: llc -mtriple=aarch64 -mattr=v8.3a < %s | FileCheck --check-prefixes=CHECK,V83A %s24; RUN: llc -mtriple=aarch64 -mattr=v9a -mattr=pauth-lr < %s | FileCheck --check-prefixes=PAUTHLR %s25 26define i32 @leaf(i32 %x) "branch-protection-pauth-lr" {27; CHECK-LABEL: leaf:28; CHECK: // %bb.0:29; CHECK-NEXT: ret30;31; PAUTHLR-LABEL: leaf:32; PAUTHLR: // %bb.0:33; PAUTHLR-NEXT: ret34 ret i32 %x35}36 37define i32 @leaf_sign_none(i32 %x) "branch-protection-pauth-lr" {38; CHECK-LABEL: leaf_sign_none:39; CHECK: // %bb.0:40; CHECK-NEXT: ret41;42; PAUTHLR-LABEL: leaf_sign_none:43; PAUTHLR: // %bb.0:44; PAUTHLR-NEXT: ret45 ret i32 %x46}47 48define i32 @leaf_sign_non_leaf(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {49; CHECK-LABEL: leaf_sign_non_leaf:50; CHECK: // %bb.0:51; CHECK-NEXT: ret52;53; PAUTHLR-LABEL: leaf_sign_non_leaf:54; PAUTHLR: // %bb.0:55; PAUTHLR-NEXT: ret56 ret i32 %x57}58 59define i32 @leaf_sign_all(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" {60; COMPAT-LABEL: leaf_sign_all:61; COMPAT: // %bb.0:62; COMPAT-NEXT: hint #3963; COMPAT-NEXT: .cfi_negate_ra_state_with_pc64; COMPAT-NEXT: .Ltmp0:65; COMPAT-NEXT: hint #2566; COMPAT-NEXT: adrp x16, .Ltmp067; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp068; COMPAT-NEXT: hint #3969; COMPAT-NEXT: hint #2970; COMPAT-NEXT: ret71;72; V83A-LABEL: leaf_sign_all:73; V83A: // %bb.0:74; V83A-NEXT: hint #3975; V83A-NEXT: .cfi_negate_ra_state_with_pc76; V83A-NEXT: .Ltmp0:77; V83A-NEXT: paciasp78; V83A-NEXT: adrp x16, .Ltmp079; V83A-NEXT: add x16, x16, :lo12:.Ltmp080; V83A-NEXT: hint #3981; V83A-NEXT: retaa82;83; PAUTHLR-LABEL: leaf_sign_all:84; PAUTHLR: // %bb.0:85; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc86; PAUTHLR-NEXT: .Ltmp0:87; PAUTHLR-NEXT: paciasppc88; PAUTHLR-NEXT: adrp x16, .Ltmp089; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp090; PAUTHLR-NEXT: retaasppc .Ltmp091 ret i32 %x92}93 94define i64 @leaf_clobbers_lr(i64 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {95; COMPAT-LABEL: leaf_clobbers_lr:96; COMPAT: // %bb.0:97; COMPAT-NEXT: hint #3998; COMPAT-NEXT: .cfi_negate_ra_state_with_pc99; COMPAT-NEXT: .Ltmp1:100; COMPAT-NEXT: hint #25101; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill102; COMPAT-NEXT: .cfi_def_cfa_offset 16103; COMPAT-NEXT: .cfi_offset w30, -16104; COMPAT-NEXT: //APP105; COMPAT-NEXT: mov x30, x0106; COMPAT-NEXT: //NO_APP107; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload108; COMPAT-NEXT: adrp x16, .Ltmp1109; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp1110; COMPAT-NEXT: hint #39111; COMPAT-NEXT: hint #29112; COMPAT-NEXT: ret113;114; V83A-LABEL: leaf_clobbers_lr:115; V83A: // %bb.0:116; V83A-NEXT: hint #39117; V83A-NEXT: .cfi_negate_ra_state_with_pc118; V83A-NEXT: .Ltmp1:119; V83A-NEXT: paciasp120; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill121; V83A-NEXT: .cfi_def_cfa_offset 16122; V83A-NEXT: .cfi_offset w30, -16123; V83A-NEXT: //APP124; V83A-NEXT: mov x30, x0125; V83A-NEXT: //NO_APP126; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload127; V83A-NEXT: adrp x16, .Ltmp1128; V83A-NEXT: add x16, x16, :lo12:.Ltmp1129; V83A-NEXT: hint #39130; V83A-NEXT: retaa131;132; PAUTHLR-LABEL: leaf_clobbers_lr:133; PAUTHLR: // %bb.0:134; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc135; PAUTHLR-NEXT: .Ltmp1:136; PAUTHLR-NEXT: paciasppc137; PAUTHLR-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill138; PAUTHLR-NEXT: .cfi_def_cfa_offset 16139; PAUTHLR-NEXT: .cfi_offset w30, -16140; PAUTHLR-NEXT: //APP141; PAUTHLR-NEXT: mov x30, x0142; PAUTHLR-NEXT: //NO_APP143; PAUTHLR-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload144; PAUTHLR-NEXT: adrp x16, .Ltmp1145; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp1146; PAUTHLR-NEXT: retaasppc .Ltmp1147 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1148 ret i64 %x149}150 151declare i32 @foo(i32)152 153define i32 @non_leaf_sign_all(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" {154; COMPAT-LABEL: non_leaf_sign_all:155; COMPAT: // %bb.0:156; COMPAT-NEXT: hint #39157; COMPAT-NEXT: .cfi_negate_ra_state_with_pc158; COMPAT-NEXT: .Ltmp2:159; COMPAT-NEXT: hint #25160; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill161; COMPAT-NEXT: .cfi_def_cfa_offset 16162; COMPAT-NEXT: .cfi_offset w30, -16163; COMPAT-NEXT: bl foo164; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload165; COMPAT-NEXT: adrp x16, .Ltmp2166; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp2167; COMPAT-NEXT: hint #39168; COMPAT-NEXT: hint #29169; COMPAT-NEXT: ret170;171; V83A-LABEL: non_leaf_sign_all:172; V83A: // %bb.0:173; V83A-NEXT: hint #39174; V83A-NEXT: .cfi_negate_ra_state_with_pc175; V83A-NEXT: .Ltmp2:176; V83A-NEXT: paciasp177; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill178; V83A-NEXT: .cfi_def_cfa_offset 16179; V83A-NEXT: .cfi_offset w30, -16180; V83A-NEXT: bl foo181; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload182; V83A-NEXT: adrp x16, .Ltmp2183; V83A-NEXT: add x16, x16, :lo12:.Ltmp2184; V83A-NEXT: hint #39185; V83A-NEXT: retaa186;187; PAUTHLR-LABEL: non_leaf_sign_all:188; PAUTHLR: // %bb.0:189; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc190; PAUTHLR-NEXT: .Ltmp2:191; PAUTHLR-NEXT: paciasppc192; PAUTHLR-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill193; PAUTHLR-NEXT: .cfi_def_cfa_offset 16194; PAUTHLR-NEXT: .cfi_offset w30, -16195; PAUTHLR-NEXT: bl foo196; PAUTHLR-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload197; PAUTHLR-NEXT: adrp x16, .Ltmp2198; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp2199; PAUTHLR-NEXT: retaasppc .Ltmp2200 %call = call i32 @foo(i32 %x)201 ret i32 %call202}203 204define i32 @non_leaf_sign_non_leaf(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {205; COMPAT-LABEL: non_leaf_sign_non_leaf:206; COMPAT: // %bb.0:207; COMPAT-NEXT: hint #39208; COMPAT-NEXT: .cfi_negate_ra_state_with_pc209; COMPAT-NEXT: .Ltmp3:210; COMPAT-NEXT: hint #25211; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill212; COMPAT-NEXT: .cfi_def_cfa_offset 16213; COMPAT-NEXT: .cfi_offset w30, -16214; COMPAT-NEXT: bl foo215; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload216; COMPAT-NEXT: adrp x16, .Ltmp3217; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp3218; COMPAT-NEXT: hint #39219; COMPAT-NEXT: hint #29220; COMPAT-NEXT: ret221;222; V83A-LABEL: non_leaf_sign_non_leaf:223; V83A: // %bb.0:224; V83A-NEXT: hint #39225; V83A-NEXT: .cfi_negate_ra_state_with_pc226; V83A-NEXT: .Ltmp3:227; V83A-NEXT: paciasp228; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill229; V83A-NEXT: .cfi_def_cfa_offset 16230; V83A-NEXT: .cfi_offset w30, -16231; V83A-NEXT: bl foo232; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload233; V83A-NEXT: adrp x16, .Ltmp3234; V83A-NEXT: add x16, x16, :lo12:.Ltmp3235; V83A-NEXT: hint #39236; V83A-NEXT: retaa237;238; PAUTHLR-LABEL: non_leaf_sign_non_leaf:239; PAUTHLR: // %bb.0:240; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc241; PAUTHLR-NEXT: .Ltmp3:242; PAUTHLR-NEXT: paciasppc243; PAUTHLR-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill244; PAUTHLR-NEXT: .cfi_def_cfa_offset 16245; PAUTHLR-NEXT: .cfi_offset w30, -16246; PAUTHLR-NEXT: bl foo247; PAUTHLR-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload248; PAUTHLR-NEXT: adrp x16, .Ltmp3249; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp3250; PAUTHLR-NEXT: retaasppc .Ltmp3251 %call = call i32 @foo(i32 %x)252 ret i32 %call253}254 255; Should not use the RETAA instruction.256define i32 @non_leaf_scs(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" shadowcallstack "target-features"="+v8.3a,+reserve-x18" {257; CHECK-LABEL: non_leaf_scs:258; CHECK: // %bb.0:259; CHECK-NEXT: hint #39260; CHECK-NEXT: .cfi_negate_ra_state_with_pc261; CHECK-NEXT: .Ltmp4:262; CHECK-NEXT: paciasp263; CHECK-NEXT: str x30, [x18], #8264; CHECK-NEXT: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 //265; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill266; CHECK-NEXT: .cfi_def_cfa_offset 16267; CHECK-NEXT: .cfi_offset w30, -16268; CHECK-NEXT: bl foo269; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload270; CHECK-NEXT: ldr x30, [x18, #-8]!271; CHECK-NEXT: adrp x16, .Ltmp4272; CHECK-NEXT: add x16, x16, :lo12:.Ltmp4273; CHECK-NEXT: hint #39274; CHECK-NEXT: autiasp275; CHECK-NEXT: ret276;277; PAUTHLR-LABEL: non_leaf_scs:278; PAUTHLR: // %bb.0:279; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc280; PAUTHLR-NEXT: .Ltmp4:281; PAUTHLR-NEXT: paciasppc282; PAUTHLR-NEXT: str x30, [x18], #8283; PAUTHLR-NEXT: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 //284; PAUTHLR-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill285; PAUTHLR-NEXT: .cfi_def_cfa_offset 16286; PAUTHLR-NEXT: .cfi_offset w30, -16287; PAUTHLR-NEXT: bl foo288; PAUTHLR-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload289; PAUTHLR-NEXT: ldr x30, [x18, #-8]!290; PAUTHLR-NEXT: adrp x16, .Ltmp4291; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp4292; PAUTHLR-NEXT: autiasppc .Ltmp4293; PAUTHLR-NEXT: ret294 %call = call i32 @foo(i32 %x)295 ret i32 %call296}297 298define i32 @leaf_sign_all_v83(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "target-features"="+v8.3a" {299; CHECK-LABEL: leaf_sign_all_v83:300; CHECK: // %bb.0:301; CHECK-NEXT: hint #39302; CHECK-NEXT: .cfi_negate_ra_state_with_pc303; CHECK-NEXT: .Ltmp5:304; CHECK-NEXT: paciasp305; CHECK-NEXT: adrp x16, .Ltmp5306; CHECK-NEXT: add x16, x16, :lo12:.Ltmp5307; CHECK-NEXT: hint #39308; CHECK-NEXT: retaa309;310; PAUTHLR-LABEL: leaf_sign_all_v83:311; PAUTHLR: // %bb.0:312; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc313; PAUTHLR-NEXT: .Ltmp5:314; PAUTHLR-NEXT: paciasppc315; PAUTHLR-NEXT: adrp x16, .Ltmp5316; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp5317; PAUTHLR-NEXT: retaasppc .Ltmp5318 ret i32 %x319}320 321declare fastcc i64 @bar(i64)322 323define fastcc void @spill_lr_and_tail_call(i64 %x) "branch-protection-pauth-lr" "sign-return-address"="all" {324; COMPAT-LABEL: spill_lr_and_tail_call:325; COMPAT: // %bb.0:326; COMPAT-NEXT: hint #39327; COMPAT-NEXT: .cfi_negate_ra_state_with_pc328; COMPAT-NEXT: .Ltmp6:329; COMPAT-NEXT: hint #25330; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill331; COMPAT-NEXT: .cfi_def_cfa_offset 16332; COMPAT-NEXT: .cfi_offset w30, -16333; COMPAT-NEXT: //APP334; COMPAT-NEXT: mov x30, x0335; COMPAT-NEXT: //NO_APP336; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload337; COMPAT-NEXT: adrp x16, .Ltmp6338; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp6339; COMPAT-NEXT: hint #39340; COMPAT-NEXT: hint #29341; COMPAT-NEXT: b bar342;343; V83A-LABEL: spill_lr_and_tail_call:344; V83A: // %bb.0:345; V83A-NEXT: hint #39346; V83A-NEXT: .cfi_negate_ra_state_with_pc347; V83A-NEXT: .Ltmp6:348; V83A-NEXT: paciasp349; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill350; V83A-NEXT: .cfi_def_cfa_offset 16351; V83A-NEXT: .cfi_offset w30, -16352; V83A-NEXT: //APP353; V83A-NEXT: mov x30, x0354; V83A-NEXT: //NO_APP355; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload356; V83A-NEXT: adrp x16, .Ltmp6357; V83A-NEXT: add x16, x16, :lo12:.Ltmp6358; V83A-NEXT: hint #39359; V83A-NEXT: autiasp360; V83A-NEXT: b bar361;362; PAUTHLR-LABEL: spill_lr_and_tail_call:363; PAUTHLR: // %bb.0:364; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc365; PAUTHLR-NEXT: .Ltmp6:366; PAUTHLR-NEXT: paciasppc367; PAUTHLR-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill368; PAUTHLR-NEXT: .cfi_def_cfa_offset 16369; PAUTHLR-NEXT: .cfi_offset w30, -16370; PAUTHLR-NEXT: //APP371; PAUTHLR-NEXT: mov x30, x0372; PAUTHLR-NEXT: //NO_APP373; PAUTHLR-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload374; PAUTHLR-NEXT: adrp x16, .Ltmp6375; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp6376; PAUTHLR-NEXT: autiasppc .Ltmp6377; PAUTHLR-NEXT: b bar378 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1379 tail call fastcc i64 @bar(i64 %x)380 ret void381}382 383define i32 @leaf_sign_all_a_key(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "sign-return-address-key"="a_key" {384; COMPAT-LABEL: leaf_sign_all_a_key:385; COMPAT: // %bb.0:386; COMPAT-NEXT: hint #39387; COMPAT-NEXT: .cfi_negate_ra_state_with_pc388; COMPAT-NEXT: .Ltmp7:389; COMPAT-NEXT: hint #25390; COMPAT-NEXT: adrp x16, .Ltmp7391; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp7392; COMPAT-NEXT: hint #39393; COMPAT-NEXT: hint #29394; COMPAT-NEXT: ret395;396; V83A-LABEL: leaf_sign_all_a_key:397; V83A: // %bb.0:398; V83A-NEXT: hint #39399; V83A-NEXT: .cfi_negate_ra_state_with_pc400; V83A-NEXT: .Ltmp7:401; V83A-NEXT: paciasp402; V83A-NEXT: adrp x16, .Ltmp7403; V83A-NEXT: add x16, x16, :lo12:.Ltmp7404; V83A-NEXT: hint #39405; V83A-NEXT: retaa406;407; PAUTHLR-LABEL: leaf_sign_all_a_key:408; PAUTHLR: // %bb.0:409; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc410; PAUTHLR-NEXT: .Ltmp7:411; PAUTHLR-NEXT: paciasppc412; PAUTHLR-NEXT: adrp x16, .Ltmp7413; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp7414; PAUTHLR-NEXT: retaasppc .Ltmp7415 ret i32 %x416}417 418define i32 @leaf_sign_all_b_key(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "sign-return-address-key"="b_key" {419; COMPAT-LABEL: leaf_sign_all_b_key:420; COMPAT: // %bb.0:421; COMPAT-NEXT: .cfi_b_key_frame422; COMPAT-NEXT: hint #39423; COMPAT-NEXT: .cfi_negate_ra_state_with_pc424; COMPAT-NEXT: .Ltmp8:425; COMPAT-NEXT: hint #27426; COMPAT-NEXT: adrp x16, .Ltmp8427; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp8428; COMPAT-NEXT: hint #39429; COMPAT-NEXT: hint #31430; COMPAT-NEXT: ret431;432; V83A-LABEL: leaf_sign_all_b_key:433; V83A: // %bb.0:434; V83A-NEXT: .cfi_b_key_frame435; V83A-NEXT: hint #39436; V83A-NEXT: .cfi_negate_ra_state_with_pc437; V83A-NEXT: .Ltmp8:438; V83A-NEXT: pacibsp439; V83A-NEXT: adrp x16, .Ltmp8440; V83A-NEXT: add x16, x16, :lo12:.Ltmp8441; V83A-NEXT: hint #39442; V83A-NEXT: retab443;444; PAUTHLR-LABEL: leaf_sign_all_b_key:445; PAUTHLR: // %bb.0:446; PAUTHLR-NEXT: .cfi_b_key_frame447; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc448; PAUTHLR-NEXT: .Ltmp8:449; PAUTHLR-NEXT: pacibsppc450; PAUTHLR-NEXT: adrp x16, .Ltmp8451; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp8452; PAUTHLR-NEXT: retabsppc .Ltmp8453 ret i32 %x454}455 456define i32 @leaf_sign_all_v83_b_key(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "target-features"="+v8.3a" "sign-return-address-key"="b_key" {457; CHECK-LABEL: leaf_sign_all_v83_b_key:458; CHECK: // %bb.0:459; CHECK-NEXT: .cfi_b_key_frame460; CHECK-NEXT: hint #39461; CHECK-NEXT: .cfi_negate_ra_state_with_pc462; CHECK-NEXT: .Ltmp9:463; CHECK-NEXT: pacibsp464; CHECK-NEXT: adrp x16, .Ltmp9465; CHECK-NEXT: add x16, x16, :lo12:.Ltmp9466; CHECK-NEXT: hint #39467; CHECK-NEXT: retab468;469; PAUTHLR-LABEL: leaf_sign_all_v83_b_key:470; PAUTHLR: // %bb.0:471; PAUTHLR-NEXT: .cfi_b_key_frame472; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc473; PAUTHLR-NEXT: .Ltmp9:474; PAUTHLR-NEXT: pacibsppc475; PAUTHLR-NEXT: adrp x16, .Ltmp9476; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp9477; PAUTHLR-NEXT: retabsppc .Ltmp9478 ret i32 %x479}480 481; Note that BTI instruction is not needed before PACIASP.482define i32 @leaf_sign_all_a_key_bti(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "sign-return-address-key"="a_key" "branch-target-enforcement" {483; COMPAT-LABEL: leaf_sign_all_a_key_bti:484; COMPAT: // %bb.0:485; COMPAT-NEXT: hint #34486; COMPAT-NEXT: hint #39487; COMPAT-NEXT: .cfi_negate_ra_state_with_pc488; COMPAT-NEXT: .Ltmp10:489; COMPAT-NEXT: hint #25490; COMPAT-NEXT: adrp x16, .Ltmp10491; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp10492; COMPAT-NEXT: hint #39493; COMPAT-NEXT: hint #29494; COMPAT-NEXT: ret495;496; V83A-LABEL: leaf_sign_all_a_key_bti:497; V83A: // %bb.0:498; V83A-NEXT: hint #34499; V83A-NEXT: hint #39500; V83A-NEXT: .cfi_negate_ra_state_with_pc501; V83A-NEXT: .Ltmp10:502; V83A-NEXT: paciasp503; V83A-NEXT: adrp x16, .Ltmp10504; V83A-NEXT: add x16, x16, :lo12:.Ltmp10505; V83A-NEXT: hint #39506; V83A-NEXT: retaa507;508; PAUTHLR-LABEL: leaf_sign_all_a_key_bti:509; PAUTHLR: // %bb.0:510; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc511; PAUTHLR-NEXT: bti c512; PAUTHLR-NEXT: .Ltmp10:513; PAUTHLR-NEXT: paciasppc514; PAUTHLR-NEXT: adrp x16, .Ltmp10515; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp10516; PAUTHLR-NEXT: retaasppc .Ltmp10517 ret i32 %x518}519 520; Note that BTI instruction is not needed before PACIBSP.521define i32 @leaf_sign_all_b_key_bti(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "sign-return-address-key"="b_key" "branch-target-enforcement" {522; COMPAT-LABEL: leaf_sign_all_b_key_bti:523; COMPAT: // %bb.0:524; COMPAT-NEXT: .cfi_b_key_frame525; COMPAT-NEXT: hint #34526; COMPAT-NEXT: hint #39527; COMPAT-NEXT: .cfi_negate_ra_state_with_pc528; COMPAT-NEXT: .Ltmp11:529; COMPAT-NEXT: hint #27530; COMPAT-NEXT: adrp x16, .Ltmp11531; COMPAT-NEXT: add x16, x16, :lo12:.Ltmp11532; COMPAT-NEXT: hint #39533; COMPAT-NEXT: hint #31534; COMPAT-NEXT: ret535;536; V83A-LABEL: leaf_sign_all_b_key_bti:537; V83A: // %bb.0:538; V83A-NEXT: .cfi_b_key_frame539; V83A-NEXT: hint #34540; V83A-NEXT: hint #39541; V83A-NEXT: .cfi_negate_ra_state_with_pc542; V83A-NEXT: .Ltmp11:543; V83A-NEXT: pacibsp544; V83A-NEXT: adrp x16, .Ltmp11545; V83A-NEXT: add x16, x16, :lo12:.Ltmp11546; V83A-NEXT: hint #39547; V83A-NEXT: retab548;549; PAUTHLR-LABEL: leaf_sign_all_b_key_bti:550; PAUTHLR: // %bb.0:551; PAUTHLR-NEXT: .cfi_b_key_frame552; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc553; PAUTHLR-NEXT: bti c554; PAUTHLR-NEXT: .Ltmp11:555; PAUTHLR-NEXT: pacibsppc556; PAUTHLR-NEXT: adrp x16, .Ltmp11557; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp11558; PAUTHLR-NEXT: retabsppc .Ltmp11559 ret i32 %x560}561 562; Note that BTI instruction is not needed before PACIBSP.563define i32 @leaf_sign_all_v83_b_key_bti(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" "target-features"="+v8.3a" "sign-return-address-key"="b_key" "branch-target-enforcement" {564; CHECK-LABEL: leaf_sign_all_v83_b_key_bti:565; CHECK: // %bb.0:566; CHECK-NEXT: .cfi_b_key_frame567; CHECK-NEXT: hint #34568; CHECK-NEXT: hint #39569; CHECK-NEXT: .cfi_negate_ra_state_with_pc570; CHECK-NEXT: .Ltmp12:571; CHECK-NEXT: pacibsp572; CHECK-NEXT: adrp x16, .Ltmp12573; CHECK-NEXT: add x16, x16, :lo12:.Ltmp12574; CHECK-NEXT: hint #39575; CHECK-NEXT: retab576;577; PAUTHLR-LABEL: leaf_sign_all_v83_b_key_bti:578; PAUTHLR: // %bb.0:579; PAUTHLR-NEXT: .cfi_b_key_frame580; PAUTHLR-NEXT: .cfi_negate_ra_state_with_pc581; PAUTHLR-NEXT: bti c582; PAUTHLR-NEXT: .Ltmp12:583; PAUTHLR-NEXT: pacibsppc584; PAUTHLR-NEXT: adrp x16, .Ltmp12585; PAUTHLR-NEXT: add x16, x16, :lo12:.Ltmp12586; PAUTHLR-NEXT: retabsppc .Ltmp12587 ret i32 %x588}589