Skip to content
5 changes: 5 additions & 0 deletions llvm/lib/IR/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,11 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const {
bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key,
const Value *Discriminator,
const DataLayout &DL) const {
// This function may only be validly called to analyze a ptrauth operation with
// no deactivation symbol, so if we have one it isn't compatible.
if (!getDeactivationSymbol()->isNullValue())
return false;

// If the keys are different, there's no chance for this to be compatible.
if (getKey() != Key)
return false;
Expand Down
9 changes: 9 additions & 0 deletions llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ define i64 @test_ptrauth_nop_ds2(ptr %p) {
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
}

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)
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.