<div class="gmail_quote"><div>My name is Isaac. I'm a student at Cal Poly State University, San Luis Obispo, and I'm currently finishing my thesis on target-specific code optimization for my master's degree. I was wondering if I could ask a few questions I have about working with the LLVM codebase.</div>

<div><br></div><div>My thesis involves optimizing the way that LLVM deals with memory operations when targeting the ARM processor (specifically the ARM and Thumb-2 ISAs). Specifically, I'm writing a pass that runs just before the passes in the ARMLoadStoreOptimizer.cpp file. I've already devised an algorithm that I believe will work, and have it mostly implemented in LLVM, but I'm having trouble with some of the details.</div>

<div><br></div><div>Specifically, I'm trying to rearrange the MachineInstrs within each MachineBasicBlock. I've noticed that there are several tutorials in the online documentation about creating LLVM IR transformations, but haven't found any resources beyond the doxygen documentation for MachineInstr level transformations. I have successfully analyzed the MachineInstrs using helper classes that I have implemented, but I need to rearrange the MachineInstrs themselves. When I naively use the MachineBasicBlock.remove() and MachineBasicBlock.push_back() methods, pushing the MachineInstrs back onto the MachineBasicBlock in a different order, LLVM crashes when I attempt to compile a "hello world" style program. Looking at the stderr output I setup for logging purposes, it appears that moving the MachineInstrs in this way does not update certain relevant information, such as when a register is marked to be "killed." </div>

<div><br></div><div>I am continuing to look over the code in the ARMLoadStoreOptimizer.cpp file, but I was wondering if you had a specific suggestion or a documentation resource that I could use to perform this instruction rearrangement in an LLVM idiomatic way. Using my algorithm, I already know where I can move MachineInstrs without effecting program correctness, but I don't know how I can reorder the MachineInstrs while maintaining all the associated live-range information. </div>

<div><br></div><div>Thanks for your time, and I welcome any suggestions you might have for me, </div><div><br></div><div>Regards,</div><div><br></div><font color="#888888"><div>Isaac Asay</div>
</font></div><br>