Skip to content

Commit 0849b2e

Browse files
authored
Merge pull request #85119 from kavon/fspl-debuginfo-rdar163281183
DebugInfo: fix FSPL SILLocation assertion issue
2 parents 7e8d8b6 + fd06bb1 commit 0849b2e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,23 @@ void TypeTreeLeafTypeRange::constructFilteredProjections(
441441
callback) {
442442
auto *fn = insertPt->getFunction();
443443
SILType type = value->getType();
444-
auto loc =
445-
(insertPt->getLoc().getKind() != SILLocation::ArtificialUnreachableKind)
446-
? insertPt->getLoc()
447-
: RegularLocation::getAutoGeneratedLocation();
444+
445+
// Create a debug location appropriate for synthesizing projection
446+
// instructions that satisfy `SILInstruction::verifyDebugInfo`, while
447+
// trying to preserve debug info when it's valid to do so.
448+
auto projectionLocFrom = [](SILInstruction *orig) -> SILLocation {
449+
auto loc = orig->getLoc();
450+
switch (loc.getKind()) {
451+
case SILLocation::ReturnKind:
452+
case SILLocation::ImplicitReturnKind:
453+
case SILLocation::ArtificialUnreachableKind:
454+
return RegularLocation::getDebugOnlyLocation(loc, orig->getModule());
455+
456+
default:
457+
return loc;
458+
}
459+
};
460+
SILLocation loc = projectionLocFrom(insertPt);
448461

449462
PRUNED_LIVENESS_LOG(llvm::dbgs() << "ConstructFilteredProjection. Bv: "
450463
<< filterBitVector << '\n');

0 commit comments

Comments
 (0)