[llvm] [PAC][IR][AArch64] Add "ptrauth(...)" Constant to represent signed pointers. (PR #85738)

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 17:22:10 PDT 2024


================
@@ -2015,6 +2018,113 @@ Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) {
   return nullptr;
 }
 
+//---- ConstantPtrAuth::get() implementations.
+//
+
+static bool areEquivalentAddrDiscriminators(const Value *V1, const Value *V2,
+                                            const DataLayout &DL) {
+  APInt Off1(DL.getTypeSizeInBits(V1->getType()), 0);
+  APInt Off2(DL.getTypeSizeInBits(V2->getType()), 0);
+
+  if (auto *V1Cast = dyn_cast<PtrToIntOperator>(V1))
----------------
ahmedbougacha wrote:

That's a good observation, it's really only one side that we'd expect to be a (ptrtoint of a) blend.  I rewrote the function to hopefully be more explicit about what it's actually checking.

For some context for the ptrauth crowd, an interesting user is comparing a call bundle with a constant target, and the bundles only have a single `discriminator` operand.  I spent some time looking into splitting up the discriminator there, but I don't think it's worth it right now, and isn't all that useful without doing the same split throughout the intrinsics as well.

But back to the patch: I also renamed this `isKnownCompatibleWith` because the old name was misleading.

https://github.com/llvm/llvm-project/pull/85738


More information about the llvm-commits mailing list