<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear dev-list,</div><div><br></div><div>I currently have a X86 machineFunctionPass and realized there are more corner cases than I realized. I need to keep my custom jump transformations aligned and therefore would like to fill the rest of the space with NOOPs.<br></div><div><br></div><div>I understand that hexcode code ASM is emitted/encoded by the ASMPrinter. In the past I have gotten the size via 2 compilations (1 to collect asm size data, 2nd to perform fixup alignment where needed), but am looking for a cleaner self contained solution.</div><div><br></div><div>In the past I used this code, creating a function in X86AsmPrinter class<br></div><div>unsigned int instSize;<br>SmallString<256> Code;<br>SmallVector<MCFixup, 4> Fixups; <br>raw_svector_ostream VecOS(Code); <br>CodeEmitter->encodeInstruction(Inst, VecOS, Fixups, STI);<br>instSize = Code.size();<br><br></div><div></div><div>So far, I have already tried to get the size of the opcode at least via:</div><div>size= MachineInstr->getDesc().getSize();<br></div><div>but it returns zero, indicating that the encoding size cannot be determined yet according to the LLVM doxygen, but why? We are already know our target ISA is X86 and if I do a dump of the MachineInstr, the opcodes and operands/registers seem already finalized....<br></div><div><br></div><div>So the questions are:</div><div>1) Is it possible to temporarily encode a given MachineInstr to a temporary buffer in a machineFunctionPass?? If so, how?<br></div><div></div><div>2) Is it possible to create an instance of CodeEmitter within a machineFunctionPass to make it possible to run the above code? If so, how?</div><div><br></div><div>Thanks in advance.</div><div>Sincerely,</div><div><br></div><div>K Jelesnianski<br></div></div></div></div>