Re-optimization using JITLink

Description of the project: In Just-In-Time compilers we often choose a low optimization level to minimize compile time and improve launch times and latencies, however some functions (which we call hot functions) are used very frequently and for these functions it is worth optimizing more heavily. In general hot functions can only be identified at runtime (different inputs will cause different functions to become hot), so the aim of the reoptimization project is to build infrastructure to (1) detect hot functions at runtime and (2) compile them a second time at a higher optimization level, hence the name "re-optimization".

There are many possible approaches to both parts of this problem. E.g. hot functions could be identified by sampling, or using existing profiling infrastructure, or by implementing custom instrumentation. Reoptimization could be applied to whole functions, or outlining could be used to enable optimization of portions of functions. Re-entry into the JIT infrastructure from JIT’d code might be implemented on top of existing lazy compilation, or via a custom path.

Whatever design is adopted, the goal is that the infrastructure should be generic so that it can be used by other LLVM API clients, and should support out-of-process JIT-compilation (so some of the solution will be implemented in the ORC runtime).

Expected result:

  • Improve ergonomics of indirection – ideally all forms of indirection (for re-optimization, lazy compilation, and procedure-linkage-tables) should be able to share a single stub (and/or binary rewriting metadata) at runtime.
  • Implement basic re-optimization on top of the tidied up indirection.
  • (Stretch goal) Garbage-collect unoptimized code that is no longer needed once the optimized version is available.

Desirable skills: Intermediate C++; Understanding of LLVM and the LLVM JIT in particular.

Project size: Large.

Difficulty: Medium

Confirmed Mentor: Vassil Vassilev, Lang Hames

1 Like


I have a question about “Project size: Large.”
How long do you expect us to dedicate to this project, and from when to when? Because some of us are studying abroad and VISA may not allow us to work for more than specific hours.


I found a blog post about it! So, in our case, do we not necessarily need to finish the project in 12 weeks or work unpaid when the working hours exceed? Do you have any chance to make the plan flexible? (I am asking the college administration what hours I can work during the summer break simultaneously.)

Time management for contributors | Google Summer of Code Guides

GSoC needs an investment of about 175 hours for medium size projects and 350 hours for large projects.

Hi @diohabara,

Large means 350 hours as you correctly pointed out.

GSoC is quite flexible in that respect and we can organize the time according to your schedule. You can probably frontload a lot of the work. In terms of, VISA and payment schedule, there is no difference between both project kinds. I know some cases where the GSoC admins have allowed earlier payments due to the US student VISAs.

It is very much dependent on the particular case.

Hi @vvassilev,

Thank you for your quick response. I’m glad you clarified the question.

I have another question about the application.
We are allowed to submit no more than three applications per summer, according to the official Q&A site.

Yes, each GSoC Contributor may submit up to three proposals. However, only one per GSoC Contributor may be accepted. No more than one proposal per GSoC Contributor will be accepted, no matter how many proposals you submit.

I am interested in this and your other project, which is also related to JITLink. I would like to have a correction made before I submit it. Is that possible? In that case, would it be a burden to make two corrections, and should I focus on only one before revising my application?

Thank you for your time.

You can make modifications to your proposal anytime before the deadline (or clicking on the submit button depending on the current features of their submission system). Generally you are advised to solicit the proposal with your mentors before submitting to increase your chances.

Note that currently the GSoC program is in very early stages and they are currently in process of approving the organization. Once the organizations are approved we can start the process as for each organization that applies there is a non-zero chance to not be approved.

1 Like

Thank you for your advice & warnings.
I will keep that possibility in mind as I draft the proposal.

I am Rushabh Shah, a third year computer science student from BITS Pilani Goa and I’m interested in working on this project.
I have gone through LLVM documentation and made a basic compiler with help from the getting started guide, I’ve built LLVM and am currently going through the documentation for LLVM JIT.
I was wondering if there are any patches or issues I could work on related to JIT or JITLink to get a better understanding on this project and contributing to LLVM. I’ve gone through the Issues pages on GitHub but couldn’t find a good place to start for JIT.
Thank you for your time :blush:

Hi @rushabh101,

Thanks for reaching out. I’d propose to go through the examples in the Kaleidoscope tutorials. There you can grasp many of the JIT concepts.

Generally going through the bugtracker and scanning for “good first issue” label is a good start.

On the JIT/JITLink side @lhames might be able to help.

Best, Vassil

Hey @vvassilev and all,

I’m a 3rd year undergrad in computer science and math (mostly interested in computational math and integrable probability, not that this is especially relevant). Looking at GSoC for this summer and have been hoping to learn more about compilers – having messed with LLVM for curiosity/ some personal projects after my compilers course and being a fan of a couple projects built on LLVM JIT, I felt this would be a great outlet + learn more about JIT and optimizations/ non-classroom experience, as I’ve found these opportunities to be few and thin. Have had some past experience putting together some nontrivial projects of my own (had a nice “extended” Kaleidoscope with the Haskell bindings a while back, but have now learned why people dislike stack in addition to that API being mostly abandoned :frowning: have since gotten it halfway working with the official C++ API).

Definitely best to reach me by my school email, which I also already have a Slack with (the primary on my github is an old personal); would love to learn more about the project regardless of outcomes –


Hi @mjachi, apologies for the delay, I have been swamped recently. This project is assumes some hands on experience in the area as it is non-trivial. If you send me your CV (in private) I might be able to suggest something that would be a better project to enter the LLVM/JIT realm.