Daniele Cono D'Elia edited case-study.tex  over 8 years ago

Commit id: 98fdd857750b9407d28fc7586de1f59141523f5d

deletions | additions      

       

When the IIR compiler processes an annotated \feval\ instruction, it keeps track of the current {\em variable map} between IIR and IR objects, the {\tt llvm::BasicBlock*} created for the \feval\ and the {\tt llvm::Value*} object used as its first argument. The last two elements are then used by the inserter component as basic block and {\tt val} argument in the open-OSR stub that invokes the optimizer component.  \newcommand{\gbase}{$g$} \newcommand{\gBase}{$g$}  \newcommand{\gOpt}{$g_{opt}$}  \newcommand{\gIIR}{$g^{IIR}$}  \newcommand{\gIR}{$g^{IR}$} 

\newcommand{\gOptIR}{$g^{IR}_{opt}$}  \subsection{Generating Optimized Code}  The core of our optimization pipeline is the optimizer module that is responsible for generating optimized code for the current running  function $f$ \gBase\  usingthe run-time value of the first argument for \feval and  contextual information passed from the by an  open-OSR stub. As a first step, the optimizer inspects {\tt val} to resolve the target $f$  of the call - which we call $f$ - \feval\  and check whether a previously compiled optimized function version of \gBase\  is available from thecode  cache. If not, a new function \gOpt\ is generated by cloning the IIR representation \gIIR\ of \gbase\ \gBase\  into \gOptIIR\ and replacing all the \feval\ calls in the same group of the instrumented one with direct calls to $f$. As a next step, the optimizer asks the IIR compiler to analyze \gOptIIR\ and generate optimized LLVM IR \gOptIR, also storing the variable map between IIR and IR objects when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR.  This map is essential for the next step, which is constructing a state mapping between \gIR\ to \gOptIR, as it is compared against the corresponding map stored during the lowering of \gbase\ \gBase\  to determine for each value in \gOptIR\ live at the continuation block whether: \begin{itemize}  \item an {\tt llvm::Value*} from \gIR\ passed as argument at the OSR point can be used directly  \item or, compensation code is required to reconstruct its value before jumping to the block.