Skip to content

[test][PAC][AArch64] Add ELF tests for subtarget-neutral codegen #98020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

kovdan01
Copy link
Contributor

@kovdan01 kovdan01 commented Jul 8, 2024

Many parts of PAuth-related codegen are not MachO- or ELF-specific. Add RUN lines against ELF targets to ensure that codegen works for ELF as well as for MachO.

@kovdan01 kovdan01 self-assigned this Jul 8, 2024
@kovdan01 kovdan01 requested review from asl, ahmedbougacha and kbeyls July 8, 2024 13:26
@llvmbot
Copy link
Member

llvmbot commented Jul 8, 2024

@llvm/pr-subscribers-backend-aarch64

Author: Daniil Kovalev (kovdan01)

Changes

Many parts of PAuth-related codegen are not MachO- or ELF-specific. Add RUN lines against ELF targets to ensure that codegen works for ELF as well as for MachO.


Full diff: https://github.com/llvm/llvm-project/pull/98020.diff

5 Files Affected:

  • (modified) llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll (+75-48)
  • (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll (+35-21)
  • (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll (+14-6)
  • (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll (+56-34)
  • (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll (+32-20)
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll
index 3a992929a8003..90a72a8f6ee07 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll
@@ -1,101 +1,128 @@
-; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti              -asm-verbose=false -o - %s | FileCheck %s
-; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -global-isel -asm-verbose=false -o - %s | FileCheck %s
-; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -fast-isel   -asm-verbose=false -o - %s | FileCheck %s
+; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti              -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -global-isel -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -fast-isel   -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc -mtriple aarch64-linux-gnu   -mattr=+bti -mattr=+pauth              -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc -mtriple aarch64-linux-gnu   -mattr=+bti -mattr=+pauth -global-isel -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc -mtriple aarch64-linux-gnu   -mattr=+bti -mattr=+pauth -fast-isel   -asm-verbose=false \
+; RUN:   -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
 
-; ptrauth tail-calls can only use x16/x17 with BTI.
+;; ptrauth tail-calls can only use x16/x17 with BTI.
 
-; CHECK-LABEL: _test_tailcall_ia_0:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  braaz x16
+; DARWIN-LABEL: _test_tailcall_ia_0:
+; ELF-LABEL:    test_tailcall_ia_0:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   braaz x16
 define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ib_0:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  brabz x16
+; DARWIN-LABEL: _test_tailcall_ib_0:
+; ELF-LABEL:    test_tailcall_ib_0:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   brabz x16
 define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ia_imm:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  mov x17, #42
-; CHECK-NEXT:  braa x16, x17
+; DARWIN-LABEL: _test_tailcall_ia_imm:
+; ELF-LABEL:    test_tailcall_ia_imm:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   mov x17, #42
+; CHECK-NEXT:   braa x16, x17
 define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ib_imm:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  mov x17, #42
-; CHECK-NEXT:  brab x16, x17
+; DARWIN-LABEL: _test_tailcall_ib_imm:
+; ELF-LABEL:    test_tailcall_ib_imm:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   mov x17, #42
+; CHECK-NEXT:   brab x16, x17
 define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ia_var:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  ldr x0, [x1]
-; CHECK-NEXT:  braa x16, x0
+; DARWIN-LABEL: _test_tailcall_ia_var:
+; DARWIN-NEXT:  bti c
+; DARWIN-NEXT:  mov x16, x0
+; DARWIN-NEXT:  ldr x0, [x1]
+; DARWIN-NEXT:  braa x16, x0
+; ELF-LABEL:    test_tailcall_ia_var:
+; ELF-NEXT:     bti c
+; ELF-NEXT:     ldr x1, [x1]
+; ELF-NEXT:     mov x16, x0
+; ELF-NEXT:     braa x16, x1
 define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 {
   %tmp0 = load i64, i64* %arg1
   %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ]
   ret i32 %tmp1
 }
 
-; CHECK-LABEL: _test_tailcall_ib_var:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  ldr x0, [x1]
-; CHECK-NEXT:  brab x16, x0
+; DARWIN-LABEL: _test_tailcall_ib_var:
+; DARWIN-NEXT:  bti c
+; DARWIN-NEXT:  mov x16, x0
+; DARWIN-NEXT:  ldr x0, [x1]
+; DARWIN-NEXT:  brab x16, x0
+; ELF-LABEL:    test_tailcall_ib_var:
+; ELF-NEXT:     bti c
+; ELF-NEXT:     ldr x1, [x1]
+; ELF-NEXT:     mov x16, x0
+; ELF-NEXT:     brab x16, x1
 define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 {
   %tmp0 = load i64, i64* %arg1
   %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ]
   ret i32 %tmp1
 }
 
-; CHECK-LABEL: _test_tailcall_ia_arg:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  braa x16, x1
+; DARWIN-LABEL: _test_tailcall_ia_arg:
+; ELF-LABEL:    test_tailcall_ia_arg:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   braa x16, x1
 define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ib_arg:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  mov x16, x0
-; CHECK-NEXT:  brab x16, x1
+; DARWIN-LABEL: _test_tailcall_ib_arg:
+; ELF-LABEL:    test_tailcall_ib_arg:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   mov x16, x0
+; CHECK-NEXT:   brab x16, x1
 define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 {
   %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ]
   ret i32 %tmp0
 }
 
-; CHECK-LABEL: _test_tailcall_ia_arg_ind:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  ldr x16, [x0]
-; CHECK-NEXT:  braa x16, x1
+; DARWIN-LABEL: _test_tailcall_ia_arg_ind:
+; ELF-LABEL:    test_tailcall_ia_arg_ind:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   ldr x16, [x0]
+; CHECK-NEXT:   braa x16, x1
 define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
   %tmp0 = load i32 ()*, i32 ()** %arg0
   %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ]
   ret i32 %tmp1
 }
 
-; CHECK-LABEL: _test_tailcall_ib_arg_ind:
-; CHECK-NEXT:  bti c
-; CHECK-NEXT:  ldr x16, [x0]
-; CHECK-NEXT:  brab x16, x1
+; DARWIN-LABEL: _test_tailcall_ib_arg_ind:
+; ELF-LABEL:    test_tailcall_ib_arg_ind:
+; CHECK-NEXT:   bti c
+; CHECK-NEXT:   ldr x16, [x0]
+; CHECK-NEXT:   brab x16, x1
 define i32 @test_tailcall_ib_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
   %tmp0 = load i32 ()*, i32 ()** %arg0
   %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ]
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll
index e60b3dfeaf225..ecb1ab76189bd 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll
@@ -1,44 +1,58 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
 
 define i64 @test_blend(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_blend:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    bfi x0, x1, #48, #16
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_blend:
+; ELF-LABEL:    test_blend:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     bfi x0, x1, #48, #16
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 %arg1)
   ret i64 %tmp
 }
 
 define i64 @test_blend_constant(i64 %arg) {
-; CHECK-LABEL: test_blend_constant:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    movk x0, #12345, lsl #48
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_blend_constant:
+; ELF-LABEL:    test_blend_constant:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     movk x0, #12345, lsl #48
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 12345)
   ret i64 %tmp
 }
 
 ; Blend isn't commutative.
 define i64 @test_blend_constant_swapped(i64 %arg) {
-; CHECK-LABEL: test_blend_constant_swapped:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    mov w8, #12345
-; CHECK-NEXT:    bfi x8, x0, #48, #16
-; CHECK-NEXT:    mov x0, x8
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_blend_constant_swapped:
+; ELF-LABEL:    test_blend_constant_swapped:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     mov w8, #12345
+; CHECK-NEXT:     bfi x8, x0, #48, #16
+; CHECK-NEXT:     mov x0, x8
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.blend(i64 12345, i64 %arg)
   ret i64 %tmp
 }
 
 ; Blends of constants wider than 16 bits truncate the constant.
 define i64 @test_blend_constant_wide(i64 %arg) {
-; CHECK-LABEL: test_blend_constant_wide:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    mov w8, #65536
-; CHECK-NEXT:    bfi x0, x8, #48, #16
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_blend_constant_wide:
+; ELF-LABEL:    test_blend_constant_wide:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     mov w8, #65536
+; CHECK-NEXT:     bfi x0, x8, #48, #16
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 65536)
   ret i64 %tmp
 }
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll
index 1f14f67926f77..721325df726ab 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll
@@ -1,12 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
 
 define i64 @test_sign_generic(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_sign_generic:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacga x0, x0, x1
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_generic:
+; ELF-LABEL:    test_sign_generic:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacga x0, x0, x1
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign.generic(i64 %arg, i64 %arg1)
   ret i64 %tmp
 }
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll
index 340a3530a5f5b..1a3e36a296232 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll
@@ -1,75 +1,97 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
 
 define i64 @test_sign_ia(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_sign_ia:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacia x0, x1
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_ia:
+; ELF-LABEL:    test_sign_ia:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacia x0, x1
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 0, i64 %arg1)
   ret i64 %tmp
 }
 
 define i64 @test_sign_ia_zero(i64 %arg) {
-; CHECK-LABEL: test_sign_ia_zero:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    paciza x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_ia_zero:
+; ELF-LABEL:    test_sign_ia_zero:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     paciza x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 0, i64 0)
   ret i64 %tmp
 }
 
 define i64 @test_sign_ib(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_sign_ib:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacib x0, x1
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_ib:
+; ELF-LABEL:    test_sign_ib:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacib x0, x1
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 1, i64 %arg1)
   ret i64 %tmp
 }
 
 define i64 @test_sign_ib_zero(i64 %arg) {
-; CHECK-LABEL: test_sign_ib_zero:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacizb x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_ib_zero:
+; ELF-LABEL:    test_sign_ib_zero:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacizb x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 1, i64 0)
   ret i64 %tmp
 }
 
 define i64 @test_sign_da(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_sign_da:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacda x0, x1
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_da:
+; ELF:          test_sign_da:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacda x0, x1
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 2, i64 %arg1)
   ret i64 %tmp
 }
 
 define i64 @test_sign_da_zero(i64 %arg) {
-; CHECK-LABEL: test_sign_da_zero:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacdza x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_da_zero:
+; ELF-LABEL:    test_sign_da_zero:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacdza x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 2, i64 0)
   ret i64 %tmp
 }
 
 define i64 @test_sign_db(i64 %arg, i64 %arg1) {
-; CHECK-LABEL: test_sign_db:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacdb x0, x1
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_db:
+; ELF-LABEL:    test_sign_db:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacdb x0, x1
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 3, i64 %arg1)
   ret i64 %tmp
 }
 
 define i64 @test_sign_db_zero(i64 %arg) {
-; CHECK-LABEL: test_sign_db_zero:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    pacdzb x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_sign_db_zero:
+; ELF-LABEL:    test_sign_db_zero:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     pacdzb x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 3, i64 0)
   ret i64 %tmp
 }
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll
index a99c046a89551..a1319a4496a91 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll
@@ -1,41 +1,53 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
-; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
-
-target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple arm64e-apple-darwin             -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
+; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
+; RUN:   -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
 
 define i64 @test_strip_ia(i64 %arg) {
-; CHECK-LABEL: test_strip_ia:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    xpaci x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_strip_ia:
+; ELF-LABEL:    test_strip_ia:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     xpaci x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 0)
   ret i64 %tmp
 }
 
 define i64 @test_strip_ib(i64 %arg) {
-; CHECK-LABEL: test_strip_ib:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    xpaci x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_strip_ib:
+; ELF-LABEL:    test_strip_ib:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     xpaci x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 1)
   ret i64 %tmp
 }
 
 define i64 @test_strip_da(i64 %arg) {
-; CHECK-LABEL: test_strip_da:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    xpacd x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_strip_da:
+; ELF-LABEL:    test_strip_da:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     xpacd x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 2)
   ret i64 %tmp
 }
 
 define i64 @test_strip_db(i64 %arg) {
-; CHECK-LABEL: test_strip_db:
-; CHECK:       ; %bb.0:
-; CHECK-NEXT:    xpacd x0
-; CHECK-NEXT:    ret
+; DARWIN-LABEL: _test_strip_db:
+; ELF-LABEL:    test_strip_db:
+; DARWIN:       ; %bb.0:
+; ELF:          // %bb.0:
+; CHECK-NEXT:     xpacd x0
+; CHECK-NEXT:     ret
   %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 3)
   ret i64 %tmp
 }


; ptrauth tail-calls can only use x16/x17 with BTI.
;; ptrauth tail-calls can only use x16/x17 with BTI.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this change? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that new tests use a convention: for "special" lines like RUN, CHECK, etc, use ';' prefix, and for "actual comments" - use ';;' prefix. I've not found this in official guidelines, but it's clear from existing tests and I also feel that there were PRs where this was discussed.

If the verb in the question is need, then no, we don't need that, it's just a cosmetic change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the change, see 41facca

Copy link
Collaborator

@asl asl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the set of changes could be reduced by not checking irrelevant platform differences

; CHECK: ; %bb.0:
; CHECK-NEXT: movk x0, #12345, lsl #48
; CHECK-NEXT: ret
; DARWIN-LABEL: _test_blend_constant:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to test the platform differences? Can we use CHECK-LABEL: test_blend_constant and CHECK: %bb.0 on all platforms? Same in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to test the platform differences? Can we use CHECK-LABEL: test_blend_constant and CHECK: %bb.0 on all platforms? Same in other files.

Yes, we can. I'll follow this approach, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got rid of checking platform differences. See 41facca

@kovdan01 kovdan01 requested a review from asl July 9, 2024 08:19
@kovdan01 kovdan01 merged commit 746f572 into llvm:main Jul 9, 2024
5 of 7 checks passed
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
…m#98020)

Many parts of PAuth-related codegen are not MachO- or ELF-specific. Add
RUN lines against ELF targets to ensure that codegen works for ELF as
well as for MachO.
@kovdan01 kovdan01 deleted the pauth-elf-tests branch July 18, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants