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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 08:53:48 PDT 2024


================
@@ -124,10 +124,10 @@ class MachineModuleInfo {
   const LLVMTargetMachine &getTarget() const { return TM; }
 
   const MCContext &getContext() const {
-    return ExternalContext ? *ExternalContext : Context;
+    return ExternalContext ? *ExternalContext : *Context;
----------------
arsenm wrote:

The question that needs to be answered is "who owns the MCContext". I think the answer should be definitely MachineModuleInfo, or definitively an external owner. Having 2 modes here is a bad API 

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


More information about the llvm-commits mailing list