MaskRay wrote:

> Is there a reason we just want to move the pointer reference from MCContext 
> to MCAsmInfo versus making MCAsmInfo own MCTargetOptions?

The current state is not ideal.

Prominent MCContext users, such as `cc1as_main.cpp` and `llvm-mc.cpp`, define 
`MCTargetOptions` (~280 bytes) as a local variable, initialize its members, 
then pass a reference to `createMCAsmInfo` and a pointer to `MCContext` ctor.
However, some users forget to pass the `MCTargetOptions` pointer to the 
`MCContext`, causing the object streamer to check nullness and fall back to the 
default `MCTargetOptions` member values.

Since MCTargetOptions is quite large with many strings and vectors, copying it 
isn't desirable.
Having MCContext own a raw pointer from the createMCAsmInfo argument is 
admittedly error-prone (stack-use-after-return), but most users don't outlive 
the MCAsmInfo object, so I believe this trade-off is acceptable.


https://github.com/llvm/llvm-project/pull/180465
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to