[clang] [PAC] Implement function pointer re-signing (PR #98847)

Anatoly Trosinenko via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 04:12:57 PDT 2024


================
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) {
   return ::getPointerAuthInfoForType(*this, T);
 }
 
+static bool isZeroConstant(llvm::Value *value) {
+  if (auto ci = dyn_cast<llvm::ConstantInt>(value))
+    return ci->isZero();
+  return false;
+}
+
+static bool equalAuthPolicies(const CGPointerAuthInfo &left,
+                              const CGPointerAuthInfo &right) {
+  if (left.isSigned() != right.isSigned())
+    return false;
+  assert(left.isSigned() && right.isSigned() &&
+         "should only be called with non-null auth policies");
----------------
atrosinenko wrote:

Maybe something like "Both pointers should have non-null auth policies" would be better: implying current point in code instead of function call (as from the above check, null auth policies are OK provided they are **both** null). Or maybe this description is correct and the above check is not actually needed (this seems consistent with how this function is called in this PR).

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


More information about the cfe-commits mailing list