[llvm] A MMIWP Constructor Initialized with the move constructor of MMI (PR #98770)

Matin Raayai via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 08:47:55 PDT 2024


matinraayai wrote:

@arsenm On further inspection, I think the move constructor of MMI is not correct and should be removed all together:
https://github.com/llvm/llvm-project/blob/8ba9ed682552261d089ceb4bc9895d5f9fd0c888/llvm/lib/CodeGen/MachineModuleInfo.cpp#L57-L67

Yes, the machine function map gets moved; but each machine function holds an internal reference to the original MMI and its context, and moving them makes those references stale.

At this point I think the only way to prevent an MMI from going out of scope is hold on to an MMIWP and the PMs that control its lifetime. 

I could in theory refactor MMIWP to either:
1. Only support an external MMI (same as `MachineModuleAnalysis`), which requires a good amount of refactoring work.
2. Support both internal and external MMI (see MMI's `MCContext` itself)

Given that the CodeGen pipeline is being ported to the new pass manager, and the `MachineModuleAnalysis` only supports an external MMI, I'm not sure if this contribution will be accepted upstream.

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


More information about the llvm-commits mailing list