Camil Demetrescu edited osr-llvm.tex  over 8 years ago

Commit id: 4fc7f168a4f8df099457450099cd97ad48c2adb5

deletions | additions      

       

\fi  %\subsection{Example}  In this section we discuss a one  possible embodiment of the OSR approach of \mysection\ref{se:overview} in LLVM. Our discussion is based on a simple running example that illustrates a profile-driven optimization scenario. We start from a simple base function ({\tt isord}) that checks whether an array of numbers is ordered according to some criterion specified by a comparator (see \myfigure\ref{fi:isord-example}). Our goal is to instrument {\tt isord} so that, whenever the number of loop iterations exceeds a certain threshold, control is dynamically diverted to a faster version generated on the fly by inlining the comparator. The IR code shown in this section has been generated with \clang\ and instrumented with \osrkit, a library we prototyped to help VM builders implement OSR in LLVM\footnote{Virtual register names and labels in the LLVM-produced IR code shown in this paper have been refactored to make the code more readable.}. \osrkit\ provides a number of useful abstractions that include open and resolved OSR instrumentation of IR base functions without breaking the SSA form, liveness analysis, generation of OSR continuation functions, and mapping of LLVM values between different versions of a program along with compensation code generation\footnote{The accompanying artifact allows the interested reader to get acquainted with \osrkit\ and repeat the sample scenario described in this section.}.