https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94515
--- Comment #1 from nsz at gcc dot gnu.org --- i had a fix but it's not enough, so here is another test case: __attribute__((noreturn)) void unwind(void); int bar(void); int global; int foo(int x) { if (x==1) return 2; int y = bar(); if (y > global) global=y; if (y==3) unwind(); return 0; } -O2 -S -mbranch-protection=pac-ret the asm: foo: .cfi_startproc cmp w0, 1 beq .L4 hint 25 // paciasp .cfi_window_save //// pauth on stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16 .cfi_offset 29, -16 .cfi_offset 30, -8 mov x29, sp bl bar mov w1, w0 adrp x2, .LANCHOR0 ldr w0, [x2, #:lo12:.LANCHOR0] cmp w0, w1 blt .L11 .L3: mov w0, 0 cmp w1, 3 beq .L12 ldp x29, x30, [sp], 16 .cfi_remember_state .cfi_restore 30 .cfi_restore 29 .cfi_def_cfa_offset 0 hint 29 // autiasp .cfi_window_save //// pauth off ret .p2align 2,,3 .L11: .cfi_restore_state //// pauth on str w1, [x2, #:lo12:.LANCHOR0] b .L3 .p2align 2,,3 .L4: .cfi_def_cfa_offset 0 .cfi_restore 29 .cfi_restore 30 mov w0, 2 //// pauth should be off but it's on ret .L12: .cfi_def_cfa_offset 16 .cfi_offset 29, -16 .cfi_offset 30, -8 bl unwind .cfi_endproc