Skip to content

Commit a50108f

Browse files
committed
Fix a debug location in DCE.
Fixes SR-15300: Compiler crash when using Builtin.unreachable in initializers Otherwise, this triggers an debug info verification assert that invalid locations must only be on unreachable instructions. This is why generating lifetime cleanup code should never inherit its location from its insertion point.
1 parent ee79c9f commit a50108f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,11 @@ bool DCE::removeDead() {
581581
// dead and will be deleted.
582582
// We do not have to end lifetime of a @guaranteed non phi arg.
583583
if (arg->getOwnershipKind() == OwnershipKind::Owned) {
584+
auto loc = RegularLocation::getAutoGeneratedLocation();
585+
// insertPt is non-null because Undef is non-owned.
584586
auto insertPt = getInsertAfterPoint(arg).getValue();
585587
SILBuilderWithScope builder(insertPt);
586-
auto *destroy = builder.createDestroyValue(insertPt->getLoc(), arg);
588+
auto *destroy = builder.createDestroyValue(loc, arg);
587589
LiveInstructions.insert(destroy);
588590
}
589591
i++;

0 commit comments

Comments
 (0)