Skip to content

Commit ae181f8

Browse files
committed
(to fixup later) simplify alloc stack safely
1 parent ab6fd6c commit ae181f8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyAllocStack.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,10 @@ private extension AllocStackInst {
332332
isLexical: isLexical,
333333
isFromVarDecl: isFromVarDecl,
334334
usesMoveableValueDebugInfo: usesMoveableValueDebugInfo)
335-
for use in uses {
336-
// FIXME: Are there any specific cases to handle?
337-
use.set(to: newAlloc, context)
338-
}
339-
context.erase(instruction: self)
335+
let builderAfter = Builder(after: self, context)
336+
let addrCast = builderAfter.createUncheckedAddrCast(from: newAlloc, to: self.type.addressType)
337+
uses.replaceAll(with: addrCast, context)
338+
self.replace(with: newAlloc, context)
340339
return true
341340
}
342341

0 commit comments

Comments
 (0)