[PATCH] D150458: [ORC] Use ExecutorAddr::toPtr() in documentation

Mike Rostecki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 09:55:41 PDT 2023


vadorovsky created this revision.
Herald added a project: All.
vadorovsky requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Partial move from JITTargetAddress to ExecutorAddr was done in 8b1771bd9f30 <https://reviews.llvm.org/rG8b1771bd9f304be39d4dcbdcccedb6d3bcd18200>,
but that change missed the ORC and Kaleidoscope documents which led to
their inconsistency.

Fixes #62411


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150458

Files:
  llvm/docs/ORCv2.rst
  llvm/docs/tutorial/BuildingAJIT1.rst
  llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst


Index: llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst
===================================================================
--- llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst
+++ llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst
@@ -317,7 +317,7 @@
 
           // Get the symbol's address and cast it to the right type (takes no
           // arguments, returns a double) so we can call it as a native function.
-          double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+          double (*FP)() = ExprSymbol.getAddress().toPtr<double (*)()>();
           fprintf(stderr, "Evaluated to %f\n", FP());
 
           // Delete the anonymous expression module from the JIT.
Index: llvm/docs/tutorial/BuildingAJIT1.rst
===================================================================
--- llvm/docs/tutorial/BuildingAJIT1.rst
+++ llvm/docs/tutorial/BuildingAJIT1.rst
@@ -77,7 +77,7 @@
 
   JIT J;
   J.addModule(buildModule());
-  auto *Main = (int(*)(int, char*[]))J.lookup("main").getAddress();
+  auto *Main = J.lookup("main").getAddress().toPtr<int(*)(int, char *[])>();
   int Result = Main();
 
 The APIs that we build in these tutorials will all be variations on this simple
Index: llvm/docs/ORCv2.rst
===================================================================
--- llvm/docs/ORCv2.rst
+++ llvm/docs/ORCv2.rst
@@ -124,7 +124,7 @@
     return EntrySym.takeError();
 
   // Cast the entry point address to a function pointer.
-  auto *Entry = (void(*)())EntrySym.getAddress();
+  auto *Entry = EntrySym.getAddress().toPtr<void(*)()>();
 
   // Call into JIT'd code.
   Entry();
@@ -204,7 +204,7 @@
 
   // Look up the JIT'd main, cast it to a function pointer, then call it.
   auto MainSym = ExitOnErr(ES.lookup({&MainJD}, "main"));
-  auto *Main = (int(*)(int, char*[]))MainSym.getAddress();
+  auto *Main = MainSym.getAddress().toPtr<int(*)(int, char *[])>();
 
   int Result = Main(...);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150458.521697.patch
Type: text/x-patch
Size: 1951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/6f67dcac/attachment.bin>


More information about the llvm-commits mailing list