[LLVMdev] Selection of multiple instructions

Evan Cheng evan.cheng at apple.com
Wed Jul 8 13:50:57 PDT 2009


On Jul 8, 2009, at 10:16 AM, Artjom Kochtchi wrote:

>
> Hi,
>
> I'm currently trying to modify LLVM to include runtime checks into X86
> binaries. I've looked into some of the possibilities during the phases
> happening in LLVM and have the impression that inserting runtime  
> checks
> during selection would be great, since lots of optimizations are  
> already
> done and I can work directly with X86 instructions.
>
> I've read through the documentation for code generation
> (http://www.llvm.org/docs/CodeGenerator.html) and am unsure if I  
> understand
> it correctly, because I have trouble figuring out what actually to  
> do in the
> code to accomplish my aim.
>
> There are the tablegen generated functions and custom C++ code (I  
> guess that
> will be X86DAGToDAGISel::Select(SDValue)) that deal with selection.
>
> The runtime checks I want to add concern indirect jumps. So for  
> example for
> all calls that jump to register values like
>
> call eax
>
> I want to insert a check
>
> ... (some test) ...# perform test
> jne error_label     # jump if test fails
> call eax              # otherwise execute original call
>
> So the check is a sequence of instructions before the call  
> instruction.
>
> Is it possible to do that at the selection level? If yes, could you  
> give a
> simple example or some hint how it would be done? I only find  
> examples where
> exactly one instruction is emitted (and/or returned).

It's not. It requires updating CFG. I'd do this as a separate pass.  
Another possibility is to use the usesCustomDAGSchedInserter hack.  
That is, isel to a pseudo instruction and expand it to a series of  
instructions and update cfg at scheduling time. Look for the  
usesCustomDAGSchedInserter in X86InstrInfo.td and  
EmitInstrWithCustomInserter in X86ISelLowering.cpp.

Evan


>
> Do you think it's the right approach or is there a better place?
>
> I'd really appreciate your help.
> Artjom Kochtchi
> -- 
> View this message in context: http://www.nabble.com/Selection-of-multiple-instructions-tp24395706p24395706.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list