Camil Demetrescu  over 8 years ago

Commit id: feee8b31ca10131f4ccd1f9fc9ebdec25e14a0fa

deletions | additions      

       

\label{fig:isordx86-64} OSR-instrumented functions {\tt isordfrom} (base) and {\tt isordto} (faster continuation) after IR to x86-64 lowering in LLVM. For %For  the sake of comparison with the native code that would be generated for the original non-OSR versions, additions Additions  resulting from the IR instrumentation are in grey, while removals are struck-through.        

\fi  %\subsection{Example}  In this section we discuss how to implement the OSR approach of \mysection\ref{se:overview} in LLVM. Our discussion is based on a simple 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, as shown in \myfigure\ref{fi:isord-example}. comparator (see \myfigure\ref{fi:isord-example}).  Our goal is to instrument {\tt isort} isord}  so that, whenever the number of loop  iterationsof {\tt isord}  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.}.