Set value_regs and invalidate_regs in RegisterInfo pushed onto m_regs
to nullptr, to ensure that the temporaries passed there are not
accidentally used.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Now, a fun fact: ProcessGDBRemote has already been passing temporaries. We probably didn't notice it's broken simply because lldb-server didn't send value_regs.
So, does this fix like an existing test or something? Maybe you could write a unit test for it?
Ok, I see now that I was wrong. DynamicRegisterInfo::Finalize() already does that. I've finally managed to figure out what this scary code does ;-).
FWIW, I think that doing this stuff immediately is a actually good idea. It avoids having a time window where info->value_regs is a dangling pointer, and it doesn't save us any work, since this is something we have to do anyway...
(Though, if we're going to be modifying/expanding these lists in subsequent AddRegister calls, then maybe it does not make that much sense...)
As I alluded to in the second comment, I'm not sure this is really that much helpful, since it's also nice to have all invalidate_regs handling happen in a single function. Maybe AddRegister should just set this field to null (to give a more predictable behavior (crash) if anyone accesses it), and have a comment saying that it will be filled in in Finalize ?