[AutoDiff] Use LinkEntity::SecondaryPointer for diff witness (#82412)

If `LinkEntity::isTypeKind()` is true, `IRGenModule::getAddrOfLLVMVariable` assumes that we can safely call
`LinkEntity::getType()`, which does `reinterpret_cast` of `LinkEntity::Pointer` to `TypeBase *`. However, for SIL
differentiability witness, the pointer has `SILDifferentiabilityWitness *` type, which is not derived from `TypeBase`. So, such a cast is not allowed.

Just as with `ProtocolWitnessTableLazyAccessFunction` and `ProtocolWitnessTableLazyCacheVariable` link entity kinds (which are also type kinds), we should use `SecondaryPointer` instead of `Pointer` for storing payload here, while setting `Pointer` to `nullptr`.
This commit is contained in:
Daniil Kovalev
2025-06-23 23:18:07 +00:00
committed by GitHub
parent 31a9b798bb
commit 644f364d3d
2 changed files with 5 additions and 5 deletions

View File

@@ -1445,7 +1445,7 @@ bool IRGenModule::IsWellKnownBuiltinOrStructralType(CanType T) const {
T == Context.getAnyObjectType())
return true;
if (auto IntTy = dyn_cast<BuiltinIntegerType>(T)) {
if (auto IntTy = dyn_cast_or_null<BuiltinIntegerType>(T)) {
auto Width = IntTy->getWidth();
if (Width.isPointerWidth())
return true;