[LLVMdev] Default behavior of DeadMachineInstructionElim deletes all instructions
Villmow, Micah
Micah.Villmow at amd.com
Wed Apr 14 13:55:05 PDT 2010
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:
BitVector NonAllocatableRegs = TRI->getAllocatableSet(MF); (In my case all registers defined in RegisterInfo.td)
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:
TargetRegisterInfo::isPhysicalRegister(reg) ? LivePhysRegs[Reg] : !MRI->use_nodbg_empty(Reg)
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.
So, what I am trying to figure out is why this behavior is occurring? I don't see this happening on the x86 backend because getAllocatableSet does not return all registers as set.
Since I'm working on virtual registers, how do I get MRI->use_nodbg_empty() to return true? Is there something I should be setting in my backend that affects this?
Thanks,
Micah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100414/acb5dfaa/attachment.html>
More information about the llvm-dev
mailing list