-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchapel-1.33.0-frontend.patch
More file actions
226 lines (209 loc) · 9 KB
/
chapel-1.33.0-frontend.patch
File metadata and controls
226 lines (209 loc) · 9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt
index ad620f38ae..ae36cb035d 100644
--- a/frontend/CMakeLists.txt
+++ b/frontend/CMakeLists.txt
@@ -15,7 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
+set(CHPL_MAJOR_VERSION 2)
+set(CHPL_MINOR_VERSION 3)
+set(CHPL_PATCH_VERSION 0)
+set(CHPL_BUILD_VERSION 0)
+set(CHPL_OFFICIAL_RELEASE false)
# CHPL_HOME may have been defined by an upstream CMakeLists.txt, so check if
# it doesn't exist before trying to create it.
if (NOT DEFINED CHPL_HOME)
@@ -76,19 +80,18 @@ set(CHPL_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
configure_file(${CHPL_MAIN_INCLUDE_DIR}/chpl/config/config.h.cmake
${CHPL_INCLUDE_DIR}/chpl/config/config.h)
-
-# request C++14 -- or C++17 if using LLVM 16
-if (CHPL_LLVM_VERSION VERSION_LESS 16.0)
- set(CMAKE_CXX_STANDARD 14)
-else()
- set(CMAKE_CXX_STANDARD 17)
-endif()
+# request C++17
+set(CMAKE_CXX_STANDARD 20)
+set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# request C11
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
+find_package(LLVM REQUIRED CONFIG)
+find_package(Clang REQUIRED CONFIG)
+
# generate the compile_commands.json compilation database
# tools like the fieldsUsed linter require this
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -132,15 +135,16 @@ endif()
# lib/CMakeLists.txt defines the target ChplFrontend
add_subdirectory(lib)
+
# Support for documentation of AST header
add_subdirectory(doc)
# Utils like C++ linters for this codebase
add_subdirectory(util)
# check for test directory and add tests if it exists (won't exist in release tarball)
-if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
- # Support for C++ compiler unit tests
- # Needs to happen in this file for ctest to work in this dir
- enable_testing()
- add_subdirectory(test)
-endif()
+# if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
+# # Support for C++ compiler unit tests
+# # Needs to happen in this file for ctest to work in this dir
+# enable_testing()
+# add_subdirectory(test)
+# endif()
diff --git a/frontend/include/chpl/framework/Context.h b/frontend/include/chpl/framework/Context.h
index 0f891965ef..587a1ea741 100644
--- a/frontend/include/chpl/framework/Context.h
+++ b/frontend/include/chpl/framework/Context.h
@@ -952,6 +952,50 @@ class Context {
*/
void queryTimingReport(std::ostream& os);
+ void finishQueryStopwatch(querydetail::QueryMapBase* base,
+ size_t depth,
+ const std::string& args,
+ querydetail::QueryTimingDuration elapsed);
+
+ template<typename... ArgTs>
+ struct ReportOnExit {
+ using Stopwatch = querydetail::QueryTimingStopwatch<ReportOnExit>;
+ Context* context = nullptr;
+ querydetail::QueryMapBase* base = nullptr;
+ const std::tuple<ArgTs...>* tupleOfArgs = nullptr;
+ bool enableQueryTiming = false;
+ size_t depth = 0;
+ bool enableQueryTimingTrace = false;
+
+ explicit ReportOnExit(Context *ctx = nullptr,
+ querydetail::QueryMapBase *base_ = nullptr,
+ const std::tuple<ArgTs...> *tup = nullptr,
+ bool enableQueryTiming_ = false, size_t dep = 0,
+ bool enableQueryTimingTrace_ = false)
+ : context(ctx), base(base_), tupleOfArgs(tup),
+ enableQueryTiming(enableQueryTiming_), depth(dep),
+ enableQueryTimingTrace(enableQueryTimingTrace_) {}
+
+ ReportOnExit(const ReportOnExit& rhs) = delete;
+ ReportOnExit(ReportOnExit&& rhs) = default;
+ ReportOnExit& operator=(const ReportOnExit& rhs) = delete;
+ ReportOnExit& operator=(ReportOnExit&& rhs) = default;
+
+ bool enabled() { return enableQueryTiming || enableQueryTimingTrace; }
+
+ void operator()(Stopwatch& stopwatch) {
+ // Return if the map is empty (to allow for default-construction).
+ if (base == nullptr) return;
+ bool enabled = enableQueryTiming || enableQueryTimingTrace;
+ if (enabled) {
+ auto elapsed = stopwatch.elapsed();
+ std::ostringstream oss;
+ if (tupleOfArgs) querydetail::queryArgsPrint(oss, *tupleOfArgs);
+ context->finishQueryStopwatch(base, depth, oss.str(), elapsed);
+ }
+ };
+ };
+
// Used in the in QUERY_BEGIN_TIMING macro. Creates a stopwatch that starts
// timing if we are enabled. And then on scope exit we conditionally stop the
// timing and add it to the total or log it.
diff --git a/frontend/include/chpl/resolution/scope-types.h b/frontend/include/chpl/resolution/scope-types.h
index 81ea24801d..75a75cd911 100644
--- a/frontend/include/chpl/resolution/scope-types.h
+++ b/frontend/include/chpl/resolution/scope-types.h
@@ -29,7 +29,7 @@
#include <unordered_map>
#include <utility>
-#include "llvm/ADT/None.h"
+// #include "llvm/ADT/None.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
diff --git a/frontend/lib/CMakeLists.txt b/frontend/lib/CMakeLists.txt
index 6d7f113938..85081d9abb 100644
--- a/frontend/lib/CMakeLists.txt
+++ b/frontend/lib/CMakeLists.txt
@@ -15,6 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+set(CMAKE_CXX_STANDARD 20)
+set(CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+file(TO_CMAKE_PATH "${CHPL_HOME}" CHPL_HOME_FIXED)
# generate a git-version.cpp file during the cmake configure step.
# If one exists, the write-git-sha script will only update it if the
@@ -23,26 +28,27 @@
find_package(Git)
if (EXISTS ${CMAKE_SOURCE_DIR}/.git AND Git_FOUND)
execute_process(COMMAND ${CHPL_CMAKE_PYTHON}
- ${CMAKE_SOURCE_DIR}/util/config/write-git-sha
- ${CMAKE_CURRENT_SOURCE_DIR}/util
+ ${CHPL_HOME_FIXED}/util/config/write-git-sha
+ ${CHPL_HOME_FIXED}/util
--build-version
- --chpl-home=${CHPL_HOME}
+ --chpl-home=${CHPL_HOME_FIXED}
)
message(VERBOSE "wrote git-version.cpp")
-elseif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/util/git-version.cpp)
+elseif(NOT EXISTS ${CHPL_HOME_FIXED}/util/git-version.cpp)
# if we are not in a git repo, or the git binary doesn't exist on this machine,
# write a git-version.cpp file (if one doesn't exist) as if CHPL_DONT_BUILD_SHA
# was set so we dont try to execute the git command
execute_process(COMMAND ${CMAKE_COMMAND} -E env CHPL_DONT_BUILD_SHA=1
${CHPL_CMAKE_PYTHON}
- ${CMAKE_SOURCE_DIR}/util/config/write-git-sha
- ${CMAKE_CURRENT_SOURCE_DIR}/util
+ ${CHPL_HOME_FIXED}/util/config/write-git-sha
+ ${CHPL_HOME_FIXED}/util
--build-version
- --chpl-home=${CHPL_HOME})
+ --chpl-home=${CHPL_HOME_FIXED})
message(VERBOSE "wrote git-version.cpp with dummy sha")
endif()
-add_library(git-sha-obj OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/util/git-version.cpp)
+
+add_library(git-sha-obj OBJECT ${CHPL_HOME_FIXED}/util/git-version.cpp)
# turn on position-independent code so we can use the same
# git-sha-obj for both a static and dynamic library
set_property(TARGET git-sha-obj PROPERTY POSITION_INDEPENDENT_CODE 1)
@@ -54,12 +60,18 @@ set_property(TARGET ChplFrontend-obj PROPERTY POSITION_INDEPENDENT_CODE 1)
# Include the public library .h files as well as any generated .h files
target_include_directories(ChplFrontend-obj PUBLIC
+ ${LLVM_INCLUDE_DIRS}
+ ${CLANG_INCLUDE_DIRS}
${CHPL_MAIN_INCLUDE_DIR}
${CHPL_INCLUDE_DIR})
# Library code can also use headers from the lib/ directory
# but these are not to be public
-target_include_directories(ChplFrontend-obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(ChplFrontend-obj PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${LLVM_INCLUDE_DIRS}
+ ${CLANG_INCLUDE_DIRS}
+)
# SHELL: is needed here to remove unwanted quotes from the list of arguments
# COMPILE_LANGUAGE:CXX is needed here to make sure we only set the flags
@@ -99,6 +111,7 @@ target_include_directories(ChplFrontend PUBLIC
${CHPL_MAIN_INCLUDE_DIR}
${CHPL_INCLUDE_DIR})
+set(CHPL_LLVM_LINK_ARGS "${LLVM_LIBRARIES}")
if (CHPL_LLVM_STATIC_DYNAMIC STREQUAL "static")
if(APPLE)
if (CHPL_LLVM_VERSION VERSION_LESS 14.0)
diff --git a/frontend/lib/resolution/InitResolver.h b/frontend/lib/resolution/InitResolver.h
index 37f2286ca9..6a08ffdc0d 100644
--- a/frontend/lib/resolution/InitResolver.h
+++ b/frontend/lib/resolution/InitResolver.h
@@ -43,7 +43,6 @@ class InitResolver {
types::QualifiedType qt;
UniqueString name;
bool isInitialized;
- FieldInitState() = default;
};
enum Phase {