-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[opt] Re-work broadenSingleElementStores to use projections.
* Fixes loadable edge case for address-only types. * Re-work, generalize, and simplify by using projections. * Support `-enable-cxx-interop` in sil-opt.
- Loading branch information
Showing
7 changed files
with
113 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef VALIDATION_TEST_SILOPTIMIZER_FOO_H | ||
#define VALIDATION_TEST_SILOPTIMIZER_FOO_H | ||
|
||
struct Foo { | ||
int x; | ||
~Foo() {} | ||
}; | ||
|
||
struct Loadable { | ||
int x; | ||
}; | ||
|
||
struct Bar { | ||
Loadable y; | ||
~Bar() {} | ||
}; | ||
|
||
#endif // VALIDATION_TEST_SILOPTIMIZER_FOO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Foo { | ||
header "foo.h" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: %target-sil-opt -silgen-cleanup %s -I %S/Inputs -enable-sil-verify-all -enable-cxx-interop | %FileCheck %s | ||
|
||
sil_stage canonical | ||
|
||
import Builtin | ||
import Swift | ||
import SwiftShims | ||
import Foo | ||
|
||
// Make sure we don't try to create a struct here. Foo is not loadable, even | ||
// though it's only property is. | ||
// CHECK-LABEL: @test_foo | ||
// CHECK: bb0 | ||
// CHECK-NEXT: [[E:%.*]] = struct_element_addr | ||
// CHECK-NEXT: store %1 to [trivial] [[E]] | ||
// CHECK-NEXT: tuple | ||
// CHECK-NEXT: return | ||
// CHECK-LABEL: end sil function 'test_foo' | ||
sil shared [transparent] [serializable] [ossa] @test_foo : $@convention(method) (Int32, @thin Foo.Type) -> @out Foo { | ||
bb0(%0 : $*Foo, %1 : $Int32, %2 : $@thin Foo.Type): | ||
%3 = struct_element_addr %0 : $*Foo, #Foo.x | ||
store %1 to [trivial] %3 : $*Int32 | ||
%5 = tuple () | ||
return %5 : $() | ||
} | ||
|
||
// Make sure we create a struct for the first (loadable) type but not the second | ||
// type (Bar). | ||
// CHECK-LABEL: @test_bar | ||
// CHECK: bb0 | ||
// CHECK-NEXT: [[E:%.*]] = struct_element_addr | ||
// CHECK-NEXT: [[AGG:%.*]] = struct $Loadable (%1 : $Int32) | ||
// CHECK-NEXT: store [[AGG]] to [trivial] [[E]] | ||
// CHECK-NEXT: tuple | ||
// CHECK-NEXT: return | ||
// CHECK-LABEL: end sil function 'test_bar' | ||
sil shared [transparent] [serializable] [ossa] @test_bar : $@convention(method) (Int32, @thin Bar.Type) -> @out Bar { | ||
bb0(%0 : $*Bar, %1 : $Int32, %2 : $@thin Bar.Type): | ||
%3 = struct_element_addr %0 : $*Bar, #Bar.y | ||
%3a = struct_element_addr %3 : $*Loadable, #Loadable.x | ||
store %1 to [trivial] %3a : $*Int32 | ||
%5 = tuple () | ||
return %5 : $() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters