Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

240 lines
10 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
define i64 @test_ptrauth_nop(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: ret i64 [[TMP0]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234)
ret i64 %authed
}
declare void @foo()
declare void @bar()
define i64 @test_ptrauth_nop_constant() {
; CHECK-LABEL: @test_ptrauth_nop_constant(
; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64)
;
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 1234)
ret i64 %authed
}
define i64 @test_ptrauth_nop_constant_addrdisc() {
; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc(
; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64)
;
%addr = ptrtoint ptr @foo to i64
%blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended)
ret i64 %authed
}
define i64 @test_ptrauth_nop_mismatch(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_mismatch(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 10)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 10)
ret i64 %authed
}
define i64 @test_ptrauth_nop_mismatch_keys(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_mismatch_keys(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 0, i64 1234)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 0, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234)
ret i64 %authed
}
define i64 @test_ptrauth_sign_resign(ptr %p) {
; CHECK-LABEL: @test_ptrauth_sign_resign(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 0, i64 42)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234)
%authed = call i64 @llvm.ptrauth.resign(i64 %signed, i32 1, i64 1234, i32 0, i64 42)
ret i64 %authed
}
define i64 @test_ptrauth_resign_resign(ptr %p) {
; CHECK-LABEL: @test_ptrauth_resign_resign(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]], i32 1, i64 1234, i32 1, i64 3141)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 42)
%authed = call i64 @llvm.ptrauth.resign(i64 %signed, i32 0, i64 42, i32 1, i64 3141)
ret i64 %authed
}
define i64 @test_ptrauth_resign_auth(ptr %p) {
; CHECK-LABEL: @test_ptrauth_resign_auth(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]], i32 1, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 42)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 0, i64 42)
ret i64 %authed
}
define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) {
; CHECK-LABEL: @test_ptrauth_resign_auth_mismatch(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]], i32 1, i64 1234, i32 0, i64 10)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 0, i64 42)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 10)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 0, i64 42)
ret i64 %authed
}
define i64 @test_ptrauth_nop_constant_mismatch() {
; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch(
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 12)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 12)
ret i64 %authed
}
define i64 @test_ptrauth_nop_constant_mismatch_key() {
; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch_key(
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 0, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 0, i64 1234)
ret i64 %authed
}
define i64 @test_ptrauth_nop_constant_addrdisc_mismatch() {
; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch(
; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @foo to i64), i64 12)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]])
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%addr = ptrtoint ptr @foo to i64
%blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 12)
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended)
ret i64 %authed
}
define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2() {
; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2(
; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @bar to i64), i64 1234)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]])
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%addr = ptrtoint ptr @bar to i64
%blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended)
ret i64 %authed
}
define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) {
; CHECK-LABEL: @test_ptrauth_resign_ptrauth_constant(
; CHECK-NEXT: ret i64 ptrtoint (ptr ptrauth (ptr @foo, i32 0, i64 42) to i64)
;
%tmp0 = ptrtoint ptr %p to i64
%authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 1234, i32 0, i64 42)
ret i64 %authed
}
@ds = external global i8
@ds2 = external global i8
define i64 @test_ptrauth_nop_ds1(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_ds1(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234)
ret i64 %authed
}
define i64 @test_ptrauth_nop_ds2(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_ds2(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234)
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234)
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
ret i64 %authed
}
define i64 @test_ptrauth_nop_ds3(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_ds3(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds2) ]
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds2) ]
ret i64 %authed
}
define i64 @test_ptrauth_nop_ds4(ptr %p) {
; CHECK-LABEL: @test_ptrauth_nop_ds4(
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: ret i64 [[TMP0]]
;
%tmp0 = ptrtoint ptr %p to i64
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
ret i64 %authed
}
define i64 @test_ptrauth_nop_ds_constant() {
; CHECK-LABEL: @test_ptrauth_nop_ds_constant(
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64), i32 1, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64), i32 1, i64 1234)
ret i64 %authed
}
define i64 @test_ptrauth_auth_call_no_args() {
; CHECK-LABEL: @test_ptrauth_auth_call_no_args(
; CHECK-NEXT: [[CALL:%.*]] = call i64 @foo()
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CALL]], i32 1, i64 1234)
; CHECK-NEXT: ret i64 [[AUTHED]]
;
%call = call i64 @foo()
%authed = call i64 @llvm.ptrauth.auth(i64 %call, i32 1, i64 1234)
ret i64 %authed
}
declare i64 @llvm.ptrauth.auth(i64, i32, i64)
declare i64 @llvm.ptrauth.sign(i64, i32, i64)
declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64)
declare i64 @llvm.ptrauth.blend(i64, i64)