[llvm] ce51cae - [PtrAuth] Use default attributes for some ptrauth intrinsics

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 01:41:36 PST 2022


Author: Nikita Popov
Date: 2022-12-09T10:41:28+01:00
New Revision: ce51cae7947e9e30320ac02e48ea954152309f6d

URL: https://github.com/llvm/llvm-project/commit/ce51cae7947e9e30320ac02e48ea954152309f6d
DIFF: https://github.com/llvm/llvm-project/commit/ce51cae7947e9e30320ac02e48ea954152309f6d.diff

LOG: [PtrAuth] Use default attributes for some ptrauth intrinsics

This uses the default intrinsic attributes (nofree, nosync,
nocallback, willreturn) for a subset of the ptrauth intrinsics.
Notably, this does not use them for auth and resign, because these
intrinsics are specified to trap and as such are not willreturn.
As far as I understood, the remaining intrinsics may not trap
(or can only trap in cases where behavior is undefined).

Differential Revision: https://reviews.llvm.org/D137557

Added: 
    

Modified: 
    llvm/include/llvm/IR/Intrinsics.td
    llvm/lib/Transforms/Utils/Local.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 1d1447cb385b5..3a27a2a22fd68 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -2097,9 +2097,9 @@ def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
 // Sign an unauthenticated pointer using the specified key and discriminator,
 // passed in that order.
 // Returns the first argument, with some known bits replaced with a signature.
-def int_ptrauth_sign : Intrinsic<[llvm_i64_ty],
-                                 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
-                                 [IntrNoMem, ImmArg<ArgIndex<1>>]>;
+def int_ptrauth_sign :
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
+                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
 
 // Authenticate a signed pointer, using the specified key and discriminator.
 // Returns the first argument, with the signature bits removed.
@@ -2125,15 +2125,14 @@ def int_ptrauth_resign : Intrinsic<[llvm_i64_ty],
 // The second argument specifies the key.
 // This behaves like @llvm.ptrauth.auth, but doesn't require the signature to
 // be valid.
-def int_ptrauth_strip : Intrinsic<[llvm_i64_ty],
-                                  [llvm_i64_ty, llvm_i32_ty],
-                                  [IntrNoMem, ImmArg<ArgIndex<1>>]>;
+def int_ptrauth_strip :
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty],
+                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
 
 // Blend a small integer discriminator with an address discriminator, producing
 // a new discriminator value.
-def int_ptrauth_blend : Intrinsic<[llvm_i64_ty],
-                                  [llvm_i64_ty, llvm_i64_ty],
-                                  [IntrNoMem]>;
+def int_ptrauth_blend :
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
 
 // Compute the signature of a value, using a given discriminator.
 // This 
diff ers from @llvm.ptrauth.sign in that it doesn't embed the computed
@@ -2141,9 +2140,8 @@ def int_ptrauth_blend : Intrinsic<[llvm_i64_ty],
 // That allows it to be used to sign non-pointer data: in that sense, it is
 // generic.  There is no generic @llvm.ptrauth.auth: instead, the signature
 // can be computed using @llvm.ptrauth.sign_generic, and compared with icmp.
-def int_ptrauth_sign_generic : Intrinsic<[llvm_i64_ty],
-                                         [llvm_i64_ty, llvm_i64_ty],
-                                         [IntrNoMem]>;
+def int_ptrauth_sign_generic :
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
 
 //===----------------------------------------------------------------------===//
 

diff  --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index e022a6f50c07a..af75fe11ad452 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -456,7 +456,6 @@ bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
     case Intrinsic::wasm_trunc_unsigned:
     case Intrinsic::ptrauth_auth:
     case Intrinsic::ptrauth_resign:
-    case Intrinsic::ptrauth_sign:
       return true;
     default:
       return false;


        


More information about the llvm-commits mailing list