@@ -2081,28 +2081,33 @@ Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) {
20812081//
20822082
20832083ConstantPtrAuth *ConstantPtrAuth::get (Constant *Ptr, ConstantInt *Key,
2084- ConstantInt *Disc, Constant *AddrDisc) {
2085- Constant *ArgVec[] = {Ptr, Key, Disc, AddrDisc};
2084+ ConstantInt *Disc, Constant *AddrDisc,
2085+ Constant *DeactivationSymbol) {
2086+ Constant *ArgVec[] = {Ptr, Key, Disc, AddrDisc, DeactivationSymbol};
20862087 ConstantPtrAuthKeyType MapKey (ArgVec);
20872088 LLVMContextImpl *pImpl = Ptr->getContext ().pImpl ;
20882089 return pImpl->ConstantPtrAuths .getOrCreate (Ptr->getType (), MapKey);
20892090}
20902091
20912092ConstantPtrAuth *ConstantPtrAuth::getWithSameSchema (Constant *Pointer) const {
2092- return get (Pointer, getKey (), getDiscriminator (), getAddrDiscriminator ());
2093+ return get (Pointer, getKey (), getDiscriminator (), getAddrDiscriminator (),
2094+ getDeactivationSymbol ());
20932095}
20942096
20952097ConstantPtrAuth::ConstantPtrAuth (Constant *Ptr, ConstantInt *Key,
2096- ConstantInt *Disc, Constant *AddrDisc)
2098+ ConstantInt *Disc, Constant *AddrDisc,
2099+ Constant *DeactivationSymbol)
20972100 : Constant(Ptr->getType (), Value::ConstantPtrAuthVal, AllocMarker) {
20982101 assert (Ptr->getType ()->isPointerTy ());
20992102 assert (Key->getBitWidth () == 32 );
21002103 assert (Disc->getBitWidth () == 64 );
21012104 assert (AddrDisc->getType ()->isPointerTy ());
2105+ assert (DeactivationSymbol->getType ()->isPointerTy ());
21022106 setOperand (0 , Ptr);
21032107 setOperand (1 , Key);
21042108 setOperand (2 , Disc);
21052109 setOperand (3 , AddrDisc);
2110+ setOperand (4 , DeactivationSymbol);
21062111}
21072112
21082113// / Remove the constant from the constant table.
@@ -2150,6 +2155,11 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const {
21502155bool ConstantPtrAuth::isKnownCompatibleWith (const Value *Key,
21512156 const Value *Discriminator,
21522157 const DataLayout &DL) const {
2158+ // This function may only be validly called to analyze a ptrauth operation
2159+ // with no deactivation symbol, so if we have one it isn't compatible.
2160+ if (!getDeactivationSymbol ()->isNullValue ())
2161+ return false ;
2162+
21532163 // If the keys are different, there's no chance for this to be compatible.
21542164 if (getKey () != Key)
21552165 return false ;
0 commit comments