[ORC][ORC-RT] Consistently use pointed-to type as template arg to wrap/unwrap.
authorLang Hames <lhames@gmail.com>
Thu, 1 Sep 2022 23:07:38 +0000 (16:07 -0700)
committerLang Hames <lhames@gmail.com>
Fri, 2 Sep 2022 03:54:24 +0000 (20:54 -0700)
Saves wrap/unwrap implementers from having to use std::remove_pointer_t to get
at the pointed-to type.

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

index e541d13..fcdbe5e 100644 (file)
@@ -40,7 +40,7 @@ private:
 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 @@ public:
   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 @@ public:
   }
 
   /// 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);
index cb0c0a4..f6673b1 100644 (file)
@@ -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 @@ public:
 
   /// 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 @@ public:
 
   /// 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 @@ public:
 
   /// 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);