[codegen] Layout of __si_class_type_info doesn't match the actual size

Right now, clang generates the following definition:
@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr

But the size of this data is larger than 8 bytes (Itanium C++ ABI).
Indeed I can find code like:
getelementptr inbounds ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2

Technically, this IR is invalid because the pointer goes out of bounds, and thus the gep inbounds returns poison.

Is it possible to change the size of the definition to match the actual size? I don’t know the implications of messing around with this stuff, but it would be great to make sure that the generated IR is well-defined.

Thank you!

These aren’t the same thing? __si_class_type_info is __class_type_info with an extra member.

Just a copy-paste typo, sorry.
It’s code like this I’m talking about:

@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
@_ZTS4Base = linkonce_odr dso_local constant [6 x i8] c"4Base\00", comdat, align 1
@_ZTI4Base = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS4Base }, comdat, align 8

That gep is OOB.

I don’t think we actually know the size? We can probably make it a [0 x ptr], though.

ah, I didn’t know that zero-sized arrays existed in LLVM. They do show up in LangRef though.
If the size is not known, that sounds like a good solution, thanks!