[LLVMdev] How to Find Instruction Encoding for a MachineInstr
craig.topper at gmail.com
Tue Oct 23 17:27:56 PDT 2012
After a quick glance at the generated description files looks like ARM has
correct size information, but X86 always returns 0. ARM is easy because its
On Tue, Oct 23, 2012 at 5:23 PM, John Criswell <criswell at illinois.edu>wrote:
> On 10/23/12 7:19 PM, Craig Topper wrote:
> What function provides the encoding length? X86 in particular is so
> difficult to encode that only the old style JIT and the MC Code Emitter
> could possibly know how many bytes something takes.
> The getSize() method of MCInstrDesc which can be fetched from a
> MachineInstr using the getDesc() method:
> Does this method not work as advertised in Doxygen?
> -- John T.
> On Tue, Oct 23, 2012 at 11:58 AM, John Criswell <criswell at illinois.edu>wrote:
>> Dear All,
>> I'm enhancing a MachineFunctionPass that enforces control-flow integrity.
>> One of the things I want to do is to set the alignment of an instruction
>> (by adding NOPs before it in the MachineBasicBlock or by emitting an
>> alignment directive to the assembler) if it causes a specific sequence of
>> bytes to be generated at a specific alignment. The goal is to ensure that
>> sequences of bytes used to label valid targets of an indirect branch (e.g.,
>> a return instruction) do not appear at a given alignment anywhere in a
>> program other than for where I inserted them explicitly.
>> It looks like MachineInstr has a method for finding the length of the
>> instruction's binary encoding, but I didn't see a method for finding the
>> exact bytes that would be emitted from the MachineInstr. Is there a way to
>> do this in the MachineFunctionPass/MachineInstr infrastructure, or do I
>> need to use something like the MC classes?
>> Thanks in advance for any help provided.
>> -- John T.
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev