Skip to content

Commit da93f4b

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 5d96964 commit da93f4b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,6 +3052,11 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
30523052
}
30533053
case Intrinsic::ptrauth_auth:
30543054
case Intrinsic::ptrauth_resign: {
3055+
// We don't support this optimization on intrinsic calls with deactivation
3056+
// symbols, which are represented using operand bundles.
3057+
if (II->hasOperandBundles())
3058+
break;
3059+
30553060
// (sign|resign) + (auth|resign) can be folded by omitting the middle
30563061
// sign+auth component if the key and discriminator match.
30573062
bool NeedSign = II->getIntrinsicID() == Intrinsic::ptrauth_resign;
@@ -3063,6 +3068,11 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
30633068
// whatever we replace this sequence with.
30643069
Value *AuthKey = nullptr, *AuthDisc = nullptr, *BasePtr;
30653070
if (const auto *CI = dyn_cast<CallBase>(Ptr)) {
3071+
// We don't support this optimization on intrinsic calls with deactivation
3072+
// symbols, which are represented using operand bundles.
3073+
if (CI->hasOperandBundles())
3074+
break;
3075+
30663076
BasePtr = CI->getArgOperand(0);
30673077
if (CI->getIntrinsicID() == Intrinsic::ptrauth_sign) {
30683078
if (CI->getArgOperand(1) != Key || CI->getArgOperand(2) != Disc)

llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,34 @@ define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) {
160160
ret i64 %authed
161161
}
162162

163+
@ds = external global i8
164+
165+
define i64 @test_ptrauth_nop_ds1(ptr %p) {
166+
; CHECK-LABEL: @test_ptrauth_nop_ds1(
167+
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
168+
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
169+
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234)
170+
; CHECK-NEXT: ret i64 [[AUTHED]]
171+
;
172+
%tmp0 = ptrtoint ptr %p to i64
173+
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
174+
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234)
175+
ret i64 %authed
176+
}
177+
178+
define i64 @test_ptrauth_nop_ds2(ptr %p) {
179+
; CHECK-LABEL: @test_ptrauth_nop_ds2(
180+
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
181+
; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234)
182+
; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
183+
; CHECK-NEXT: ret i64 [[AUTHED]]
184+
;
185+
%tmp0 = ptrtoint ptr %p to i64
186+
%signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234)
187+
%authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ]
188+
ret i64 %authed
189+
}
190+
163191
declare i64 @llvm.ptrauth.auth(i64, i32, i64)
164192
declare i64 @llvm.ptrauth.sign(i64, i32, i64)
165193
declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64)

0 commit comments

Comments
 (0)