[PATCH] D63378: [ORC] WIP Speculative compilation

Praveen velliengiri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 21:08:38 PDT 2019


pree-jackie marked 2 inline comments as done.
pree-jackie added inline comments.


================
Comment at: llvm/lib/ExecutionEngine/Orc/Speculation.cpp:56
+
+  // reinterpret_cast of Stub Address to i64
+  auto RTFTy = FunctionType::get(Type::getVoidTy(InContext),
----------------
lhames wrote:
> What line is this comment in reference to?
Converting the function definition address to the unsigned int of 64 bits. Which are used as the key in Speculator to lookup likely functions. 


================
Comment at: llvm/lib/ExecutionEngine/Orc/Speculation.cpp:90
+            auto RAddr = (*ResSymMap)[Target].getAddress();
+            SpecMap.registerSymbolsWithAddr(std::move(RAddr), likely);
+          } else {
----------------
lhames wrote:
> If I have understood your patch correctly, you could test Dave Blaikie's proof-of-concept speculation idea by issuing a call to:
> 
>   SpecMap.speculateFor(RAddr);
> 
> You would need to remove the std::move from RAddr on the previous line. JITTargetAddresses are cheap to copy so that's fine to get rid of.
> 
> To test that this is really working you could compile a test module:
> 
>   void a() {}
>   void b() {}
> 
>   int main(int argc, char *argv[]) {
>     if (argc > 2)
>       a();
>     else
>       b();
>     return 0;
>   }
> 
> If your simple speculator is working you should see modules for both a() and b() pass through your speculation layer when main is called, even though only one will ever be executed.
Not exactly, registering the symbols with speculator doesn't mean in any way that the Impl Symbols are recorded in the Imap. To replicate the lazyreexports symbol mapping we use the same technique as earlier. 

Triggering a call at run time is easy, because we can guarantee that when we call the function, all the external references by the function are already stub materialized. So when we call the function at run time  through __orc_speculate_for, Imap has the Impl Symbols.

But triggering speculative compiles without the run time function, requires 2 look ups 
1 )  Lookup likely Symbols to Stub Materialize and handover the remaining to the linking layer.
2 )  Lookup based on the Imap Entries of the likely functions for speculative compiles.

I have done it, it is working and I have to write tests. 

Actually, it work along with the same sequence of actions that ORC v2 do.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63378/new/

https://reviews.llvm.org/D63378





More information about the llvm-commits mailing list