1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
; 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
}
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)
|