Skip to content

Commit 4a543c8

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 4a543c8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 replace the local store with a debug_value.
11+
// The dead store elimination pass is written in Swift, and should call
12+
// salvage debug info when removing the store.
13+
14+
// CHECK-LABEL: @trivial_local_dead_store
15+
// CHECK: debug_value %{{[0-9]+}} : $Int, var, name "a"
16+
// CHECK: return
17+
sil hidden @trivial_local_dead_store : $@convention(thin) () -> () {
18+
bb0:
19+
%0 = alloc_stack $Int, var, name "a"
20+
%1 = integer_literal $Builtin.Int64, 1
21+
%2 = struct $Int (%1 : $Builtin.Int64)
22+
store %2 to %0 : $*Int
23+
%4 = tuple ()
24+
dealloc_stack %0 : $*Int
25+
return %4 : $()
26+
}

0 commit comments

Comments
 (0)