[llvm] 702b3f0 - [ORC] Add a convenience method to create a JITEvaluatedSymbol from a pointer.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 15:18:48 PDT 2020
Author: Lang Hames
Date: 2020-04-18T14:16:54-07:00
New Revision: 702b3f01ddb8bcda86e0a5354b8bfba2e3c586bd
URL: https://github.com/llvm/llvm-project/commit/702b3f01ddb8bcda86e0a5354b8bfba2e3c586bd
DIFF: https://github.com/llvm/llvm-project/commit/702b3f01ddb8bcda86e0a5354b8bfba2e3c586bd.diff
LOG: [ORC] Add a convenience method to create a JITEvaluatedSymbol from a pointer.
This can be used to reduce boilerplate code, especially when defining absolute
symbols.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITSymbol.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITSymbol.h b/llvm/include/llvm/ExecutionEngine/JITSymbol.h
index 976f62306735..6f0030a18f47 100644
--- a/llvm/include/llvm/ExecutionEngine/JITSymbol.h
+++ b/llvm/include/llvm/ExecutionEngine/JITSymbol.h
@@ -237,6 +237,13 @@ class JITEvaluatedSymbol {
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
: Address(Address), Flags(Flags) {}
+ /// Create a symbol from the given pointer with the given flags.
+ template <typename T>
+ static JITEvaluatedSymbol
+ fromPointer(T *P, JITSymbolFlags Flags = JITSymbolFlags::Exported) {
+ return JITEvaluatedSymbol(pointerToJITTargetAddress(P), Flags);
+ }
+
/// An evaluated symbol converts to 'true' if its address is non-zero.
explicit operator bool() const { return Address != 0; }
More information about the llvm-commits
mailing list