SILGen: Emit cleanups before returning from enum case constructors.

We were leaking dealloc_stacks when the enum constructor had to create temporary allocations in order to implode address-only tuple payloads.

Swift SVN r8971
This commit is contained in:
Joe Groff
2013-10-07 18:04:43 +00:00
parent c6d7c2941e
commit 0bff1ebe7b
2 changed files with 13 additions and 0 deletions

11
test/SILGen/enum.swift Normal file
View File

@@ -0,0 +1,11 @@
// RUN: %swift -emit-silgen %s | FileCheck %s
protocol P {}
// Regression test for a bug where temporary allocations created as a result of
// tuple implosion were not deallocated in enum constructors.
enum Foo { case A(P, String) }
// CHECK: sil [transparent] @_TO4enum3Foo1AfMS0_FTPS_1P_SS_S0_ : $[thin] ((P, String), Foo.metatype) -> Foo {
// CHECK: [[ALLOC:%.*]] = alloc_stack $(P, String)
// CHECK: dealloc_stack [[ALLOC]]#0
// CHECK: }