Skip to content

Commit cebe79d

Browse files
committed
SIL: use object libraries instead of globbing
This simplifies the handling of the subdirectories in the SIL and SILOptimizer paths. Create individual libraries as object libraries which allows the analysis of the source changes to be limited in scope. Because these are object libraries, this has 0 overhead compared to the previous implementation. However, string operations over the filenames are avoided. The cost for this is that any new sub-library needs to be added into the list rather than added with the special local function.
1 parent dca0209 commit cebe79d

File tree

21 files changed

+76
-103
lines changed

21 files changed

+76
-103
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ if(POLICY CMP0067)
1212
cmake_policy(SET CMP0067 NEW)
1313
endif()
1414

15+
# Convert relative paths to absolute for subdirectory `target_sources`
16+
if(POLICY CMP0076)
17+
cmake_policy(SET CMP0076 NEW)
18+
endif()
19+
1520
# Add path for custom CMake modules.
1621
list(APPEND CMAKE_MODULE_PATH
1722
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

lib/SIL/CMakeLists.txt

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
1-
2-
set(SIL_SOURCES)
3-
4-
function(_list_transform newvar)
5-
set(sources ${ARGN})
6-
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
7-
set(tmp)
8-
foreach (s ${sources})
9-
list(APPEND tmp "${dir}/${s}")
10-
endforeach()
11-
set(${newvar} "${tmp}" PARENT_SCOPE)
12-
endfunction()
13-
14-
macro(sil_register_sources)
15-
precondition(new_transformed_sources
16-
NEGATE
17-
MESSAGE "Expected this to be empty since we clear after each run")
18-
_list_transform(new_transformed_sources ${ARGN})
19-
list_union("${SIL_SOURCES}" "${new_transformed_sources}" out)
20-
set(SIL_SOURCES "${out}" PARENT_SCOPE)
21-
set(new_transformed_sources)
22-
endmacro()
23-
24-
add_subdirectory(IR)
25-
add_subdirectory(Utils)
26-
add_subdirectory(Verifier)
27-
add_subdirectory(Parser)
28-
291
add_swift_host_library(swiftSIL STATIC
30-
${SIL_SOURCES})
2+
SIL.cpp)
313
target_link_libraries(swiftSIL PUBLIC
324
swiftDemangling)
335
target_link_libraries(swiftSIL PRIVATE
346
swiftSema
357
swiftSerialization)
368

9+
add_subdirectory(IR)
10+
add_subdirectory(Utils)
11+
add_subdirectory(Verifier)
12+
add_subdirectory(Parser)
13+
3714
# intrinsics_gen is the LLVM tablegen target that generates the include files
3815
# where intrinsics and attributes are declared. swiftSIL depends on these
3916
# headers.

lib/SIL/IR/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sil_register_sources(
1+
target_sources(swiftSIL PRIVATE
22
AbstractionPattern.cpp
33
Bridging.cpp
44
Linker.cpp
@@ -31,5 +31,4 @@ sil_register_sources(
3131
SILValue.cpp
3232
SILWitnessTable.cpp
3333
TypeLowering.cpp
34-
ValueOwnership.cpp
35-
)
34+
ValueOwnership.cpp)

lib/SIL/Parser/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
sil_register_sources(
2-
ParseSIL.cpp
3-
)
4-
1+
target_sources(swiftSIL PRIVATE
2+
ParseSIL.cpp)

lib/SIL/SIL.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===--- SIL.cpp ---------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// DO NOT MODIFY THIS FILE!
14+
// The SIL library is split into sub-components, modify the respective
15+
// sub-component.

lib/SIL/Utils/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sil_register_sources(
1+
target_sources(swiftSIL PRIVATE
22
BasicBlockUtils.cpp
33
DebugUtils.cpp
44
Dominance.cpp
@@ -13,5 +13,4 @@ sil_register_sources(
1313
SILInstructionWorklist.cpp
1414
SILOpenedArchetypesTracker.cpp
1515
SILRemarkStreamer.cpp
16-
ValueUtils.cpp
17-
)
16+
ValueUtils.cpp)

lib/SIL/Verifier/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
sil_register_sources(
1+
target_sources(swiftSIL PRIVATE
22
LoadBorrowInvalidationChecker.cpp
33
LinearLifetimeChecker.cpp
44
MemoryLifetime.cpp
55
SILOwnershipVerifier.cpp
6-
SILVerifier.cpp
7-
)
6+
SILVerifier.cpp)

lib/SILOptimizer/ARC/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
silopt_register_sources(
1+
target_sources(swiftSILOptimizer PRIVATE
22
ARCBBState.cpp
33
ARCLoopOpts.cpp
44
ARCMatchingSet.cpp
@@ -8,5 +8,4 @@ silopt_register_sources(
88
GlobalLoopARCSequenceDataflow.cpp
99
RCStateTransition.cpp
1010
RCStateTransitionVisitors.cpp
11-
RefCountState.cpp
12-
)
11+
RefCountState.cpp)

lib/SILOptimizer/Analysis/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
silopt_register_sources(
1+
target_sources(swiftSILOptimizer PRIVATE
22
ARCAnalysis.cpp
33
AccessSummaryAnalysis.cpp
44
AccessedStorageAnalysis.cpp
@@ -25,5 +25,4 @@ silopt_register_sources(
2525
SideEffectAnalysis.cpp
2626
SimplifyInstruction.cpp
2727
TypeExpansionAnalysis.cpp
28-
ValueTracking.cpp
29-
)
28+
ValueTracking.cpp)

lib/SILOptimizer/CMakeLists.txt

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
2-
set(SILOPTIMIZER_SOURCES)
3-
4-
function(_list_transform newvar)
5-
set(sources ${ARGN})
6-
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
7-
set(tmp)
8-
foreach (s ${sources})
9-
list(APPEND tmp "${dir}/${s}")
10-
endforeach()
11-
set(${newvar} "${tmp}" PARENT_SCOPE)
12-
endfunction()
13-
14-
macro(silopt_register_sources)
15-
precondition(new_transformed_sources
16-
NEGATE
17-
MESSAGE "Expected this to be empty since we clear after each run")
18-
_list_transform(new_transformed_sources ${ARGN})
19-
list_union("${SILOPTIMIZER_SOURCES}" "${new_transformed_sources}" out)
20-
set(SILOPTIMIZER_SOURCES "${out}" PARENT_SCOPE)
21-
set(new_transformed_sources)
22-
endmacro()
1+
add_swift_host_library(swiftSILOptimizer STATIC
2+
SILOptimizer.cpp)
3+
target_link_libraries(swiftSILOptimizer PRIVATE
4+
swiftSIL)
235

246
add_subdirectory(ARC)
257
add_subdirectory(Analysis)
@@ -33,8 +15,3 @@ add_subdirectory(SILCombiner)
3315
add_subdirectory(Transforms)
3416
add_subdirectory(UtilityPasses)
3517
add_subdirectory(Utils)
36-
37-
add_swift_host_library(swiftSILOptimizer STATIC
38-
${SILOPTIMIZER_SOURCES})
39-
target_link_libraries(swiftSILOptimizer PRIVATE
40-
swiftSIL)

0 commit comments

Comments
 (0)