[clang] [RFC] [clang] [CodeGen] Avoid creating global variable repeatedly when type are not specified (PR #114948)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 12:32:17 PST 2024


efriedma-quic wrote:

> If we want to change the type of a global variable, maybe we can use Value::mutateType

Trying to mutate the type of a global is still unsafe.  The benefit of opaque pointers here is that getValueType() is independent from getType(), so it's safe to rewrite the ValueType.  (This is what GlobalVariable::replaceInitializer() does.)

> I don't think there's any situation in which Clang needs to change the address space of a declaration.

I wouldn't be surprised if there's some GPU stuff that relies on this, maybe by accident.

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


More information about the cfe-commits mailing list