Skip to content

Commit 920c560

Browse files
authored
Merge pull request #75807 from meg-gupta/fixdebuginfodoe
Fix debug info in DeadObjectElimination in OSSA
2 parents 1c6552f + f71ab17 commit 920c560

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/SILOptimizer/Transforms/DeadObjectElimination.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,9 @@ bool DeadObjectElimination::processAllocStack(AllocStackInst *ASI) {
995995
return false;
996996
}
997997

998+
for (auto *I : UsersToRemove)
999+
salvageDebugInfo(I);
1000+
9981001
if (ASI->getFunction()->hasOwnership()) {
9991002
for (auto *user : UsersToRemove) {
10001003
auto *store = dyn_cast<StoreInst>(user);
@@ -1019,8 +1022,6 @@ bool DeadObjectElimination::processAllocStack(AllocStackInst *ASI) {
10191022
}
10201023
}
10211024

1022-
for (auto *I : UsersToRemove)
1023-
salvageDebugInfo(I);
10241025
// Remove the AllocRef and all of its users.
10251026
removeInstructions(
10261027
ArrayRef<SILInstruction*>(UsersToRemove.begin(), UsersToRemove.end()));

test/SILOptimizer/dead_array_elim_ossa.sil

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ class TrivialDestructor {
1818
deinit { }
1919
}
2020

21+
class Klass {}
22+
23+
struct NonTrivialStruct {
24+
var k : Klass
25+
init()
26+
}
27+
2128
// Remove a dead array.
2229
// rdar://20980377 Add dead array elimination to DeadObjectElimination
2330
// Swift._allocateUninitializedArray <A> (Builtin.Word) -> (Swift.Array<A>, Builtin.RawPointer)
@@ -167,3 +174,19 @@ bb2:
167174
return %18 : $()
168175
}
169176

177+
// CHECK-LABEL: sil [ossa] @dead_debuginfo
178+
// CHECK-NOT: alloc_stack
179+
// CHECK-LABEL: } // end sil function 'dead_debuginfo'
180+
sil [ossa] @dead_debuginfo : $@convention(thin) (@owned Klass) -> () {
181+
bb0(%0 : @owned $Klass):
182+
%1 = alloc_stack [lexical] [var_decl] $NonTrivialStruct, var, name "x", type $NonTrivialStruct
183+
%2 = integer_literal $Builtin.Int64, 0
184+
%4 = struct $NonTrivialStruct (%0 : $Klass)
185+
apply undef(%4) : $@convention(thin) (@guaranteed NonTrivialStruct) -> ()
186+
store %4 to [init] %1 : $*NonTrivialStruct
187+
destroy_addr %1 : $*NonTrivialStruct
188+
dealloc_stack %1 : $*NonTrivialStruct
189+
%t = tuple ()
190+
return %t : $()
191+
}
192+

0 commit comments

Comments
 (0)