mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user