Skip to content

Commit fd06bb1

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
1 parent 19bd65c commit fd06bb1

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)