[llvm] 6ca9f42 - [ORC][ORC-RT] Consistently use pointed-to type as template arg to wrap/unwrap.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 20:54:36 PDT 2022


Author: Lang Hames
Date: 2022-09-01T20:54:24-07:00
New Revision: 6ca9f42189b668940e87f76eec5d92d00fe331f8

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

LOG: [ORC][ORC-RT] Consistently use pointed-to type as template arg to wrap/unwrap.

Saves wrap/unwrap implementers from having to use std::remove_pointer_t to get
at the pointed-to type.

Added: 
    

Modified: 
    compiler-rt/lib/orc/executor_address.h
    llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/orc/executor_address.h b/compiler-rt/lib/orc/executor_address.h
index e541d13627bb1..fcdbe5e1edda4 100644
--- a/compiler-rt/lib/orc/executor_address.h
+++ b/compiler-rt/lib/orc/executor_address.h
@@ -40,7 +40,7 @@ class ExecutorAddrDiff {
 class ExecutorAddr {
 public:
   /// A wrap/unwrap function that leaves pointers unmodified.
-  template <typename T> using rawPtr = __orc_rt::identity<T>;
+  template <typename T> using rawPtr = __orc_rt::identity<T *>;
 
   /// Default wrap function to use on this host.
   template <typename T> using defaultWrap = rawPtr<T>;
@@ -82,14 +82,14 @@ class ExecutorAddr {
   explicit ExecutorAddr(uint64_t Addr) : Addr(Addr) {}
 
   /// Create an ExecutorAddr from the given pointer.
-  template <typename T, typename UnwrapFn = defaultUnwrap<T *>>
+  template <typename T, typename UnwrapFn = defaultUnwrap<T>>
   static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap = UnwrapFn()) {
     return ExecutorAddr(
         static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Unwrap(Ptr))));
   }
 
   /// Cast this ExecutorAddr to a pointer of the given type.
-  template <typename T, typename WrapFn = defaultWrap<T>>
+  template <typename T, typename WrapFn = defaultWrap<std::remove_pointer_t<T>>>
   std::enable_if_t<std::is_pointer<T>::value, T>
   toPtr(WrapFn &&Wrap = WrapFn()) const {
     uintptr_t IntPtr = static_cast<uintptr_t>(Addr);
@@ -98,7 +98,7 @@ class ExecutorAddr {
   }
 
   /// Cast this ExecutorAddr to a pointer of the given function type.
-  template <typename T, typename WrapFn = defaultWrap<T *>>
+  template <typename T, typename WrapFn = defaultWrap<T>>
   std::enable_if_t<std::is_function<T>::value, T *>
   toPtr(WrapFn &&Wrap = WrapFn()) const {
     uintptr_t IntPtr = static_cast<uintptr_t>(Addr);

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
index cb0c0a4d81399..f6673b18cb5aa 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
@@ -31,7 +31,7 @@ using ExecutorAddrDiff = uint64_t;
 class ExecutorAddr {
 public:
   /// A wrap/unwrap function that leaves pointers unmodified.
-  template <typename T> using rawPtr = llvm::identity<T>;
+  template <typename T> using rawPtr = llvm::identity<T *>;
 
   /// Default wrap function to use on this host.
   template <typename T> using defaultWrap = rawPtr<T>;
@@ -76,7 +76,7 @@ class ExecutorAddr {
 
   /// Create an ExecutorAddr from the given pointer.
   /// Warning: This should only be used when JITing in-process.
-  template <typename T, typename UnwrapFn = defaultUnwrap<T *>>
+  template <typename T, typename UnwrapFn = defaultUnwrap<T>>
   static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap = UnwrapFn()) {
     return ExecutorAddr(
         static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Unwrap(Ptr))));
@@ -84,7 +84,7 @@ class ExecutorAddr {
 
   /// Cast this ExecutorAddr to a pointer of the given type.
   /// Warning: This should only be used when JITing in-process.
-  template <typename T, typename WrapFn = defaultWrap<T>>
+  template <typename T, typename WrapFn = defaultWrap<std::remove_pointer_t<T>>>
   std::enable_if_t<std::is_pointer<T>::value, T>
   toPtr(WrapFn &&Wrap = WrapFn()) const {
     uintptr_t IntPtr = static_cast<uintptr_t>(Addr);
@@ -94,7 +94,7 @@ class ExecutorAddr {
 
   /// Cast this ExecutorAddr to a pointer of the given function type.
   /// Warning: This should only be used when JITing in-process.
-  template <typename T, typename WrapFn = defaultWrap<T *>>
+  template <typename T, typename WrapFn = defaultWrap<T>>
   std::enable_if_t<std::is_function<T>::value, T *>
   toPtr(WrapFn &&Wrap = WrapFn()) const {
     uintptr_t IntPtr = static_cast<uintptr_t>(Addr);


        


More information about the llvm-commits mailing list