[llvm] [CodeGen] Fix `MachineModuleInfo`'s move constructor to be more safe with `MCContext` ownership. (PR #104834)

weiwei chen via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 10:47:08 PDT 2024


weiweichen wrote:

> Could you also just change the move constructor to move the MCContext in place without switching to the unique_ptr?

I don't think this is the right solution though. Yes, the MCContext can be moved constructed instead of constructed in `llvm::MachineModuleInfo`'s move constructor. But the `MachineFunction` in `MachineFunctions` are still referencing to the original `MCContext` object (now moved to the new one), that would still have the issue that the now moved `MachineFunction` in `MachineFunctions` are referencing a possible dead `MCContext` depending on the lifetime of the original `llvm::MachineModuleInfo`. Or am I missing something here??

> This isn't big enough to call for an RFC
Not trying to be difficult, but I'm curious what is the criteria for API changing with an RFC. Is there a community guideline about this? Also, regarding the context of `ExternContext`, what would be the best way to find out why it is there at the first place?



https://github.com/llvm/llvm-project/pull/104834


More information about the llvm-commits mailing list