Skip to content

Commit 7623a5d

Browse files
committed
[DebugInfo] Salvage Debug Info in Swift Function Passes
Salvage Debug Info was only being called for simplifications, and not for function passes written in Swift. Salvage Debug Info is now called for both cases.
1 parent fac61c5 commit 7623a5d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ void SwiftPassInvocation::eraseInstruction(SILInstruction *inst) {
615615
if (silCombiner) {
616616
silCombiner->eraseInstFromFunction(*inst);
617617
} else {
618+
swift::salvageDebugInfo(inst);
618619
if (inst->isStaticInitializerInst()) {
619620
inst->getParent()->erase(inst, *getPassManager()->getModule());
620621
} else {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-sil-opt %s -dead-store-elimination -enable-sil-verify-all | %FileCheck %s
2+
3+
// REQUIRES: swift_in_compiler
4+
5+
sil_stage canonical
6+
7+
import Swift
8+
import Builtin
9+
10+
// We should be able to remove the local store that is not read.
11+
//
12+
// CHECK-LABEL: @trivial_local_dead_store
13+
// CHECK: debug_value %{{[0-9]+}} : $Int, var, name "a"
14+
// CHECK: return
15+
sil hidden @trivial_local_dead_store : $@convention(thin) () -> () {
16+
bb0:
17+
%0 = alloc_stack $Int, var, name "a"
18+
%1 = integer_literal $Builtin.Int64, 1
19+
%2 = struct $Int (%1 : $Builtin.Int64)
20+
store %2 to %0 : $*Int
21+
%4 = tuple ()
22+
dealloc_stack %0 : $*Int
23+
return %4 : $()
24+
}

0 commit comments

Comments
 (0)