Skip to content

Commit 305125d

Browse files
authored
Merge pull request #82694 from clackary/cherrypick/autodiff-fix-link-entity-diff-witness
[6.2 🍒][AutoDiff] Use `LinkEntity::SecondaryPointer` for diff witness
2 parents 8686a8b + a86e717 commit 305125d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/swift/IRGen/Linking.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class LinkEntity {
132132
/// ValueDecl*, SILFunction*, or TypeBase*, depending on Kind.
133133
void *Pointer;
134134

135-
/// ProtocolConformance*, depending on Kind.
135+
/// ProtocolConformance* or SILDifferentiabilityWitness*, depending on Kind.
136136
void *SecondaryPointer;
137137

138138
/// A hand-rolled bitfield with the following layout:
@@ -772,8 +772,8 @@ class LinkEntity {
772772
void
773773
setForDifferentiabilityWitness(Kind kind,
774774
const SILDifferentiabilityWitness *witness) {
775-
Pointer = const_cast<void *>(static_cast<const void *>(witness));
776-
SecondaryPointer = nullptr;
775+
Pointer = nullptr;
776+
SecondaryPointer = const_cast<void *>(static_cast<const void *>(witness));
777777
Data = LINKENTITY_SET_FIELD(Kind, unsigned(kind));
778778
}
779779

@@ -1684,7 +1684,7 @@ class LinkEntity {
16841684

16851685
SILDifferentiabilityWitness *getSILDifferentiabilityWitness() const {
16861686
assert(getKind() == Kind::DifferentiabilityWitness);
1687-
return reinterpret_cast<SILDifferentiabilityWitness *>(Pointer);
1687+
return reinterpret_cast<SILDifferentiabilityWitness *>(SecondaryPointer);
16881688
}
16891689

16901690
const RootProtocolConformance *getRootProtocolConformance() const {

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ bool IRGenModule::IsWellKnownBuiltinOrStructralType(CanType T) const {
14491449
T == Context.getAnyObjectType())
14501450
return true;
14511451

1452-
if (auto IntTy = dyn_cast<BuiltinIntegerType>(T)) {
1452+
if (auto IntTy = dyn_cast_or_null<BuiltinIntegerType>(T)) {
14531453
auto Width = IntTy->getWidth();
14541454
if (Width.isPointerWidth())
14551455
return true;

0 commit comments

Comments
 (0)