Skip to content

Commit 02f5326

Browse files
Merge pull request #36805 from varungandhi-apple/vg-main
Turn on additional musttail checks for swiftc and runtime.
2 parents 5447afc + 0255156 commit 02f5326

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

include/swift/Option/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,12 @@ def user_module_version : Separate<["-"], "user-module-version">,
11931193
HelpText<"Module version specified from Swift module authors">,
11941194
MetaVarName<"<vers>">;
11951195

1196+
// LLVM verification
1197+
def skip_swifttailcc_musttail_check : Flag<["-"], "skip-swifttailcc-musttail-check">,
1198+
Flags<[HelpHidden, DoesNotAffectIncrementalBuild]>,
1199+
HelpText<"Skip additional LLVM verification that all tail calls from "
1200+
"swifttailcc->swifttailcc are marked musttail.">;
1201+
11961202
// VFS
11971203

11981204
def vfsoverlay : JoinedOrSeparate<["-"], "vfsoverlay">,

lib/Driver/ToolChains.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
323323
arguments.push_back("-enable-anonymous-context-mangled-names");
324324
}
325325

326+
if (!inputArgs.hasArg(options::OPT_skip_swifttailcc_musttail_check)) {
327+
arguments.push_back("-Xllvm");
328+
arguments.push_back("-enable-swifttailcc-musttail-check");
329+
}
330+
326331
// Pass through any subsystem flags.
327332
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
328333
inputArgs.AddAllArgs(arguments, options::OPT_Xcc);

stdlib/public/runtime/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags})
7979
list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS)
8080
list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/stdlib/include/llvm/Support -I${SWIFT_SOURCE_DIR}/include)
8181

82+
# Check that the runtime is using the async calling convention
83+
# correctly, and that musttail isn't missed by Clang/LLVM.
84+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
85+
list(APPEND swift_runtime_library_compile_flags
86+
"-mllvm" "-enable-swifttailcc-musttail-check")
87+
endif()
88+
8289
set(sdk "${SWIFT_HOST_VARIANT_SDK}")
8390
if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
8491
set(static_binary_lnk_file_list)

unittests/runtime/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,12 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
129129
swiftCore${SWIFT_PRIMARY_VARIANT_SUFFIX}
130130
${PLATFORM_TARGET_LINK_LIBRARIES}
131131
)
132+
133+
# Check that the tests are using the async calling convention
134+
# correctly, and that musttail isn't missed by Clang/LLVM.
135+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
136+
target_compile_options(SwiftRuntimeTests
137+
PUBLIC "-mllvm;-enable-swifttailcc-musttail-check")
138+
endif()
139+
132140
endif()

0 commit comments

Comments
 (0)