Skip to content

Commit e6694c1

Browse files
committed
DebugInfo: fix FSPL SILLocation assertion issue
We were reusing the SILLocation from return instructions to generate projections to ultimately destroy values. This fix improves on what we were doing before, by converting the insertion point's SILLocation into a RegularLocation _without dropping_ the source location. If the SILLocation was tied to an ASTNode, it'll carry over the line location for this new regular location. Otherwise, it'll fallback to the prior strategy of producing a line 0 autogenerated location. resolves rdar://163281183 (cherry picked from commit fd06bb1)
1 parent de48c2f commit e6694c1

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
@@ -434,10 +434,23 @@ void TypeTreeLeafTypeRange::constructFilteredProjections(
434434
callback) {
435435
auto *fn = insertPt->getFunction();
436436
SILType type = value->getType();
437-
auto loc =
438-
(insertPt->getLoc().getKind() != SILLocation::ArtificialUnreachableKind)
439-
? insertPt->getLoc()
440-
: RegularLocation::getAutoGeneratedLocation();
437+
438+
// Create a debug location appropriate for synthesizing projection
439+
// instructions that satisfy `SILInstruction::verifyDebugInfo`, while
440+
// trying to preserve debug info when it's valid to do so.
441+
auto projectionLocFrom = [](SILInstruction *orig) -> SILLocation {
442+
auto loc = orig->getLoc();
443+
switch (loc.getKind()) {
444+
case SILLocation::ReturnKind:
445+
case SILLocation::ImplicitReturnKind:
446+
case SILLocation::ArtificialUnreachableKind:
447+
return RegularLocation::getDebugOnlyLocation(loc, orig->getModule());
448+
449+
default:
450+
return loc;
451+
}
452+
};
453+
SILLocation loc = projectionLocFrom(insertPt);
441454

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

0 commit comments

Comments
 (0)