Skip to content

Commit a9e675e

Browse files
committed
---
yaml --- r: 347263 b: refs/heads/master c: d45e63b h: refs/heads/master i: 347261: 2b12610 347259: 0a1bcc5 347255: 3c793e4 347247: bd2d98e 347231: 3e9adf0 347199: 0110c1c 347135: a433ebe
1 parent c454adb commit a9e675e

File tree

29 files changed

+707
-655
lines changed

29 files changed

+707
-655
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e265f50e8309dfaa4701f51eb13fb25794fd2d68
2+
refs/heads/master: d45e63b98e5f1023d966b3b6ac21a12135acb0a7
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ function(_add_swift_library_single target name)
721721
FILE_DEPENDS
722722
FRAMEWORK_DEPENDS
723723
FRAMEWORK_DEPENDS_WEAK
724+
GYB_SOURCES
724725
INCORPORATE_OBJECT_LIBRARIES
725726
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
726727
INTERFACE_LINK_LIBRARIES
@@ -810,10 +811,14 @@ function(_add_swift_library_single target name)
810811
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
811812
endif()
812813

813-
handle_gyb_sources(
814-
gyb_dependency_targets
815-
SWIFTLIB_SINGLE_SOURCES
816-
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
814+
if(SWIFTLIB_SINGLE_GYB_SOURCES)
815+
handle_gyb_sources(
816+
gyb_dependency_targets
817+
SWIFTLIB_SINGLE_GYB_SOURCES
818+
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
819+
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES}
820+
${SWIFTLIB_SINGLE_GYB_SOURCES})
821+
endif()
817822

818823
# Remove the "swift" prefix from the name to determine the module name.
819824
if(SWIFTLIB_IS_STDLIB_CORE)
@@ -1620,6 +1625,7 @@ function(add_swift_target_library name)
16201625
FRAMEWORK_DEPENDS_IOS_TVOS
16211626
FRAMEWORK_DEPENDS_OSX
16221627
FRAMEWORK_DEPENDS_WEAK
1628+
GYB_SOURCES
16231629
INCORPORATE_OBJECT_LIBRARIES
16241630
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
16251631
INTERFACE_LINK_LIBRARIES
@@ -1914,6 +1920,7 @@ function(add_swift_target_library name)
19141920
DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
19151921
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
19161922
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
1923+
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19171924
)
19181925

19191926
if(NOT SWIFTLIB_OBJECT_LIBRARY)

trunk/cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,31 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
131131
"${SWIFT_SOURCE_DIR}/utils/gyb_sourcekit_support/UIDs.py")
132132

133133
foreach (src ${${sources_var_name}})
134-
string(REGEX REPLACE "[.]gyb$" "" src_sans_gyb "${src}")
135-
if(src STREQUAL src_sans_gyb)
136-
list(APPEND de_gybbed_sources "${src}")
134+
# On Windows (using Visual Studio), the generated project files assume that the
135+
# generated GYB files will be in the source, not binary directory.
136+
# We can work around this by modifying the root directory when generating VS projects.
137+
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
138+
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
137139
else()
140+
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
141+
endif()
138142

139-
# On Windows (using Visual Studio), the generated project files assume that the
140-
# generated GYB files will be in the source, not binary directory.
141-
# We can work around this by modifying the root directory when generating VS projects.
142-
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
143-
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
144-
else()
145-
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
146-
endif()
147-
148-
if (arch)
149-
set(dir "${dir_root}/${ptr_size}")
150-
else()
151-
set(dir "${dir_root}")
152-
endif()
153-
set(output_file_name "${dir}/${src_sans_gyb}")
154-
list(APPEND de_gybbed_sources "${output_file_name}")
155-
handle_gyb_source_single(dependency_target
156-
SOURCE "${src}"
157-
OUTPUT "${output_file_name}"
158-
FLAGS ${extra_gyb_flags}
159-
DEPENDS "${gyb_extra_sources}"
160-
COMMENT "with ptr size = ${ptr_size}")
161-
list(APPEND dependency_targets "${dependency_target}")
143+
if (arch)
144+
set(dir "${dir_root}/${ptr_size}")
145+
else()
146+
set(dir "${dir_root}")
162147
endif()
148+
# get_filename_component(src_sans_gyb ${src} NAME_WLE)
149+
string(REGEX REPLACE "\.gyb$" "" src_sans_gyb ${src})
150+
set(output_file_name "${dir}/${src_sans_gyb}")
151+
list(APPEND de_gybbed_sources "${output_file_name}")
152+
handle_gyb_source_single(dependency_target
153+
SOURCE "${src}"
154+
OUTPUT "${output_file_name}"
155+
FLAGS ${extra_gyb_flags}
156+
DEPENDS "${gyb_extra_sources}"
157+
COMMENT "with ptr size = ${ptr_size}")
158+
list(APPEND dependency_targets "${dependency_target}")
163159
endforeach()
164160
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
165161
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)

trunk/include/swift/SILOptimizer/Analysis/AccessedStorageAnalysis.h

Lines changed: 114 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ template <> struct DenseMapInfo<swift::StorageAccessInfo> {
122122
}
123123

124124
namespace swift {
125-
/// The per-function result of AccessedStorageAnalysis.
126-
///
125+
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
126+
127127
/// Records each unique AccessedStorage in a set of StorageAccessInfo
128128
/// objects. Hashing and equality only sees the AccesedStorage data. The
129129
/// additional StorageAccessInfo bits are recorded as results of this analysis.
@@ -133,28 +133,32 @@ namespace swift {
133133
/// results, either because the call graph is unknown or the access sets are too
134134
/// large. It does not imply that all accesses have Unidentified
135135
/// AccessedStorage, which is never allowed for class or global access.
136-
class FunctionAccessedStorage {
137-
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
138-
136+
class AccessedStorageResult {
139137
AccessedStorageSet storageAccessSet;
140138
Optional<SILAccessKind> unidentifiedAccess;
141139

142140
public:
143-
FunctionAccessedStorage() {}
141+
AccessedStorageResult() {}
144142

145143
// ---------------------------------------------------------------------------
146144
// Accessing the results.
147145

146+
const AccessedStorageSet &getStorageSet() const { return storageAccessSet; }
147+
148+
bool isEmpty() const {
149+
return storageAccessSet.empty() && !unidentifiedAccess;
150+
}
151+
148152
bool hasUnidentifiedAccess() const { return unidentifiedAccess != None; }
149153

150154
/// Return true if the analysis has determined all accesses of otherStorage
151155
/// have the [no_nested_conflict] flag set.
152156
///
153-
/// Only call this if there is no unidentifiedAccess in the function and the
157+
/// Only call this if there is no unidentifiedAccess in the region and the
154158
/// given storage is uniquely identified.
155159
bool hasNoNestedConflict(const AccessedStorage &otherStorage) const;
156160

157-
/// Does any of the accesses represented by this FunctionAccessedStorage
161+
/// Does any of the accesses represented by this AccessedStorageResult
158162
/// object conflict with the given access kind and storage.
159163
bool mayConflictWith(SILAccessKind otherAccessKind,
160164
const AccessedStorage &otherStorage) const;
@@ -181,6 +185,97 @@ class FunctionAccessedStorage {
181185
unidentifiedAccess = SILAccessKind::Modify;
182186
}
183187

188+
void setUnidentifiedAccess(SILAccessKind kind) { unidentifiedAccess = kind; }
189+
190+
/// Merge effects directly from \p RHS.
191+
bool mergeFrom(const AccessedStorageResult &other);
192+
193+
/// Merge the effects represented in calleeAccess into this
194+
/// FunctionAccessedStorage object. calleeAccess must correspond to at least
195+
/// one callee at the apply site `fullApply`. Merging drops any local effects,
196+
/// and translates parameter effects into effects on the caller-side
197+
/// arguments.
198+
///
199+
/// The full caller-side effects at a call site can be obtained with
200+
/// AccessedStorageAnalysis::getCallSiteEffects().
201+
bool mergeFromApply(const AccessedStorageResult &calleeAccess,
202+
FullApplySite fullApply);
203+
204+
/// Record any access scopes entered by the given single SIL instruction. 'I'
205+
/// must not be a FullApply; use mergeFromApply instead.
206+
void analyzeInstruction(SILInstruction *I);
207+
208+
void print(raw_ostream &os) const;
209+
void dump() const;
210+
211+
protected:
212+
std::pair<AccessedStorageSet::iterator, bool>
213+
insertStorageAccess(StorageAccessInfo storageAccess) {
214+
storageAccess.setStorageIndex(storageAccessSet.size());
215+
return storageAccessSet.insert(storageAccess);
216+
}
217+
218+
bool updateUnidentifiedAccess(SILAccessKind accessKind);
219+
220+
bool mergeAccesses(const AccessedStorageResult &other,
221+
std::function<StorageAccessInfo(const StorageAccessInfo &)>
222+
transformStorage);
223+
224+
template <typename B> void visitBeginAccess(B *beginAccess);
225+
};
226+
} // namespace swift
227+
228+
namespace swift {
229+
/// The per-function result of AccessedStorageAnalysis.
230+
class FunctionAccessedStorage {
231+
AccessedStorageResult accessResult;
232+
233+
public:
234+
FunctionAccessedStorage() {}
235+
236+
// ---------------------------------------------------------------------------
237+
// Accessing the results.
238+
239+
const AccessedStorageResult &getResult() const { return accessResult; }
240+
241+
bool hasUnidentifiedAccess() const {
242+
return accessResult.hasUnidentifiedAccess();
243+
}
244+
245+
/// Return true if the analysis has determined all accesses of otherStorage
246+
/// have the [no_nested_conflict] flag set.
247+
///
248+
/// Only call this if there is no unidentifiedAccess in the function and the
249+
/// given storage is uniquely identified.
250+
bool hasNoNestedConflict(const AccessedStorage &otherStorage) const {
251+
return accessResult.hasNoNestedConflict(otherStorage);
252+
}
253+
254+
/// Does any of the accesses represented by this FunctionAccessedStorage
255+
/// object conflict with the given access kind and storage.
256+
bool mayConflictWith(SILAccessKind otherAccessKind,
257+
const AccessedStorage &otherStorage) const {
258+
return accessResult.mayConflictWith(otherAccessKind, otherStorage);
259+
}
260+
261+
/// Raw access to the result for a given AccessedStorage location.
262+
StorageAccessInfo
263+
getStorageAccessInfo(const AccessedStorage &otherStorage) const {
264+
return accessResult.getStorageAccessInfo(otherStorage);
265+
}
266+
267+
// ---------------------------------------------------------------------------
268+
// Constructing the results.
269+
270+
void clear() { accessResult.clear(); }
271+
272+
/// Return true if these effects are fully conservative.
273+
bool hasWorstEffects() { return accessResult.hasWorstEffects(); }
274+
275+
/// Sets the most conservative effects, if we don't know anything about the
276+
/// function.
277+
void setWorstEffects() { accessResult.setWorstEffects(); }
278+
184279
/// Summarize the given function's effects using this FunctionAccessedStorage
185280
/// object.
186281
//
@@ -201,12 +296,14 @@ class FunctionAccessedStorage {
201296
///
202297
/// TODO: Summarize ArraySemanticsCall accesses.
203298
bool summarizeCall(FullApplySite fullApply) {
204-
assert(storageAccessSet.empty() && "expected uninitialized results.");
299+
assert(accessResult.isEmpty() && "expected uninitialized results.");
205300
return false;
206301
}
207302

208303
/// Merge effects directly from \p RHS.
209-
bool mergeFrom(const FunctionAccessedStorage &RHS);
304+
bool mergeFrom(const FunctionAccessedStorage &RHS) {
305+
return accessResult.mergeFrom(RHS.accessResult);
306+
}
210307

211308
/// Merge the effects represented in calleeAccess into this
212309
/// FunctionAccessedStorage object. calleeAccess must correspond to at least
@@ -217,31 +314,19 @@ class FunctionAccessedStorage {
217314
/// The full caller-side effects at a call site can be obtained with
218315
/// AccessedStorageAnalysis::getCallSiteEffects().
219316
bool mergeFromApply(const FunctionAccessedStorage &calleeAccess,
220-
FullApplySite fullApply);
317+
FullApplySite fullApply) {
318+
return accessResult.mergeFromApply(calleeAccess.accessResult, fullApply);
319+
}
221320

222321
/// Analyze the side-effects of a single SIL instruction \p I.
223322
/// Visited callees are added to \p BottomUpOrder until \p RecursionDepth
224323
/// reaches MaxRecursionDepth.
225-
void analyzeInstruction(SILInstruction *I);
226-
227-
void print(raw_ostream &os) const;
228-
void dump() const;
229-
230-
protected:
231-
std::pair<AccessedStorageSet::iterator, bool>
232-
insertStorageAccess(StorageAccessInfo storageAccess) {
233-
storageAccess.setStorageIndex(storageAccessSet.size());
234-
return storageAccessSet.insert(storageAccess);
324+
void analyzeInstruction(SILInstruction *I) {
325+
accessResult.analyzeInstruction(I);
235326
}
236327

237-
bool updateUnidentifiedAccess(SILAccessKind accessKind);
238-
239-
bool mergeAccesses(
240-
const FunctionAccessedStorage &other,
241-
std::function<StorageAccessInfo(const StorageAccessInfo &)>
242-
transformStorage);
243-
244-
template <typename B> void visitBeginAccess(B *beginAccess);
328+
void print(raw_ostream &os) const { accessResult.print(os); }
329+
void dump() const { accessResult.dump(); }
245330
};
246331

247332
/// Summarizes the dynamic accesses performed within a function and its

trunk/lib/Basic/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ add_swift_host_library(swiftBasic STATIC
102102
# Platform-agnostic fallback TaskQueue implementation
103103
Default/TaskQueue.inc
104104

105-
UnicodeExtendedGraphemeClusters.cpp.gyb
105+
GYB_SOURCES
106+
UnicodeExtendedGraphemeClusters.cpp.gyb
106107

107108
C_COMPILE_FLAGS ${UUID_INCLUDE}
108109
LLVM_COMPONENT_DEPENDS support)

trunk/lib/Parse/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ add_swift_host_library(swiftParse STATIC
1010
ParseDecl.cpp
1111
ParsedRawSyntaxNode.cpp
1212
ParsedRawSyntaxRecorder.cpp
13-
ParsedSyntaxBuilders.cpp.gyb
14-
ParsedSyntaxNodes.cpp.gyb
15-
ParsedSyntaxRecorder.cpp.gyb
1613
ParsedTrivia.cpp
1714
ParseExpr.cpp
1815
ParseGeneric.cpp
@@ -24,7 +21,12 @@ add_swift_host_library(swiftParse STATIC
2421
PersistentParserState.cpp
2522
Scope.cpp
2623
SyntaxParsingCache.cpp
27-
SyntaxParsingContext.cpp)
24+
SyntaxParsingContext.cpp
25+
26+
GYB_SOURCES
27+
ParsedSyntaxBuilders.cpp.gyb
28+
ParsedSyntaxNodes.cpp.gyb
29+
ParsedSyntaxRecorder.cpp.gyb)
2830
target_link_libraries(swiftParse PRIVATE
2931
swiftAST
3032
swiftSyntax)

0 commit comments

Comments
 (0)