<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 14, 2010, at 1:55 PMPDT, Villmow, Micah wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple">
<div class="Section1"><p class="MsoNormal">I’ve recently sync’d to a newer version of LLVM(Apple
branch 2326 from Apple branch 2323.8) that changed the interface to
addCommonCodeGenPasses which caused the default implementation to be executed
instead of my overriding implementation. This default implementation has DeadMachineInstructionElim
pass enabled, which is causing havoc with my backend. Before entering this
pass, everything in my machine function is fine, after this pass, all
instructions that are not function calls are deleted. I’ve tracked this
issue down to the line:<o:p></o:p></p><p class="MsoNormal">BitVector NonAllocatableRegs = TRI->getAllocatableSet(MF);
(In my case all registers defined in RegisterInfo.td)</p><p class="MsoNormal">This function loops through all registers classes and sets
all registers in the bitset that are allocatable. It then inverts the registers
that are set to get the NonAllocatable registers and assigns that to the
LivePhysRegs for each basic block in a function. The function then loops
through all instructions in a basic block and checks to see if it is a dead
instruction. The check is whether it is a physical register or not with
the check:<o:p></o:p></p><p class="MsoNormal">TargetRegisterInfo::isPhysicalRegister(reg) ?
LivePhysRegs[Reg] : !MRI->use_nodbg_empty(Reg) </p><p class="MsoNormal">If the register is virtual, then MRI->use_nodbg_empty()
returns false, if the register is physical LivePhysRegs[Reg] returns false,
since the bitvector was inverted. So my instruction is considered dead and
deleted.</p></div></div></blockquote><div lang="EN-US" link="blue" vlink="purple"><div class="Section1"><p class="MsoNormal"><div>Huh? The code is</div></p></div></div></div><div><div> if (TargetRegisterInfo::isPhysicalRegister(Reg) ?</div><div> LivePhysRegs[Reg] : !MRI->use_nodbg_empty(Reg)) {</div><div> // This def has a non-debug use. Don't delete the instruction!</div><div> return false;</div><div><br></div><div>Returning false from MRI->use_nodbg_empty means the instruction has a use, and it is not deleted. That's what's supposed to happen.</div></div><br></body></html>