From 1970da96ffeba989c9326ec6779e35453cdf4759 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Thu, 14 Sep 2023 12:43:55 -0700 Subject: [PATCH 001/110] [Test] See if removing -Xcc from DOTEST_EXTRA continues to work (cherry picked from commit 54fed44b8093143bd74c695452945d851247b585) --- utils/build-script-impl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index f16b13d7bd17c..c7658ae747a0f 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -2177,7 +2177,7 @@ for host in "${ALL_HOSTS[@]}"; do LIBDISPATCH_BUILD_DIR="$(build_directory ${host} libdispatch)" FOUNDATION_BUILD_DIR=$(build_directory ${host} foundation) DOTEST_EXTRA="-I${FOUNDATION_BUILD_DIR}" - DOTEST_EXTRA="${DOTEST_EXTRA} -Xcc -F${FOUNDATION_BUILD_DIR}" + DOTEST_EXTRA="${DOTEST_EXTRA} -F${FOUNDATION_BUILD_DIR}" DOTEST_EXTRA="${DOTEST_EXTRA} -I${FOUNDATION_BUILD_DIR}/swift" DOTEST_EXTRA="${DOTEST_EXTRA} -I${LIBDISPATCH_SOURCE_DIR}" DOTEST_EXTRA="${DOTEST_EXTRA} -L${LIBDISPATCH_BUILD_DIR}" From 3107a92bb95aa6097dc275a0ae5a9c0fdb886762 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Fri, 16 Feb 2024 10:13:58 -0800 Subject: [PATCH 002/110] Add libunwind to LLVM_ENABLE_RUNTIMES We are seeing the following issue rdar://123102211 (Fix internal/next smooshbase bot's cmake error) CMake Error at /Users/buildslave/jenkins/workspace/lldb-internal-next-ios-disclosed-x86_64/llvm-project/libcxxabi/CMakeLists.txt:51 (message): LIBCXXABI_USE_LLVM_UNWINDER is set to ON, but libunwind is not specified in LLVM_ENABLE_RUNTIMES. To fix it, we need to add libunwind to the LLVM_ENABLE_RUNTIMES. --- utils/build-script-impl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index c7658ae747a0f..bc65594a55596 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -1720,7 +1720,7 @@ for host in "${ALL_HOSTS[@]}"; do libcxx) build_targets=(cxx) cmake_options=( - -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DLIBCXX_INSTALL_LIBRARY=OFF + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_INSTALL_LIBRARY=OFF "${cmake_options[@]}" "${llvm_cmake_options[@]}" ) From acd0efa67f012aa16894d7545b0fb7dad06ccf08 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 20:05:50 -0700 Subject: [PATCH 003/110] Migrate to common OptTable macros `OptTable` was a source of consistent churn due to new arguments to the `OPTION` macro. LLVM 3f092f37b7362447cbb13f5502dae4bdd5762afd extracted the handling of the common option parts (eg. an ID and an info) out into separate macros to reduce this - use those here (since unsurprisingly, more arguments were added). --- include/swift/Option/Options.h | 12 +++--------- lib/DriverTool/swift_cache_tool_main.cpp | 9 ++------- lib/FrontendTool/FrontendTool.cpp | 6 +++--- lib/Option/Options.cpp | 5 +---- .../SourceKit/tools/sourcekitd-test/TestOptions.cpp | 12 +++--------- tools/libSwiftScan/libSwiftScan.cpp | 6 +++--- unittests/DependencyScan/Features.cpp | 6 +++--- 7 files changed, 18 insertions(+), 38 deletions(-) diff --git a/include/swift/Option/Options.h b/include/swift/Option/Options.h index 0f24e0bd7d0df..b3ce193b56f73 100644 --- a/include/swift/Option/Options.h +++ b/include/swift/Option/Options.h @@ -13,13 +13,9 @@ #ifndef SWIFT_OPTION_OPTIONS_H #define SWIFT_OPTION_OPTIONS_H -#include +#include "llvm/Option/OptTable.h" -namespace llvm { -namespace opt { - class OptTable; -} -} +#include namespace swift { namespace options { @@ -49,9 +45,7 @@ namespace options { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "swift/Option/Options.inc" LastOption #undef OPTION diff --git a/lib/DriverTool/swift_cache_tool_main.cpp b/lib/DriverTool/swift_cache_tool_main.cpp index 72096cc2045c0..f79d3a811333e 100644 --- a/lib/DriverTool/swift_cache_tool_main.cpp +++ b/lib/DriverTool/swift_cache_tool_main.cpp @@ -56,9 +56,7 @@ struct OutputEntry { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "SwiftCacheToolOptions.inc" LastOption #undef OPTION @@ -72,10 +70,7 @@ enum ID { #undef PREFIX static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "SwiftCacheToolOptions.inc" #undef OPTION }; diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index ffb44e70c60d0..7e68844b61674 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -1263,9 +1263,9 @@ static bool printSwiftFeature(CompilerInstance &instance) { out << "}\n"; }; out << " \"SupportedArguments\": [\n"; -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - printSingleFrontendOpt(*table, swift::options::OPT_##ID, out); +#define OPTION(...) \ + printSingleFrontendOpt(*table, \ + swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), out); #include "swift/Option/Options.inc" #undef OPTION out << " \"LastOption\"\n"; diff --git a/lib/Option/Options.cpp b/lib/Option/Options.cpp index aeeed8dc9797d..6a159de3150ba 100644 --- a/lib/Option/Options.cpp +++ b/lib/Option/Options.cpp @@ -27,10 +27,7 @@ using namespace llvm::opt; #undef PREFIX static const llvm::opt::GenericOptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "swift/Option/Options.inc" #undef OPTION }; diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp index 69cb760afa603..2fc43eade84f2 100644 --- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp +++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +using namespace llvm::opt; using namespace sourcekitd_test; using llvm::StringRef; @@ -28,9 +29,7 @@ namespace { // Create enum with OPT_xxx values for each option in Options.td. enum Opt { OPT_INVALID = 0, -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELP, META, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "Options.inc" LastOption #undef OPTION @@ -46,12 +45,7 @@ enum Opt { // Create table mapping all options defined in Options.td. static const llvm::opt::OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, llvm::opt::Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "Options.inc" #undef OPTION }; diff --git a/tools/libSwiftScan/libSwiftScan.cpp b/tools/libSwiftScan/libSwiftScan.cpp index 1838d8bc5fb07..cb610da960ac6 100644 --- a/tools/libSwiftScan/libSwiftScan.cpp +++ b/tools/libSwiftScan/libSwiftScan.cpp @@ -617,9 +617,9 @@ swiftscan_string_set_t * swiftscan_compiler_supported_arguments_query() { std::unique_ptr table = swift::createSwiftOptTable(); std::vector frontendFlags; -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - addFrontendFlagOption(*table, swift::options::OPT_##ID, frontendFlags); +#define OPTION(...) \ + addFrontendFlagOption(*table, swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), \ + frontendFlags); #include "swift/Option/Options.inc" #undef OPTION return swift::c_string_utils::create_set(frontendFlags); diff --git a/unittests/DependencyScan/Features.cpp b/unittests/DependencyScan/Features.cpp index a35315819cb8f..89cdc1b900b46 100644 --- a/unittests/DependencyScan/Features.cpp +++ b/unittests/DependencyScan/Features.cpp @@ -45,9 +45,9 @@ TEST_F(ScanTest, TestHasArgumentQuery) { optionSet.insert(std::string(data, option.length)); } swiftscan_string_set_dispose(supported_args_set); -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - testHasOption(*table, swift::options::OPT_##ID, optionSet); +#define OPTION(...) \ + testHasOption(*table, swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), \ + optionSet); #include "swift/Option/Options.inc" #undef OPTION } From cacfd3e3ae17180b105ea804bb49eb5bf17018fc Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 13 Mar 2024 20:26:29 -0700 Subject: [PATCH 004/110] Rename llvm::support::endianness to llvm::endianness LLVM is gearing up to move to `std::endianness` and as part of that has moved `llvm::support::endianness` to `llvm::endianness` (bbdbcd83e6702f314d147a680247058a899ba261). Rename our uses. --- ...ponentialGrowthAppendingBinaryByteStream.h | 6 +- include/swift/Basic/StableHasher.h | 4 +- .../swift/Localization/LocalizationFormat.h | 14 ++- lib/AST/PluginRegistry.cpp | 8 +- lib/ClangImporter/SwiftLookupTable.cpp | 50 ++++---- lib/Frontend/CachedDiagnostics.cpp | 4 +- lib/Frontend/CompileJobCacheKey.cpp | 3 +- lib/IDE/CodeCompletionCache.cpp | 13 +- lib/Localization/LocalizationFormat.cpp | 7 +- lib/Serialization/DeserializeSIL.cpp | 6 +- lib/Serialization/ModuleFile.cpp | 37 +++--- lib/Serialization/ModuleFileCoreTableInfo.h | 112 +++++++----------- lib/Serialization/ModuleFileSharedCore.cpp | 5 +- lib/Serialization/Serialization.cpp | 62 +++++----- lib/Serialization/SerializationFormat.h | 33 ++++++ lib/Serialization/SerializeDoc.cpp | 20 ++-- lib/Serialization/SerializeSIL.cpp | 6 +- tools/libMockPlugin/MockPlugin.cpp | 7 +- tools/libSwiftScan/SwiftCaching.cpp | 2 +- 19 files changed, 208 insertions(+), 191 deletions(-) create mode 100644 lib/Serialization/SerializationFormat.h diff --git a/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h b/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h index bb48937baef9b..59df3eeb09552 100644 --- a/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h +++ b/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h @@ -23,6 +23,7 @@ #include "swift/Basic/LLVM.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/Endian.h" namespace swift { @@ -34,13 +35,14 @@ class ExponentialGrowthAppendingBinaryByteStream SmallVector Data; /// Data in the stream is always encoded in little-endian byte order. - const llvm::support::endianness Endian = llvm::support::endianness::little; + const llvm::endianness Endian = llvm::endianness::little; + public: ExponentialGrowthAppendingBinaryByteStream() = default; void reserve(size_t Size); - llvm::support::endianness getEndian() const override { return Endian; } + llvm::endianness getEndian() const override { return Endian; } llvm::Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; diff --git a/include/swift/Basic/StableHasher.h b/include/swift/Basic/StableHasher.h index 786931a74607b..9a96e25fe2059 100644 --- a/include/swift/Basic/StableHasher.h +++ b/include/swift/Basic/StableHasher.h @@ -133,7 +133,7 @@ class StableHasher final { return setBufferLength(bufLen + N); } - constexpr auto endian = llvm::support::endianness::little; + constexpr auto endian = llvm::endianness::little; compress(llvm::support::endian::read(byteBuffer, endian)); // Now reseed the buffer with the remaining bytes. @@ -146,7 +146,7 @@ class StableHasher final { typename T, typename std::enable_if::value>::type * = nullptr> void combine(T bits) { - constexpr auto endian = llvm::support::endianness::little; + constexpr auto endian = llvm::endianness::little; uint8_t buf[sizeof(T)] = {0}; bits = llvm::support::endian::byte_swap(bits, endian); std::memcpy(buf, &bits, sizeof(T)); diff --git a/include/swift/Localization/LocalizationFormat.h b/include/swift/Localization/LocalizationFormat.h index 78c6937e03ea6..23e38f0f49402 100644 --- a/include/swift/Localization/LocalizationFormat.h +++ b/include/swift/Localization/LocalizationFormat.h @@ -40,8 +40,6 @@ enum class DiagID : uint32_t; namespace diag { -using namespace llvm::support; - enum LocalizationProducerState : uint8_t { NotInitialized, Initialized, @@ -77,14 +75,15 @@ class LocalizationWriterInfo { key_type_ref key, data_type_ref data) { offset_type dataLength = static_cast(data.size()); - endian::write(out, dataLength, little); + llvm::support::endian::write(out, dataLength, + llvm::endianness::little); // No need to write the key length; it's constant. return {sizeof(key_type), dataLength}; } void EmitKey(llvm::raw_ostream &out, key_type_ref key, unsigned len) { assert(len == sizeof(key_type)); - endian::write(out, key, little); + llvm::support::endian::write(out, key, llvm::endianness::little); } void EmitData(llvm::raw_ostream &out, key_type_ref key, data_type_ref data, @@ -120,12 +119,15 @@ class LocalizationReaderInfo { static std::pair ReadKeyDataLength(const unsigned char *&data) { offset_type dataLength = - endian::readNext(data); + llvm::support::endian::readNext(data); return {sizeof(uint32_t), dataLength}; } internal_key_type ReadKey(const unsigned char *data, offset_type length) { - return endian::readNext(data); + return llvm::support::endian::readNext< + internal_key_type, llvm::endianness::little, llvm::support::unaligned>( + data); } data_type ReadData(internal_key_type Key, const unsigned char *data, diff --git a/lib/AST/PluginRegistry.cpp b/lib/AST/PluginRegistry.cpp index 3bd5d0e870291..8866492428abf 100644 --- a/lib/AST/PluginRegistry.cpp +++ b/lib/AST/PluginRegistry.cpp @@ -271,8 +271,8 @@ llvm::Error LoadedExecutablePlugin::sendMessage(llvm::StringRef message) const { size_t size = message.size(); // Write header (message size). - uint64_t header = llvm::support::endian::byte_swap( - uint64_t(size), llvm::support::endianness::little); + uint64_t header = llvm::support::endian::byte_swap(uint64_t(size), + llvm::endianness::little); writtenSize = Process->write(&header, sizeof(header)); if (writtenSize != sizeof(header)) { setStale(); @@ -304,8 +304,8 @@ llvm::Expected LoadedExecutablePlugin::waitForNextMessage() const { "failed to read plugin message header"); } - size_t size = llvm::support::endian::read( - &header, llvm::support::endianness::little); + size_t size = + llvm::support::endian::read(&header, llvm::endianness::little); // Read message. std::string message; diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index be60f796c0032..26768662963e4 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -51,6 +51,12 @@ static bool matchesExistingDecl(clang::Decl *decl, clang::Decl *existingDecl) { return false; } +template +[[nodiscard]] static inline value_type readNext(const CharT *&memory) { + return llvm::support::endian::readNext(memory); +} + namespace { class BaseNameToEntitiesTableReaderInfo; class GlobalsAsMembersTableReaderInfo; @@ -1146,14 +1152,14 @@ namespace { dataLength += (sizeof(uint64_t) * entry.DeclsOrMacros.size()); } - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write((uint8_t)key.Kind); if (key.Kind == swift::DeclBaseName::Kind::Normal) writer.OS << key.Name; @@ -1161,7 +1167,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // # of entries writer.write(data.size()); @@ -1240,14 +1246,14 @@ namespace { sizeof(uint16_t) + sizeof(uint64_t) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(static_cast(key.first) - 2); if (SwiftLookupTable::contextRequiresName(key.first)) out << key.second; @@ -1255,7 +1261,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // # of entries writer.write(data.size()); @@ -1314,7 +1320,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1356,7 +1362,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1386,7 +1392,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1423,13 +1429,13 @@ namespace { static std::pair ReadKeyDataLength(const uint8_t *&data) { - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case (uint8_t)DeclBaseName::Kind::Normal: { StringRef str(reinterpret_cast(data), @@ -1452,7 +1458,7 @@ namespace { data_type result; // # of entries. - unsigned numEntries = endian::readNext(data); + unsigned numEntries = readNext(data); result.reserve(numEntries); // Read all of the entries. @@ -1461,19 +1467,17 @@ namespace { // Read the context. entry.Context.first = - static_cast( - endian::readNext(data)); + static_cast(readNext(data)); if (SwiftLookupTable::contextRequiresName(entry.Context.first)) { - uint16_t length = endian::readNext(data); + uint16_t length = readNext(data); entry.Context.second = StringRef((const char *)data, length); data += length; } // Read the declarations and macros. - unsigned numDeclsOrMacros = - endian::readNext(data); + unsigned numDeclsOrMacros = readNext(data); while (numDeclsOrMacros--) { - auto id = endian::readNext(data); + auto id = readNext(data); entry.DeclsOrMacros.push_back(id); } @@ -1511,8 +1515,8 @@ namespace { static std::pair ReadKeyDataLength(const uint8_t *&data) { - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -1527,12 +1531,12 @@ namespace { data_type result; // # of entries. - unsigned numEntries = endian::readNext(data); + unsigned numEntries = readNext(data); result.reserve(numEntries); // Read all of the entries. while (numEntries--) { - auto id = endian::readNext(data); + auto id = readNext(data); result.push_back(id); } diff --git a/lib/Frontend/CachedDiagnostics.cpp b/lib/Frontend/CachedDiagnostics.cpp index 7d9b3b2c7dab8..ced75ac1ea2ba 100644 --- a/lib/Frontend/CachedDiagnostics.cpp +++ b/lib/Frontend/CachedDiagnostics.cpp @@ -777,7 +777,7 @@ CachingDiagnosticsProcessor::CachingDiagnosticsProcessor( // Write the uncompressed size in the end. if (!Compression.empty()) { llvm::raw_svector_ostream BufOS((SmallVectorImpl &)Compression); - llvm::support::endian::Writer Writer(BufOS, llvm::support::little); + llvm::support::endian::Writer Writer(BufOS, llvm::endianness::little); Writer.write(uint32_t(Output.size())); } @@ -825,7 +825,7 @@ CachingDiagnosticsProcessor::replayCachedDiagnostics(llvm::StringRef Buffer) { std::make_error_code(std::errc::message_size)); uint32_t UncompressedSize = - llvm::support::endian::read( + llvm::support::endian::read( Buffer.data() + Buffer.size() - sizeof(uint32_t)); StringRef CompressedData = Buffer.drop_back(sizeof(uint32_t)); diff --git a/lib/Frontend/CompileJobCacheKey.cpp b/lib/Frontend/CompileJobCacheKey.cpp index 3aa065ff2577f..d6506abfee751 100644 --- a/lib/Frontend/CompileJobCacheKey.cpp +++ b/lib/Frontend/CompileJobCacheKey.cpp @@ -94,7 +94,8 @@ swift::createCompileJobCacheKeyForOutput(llvm::cas::ObjectStore &CAS, // CacheKey is the index of the producting input + the base key. // Encode the unsigned value as little endian in the field. - llvm::support::endian::write(OS, InputIndex, llvm::support::little); + llvm::support::endian::write(OS, InputIndex, + llvm::endianness::little); return CAS.storeFromString({BaseKey}, OS.str()); } diff --git a/lib/IDE/CodeCompletionCache.cpp b/lib/IDE/CodeCompletionCache.cpp index ef91184bd29d8..d52e64ec42268 100644 --- a/lib/IDE/CodeCompletionCache.cpp +++ b/lib/IDE/CodeCompletionCache.cpp @@ -304,8 +304,7 @@ static bool readCachedModule(llvm::MemoryBuffer *in, static void writeCachedModule(llvm::raw_ostream &out, const CodeCompletionCache::Key &K, CodeCompletionCache::Value &V) { - using namespace llvm::support; - endian::Writer LE(out, little); + llvm::support::endian::Writer LE(out, llvm::endianness::little); // HEADER // Metadata required for reading the completions. @@ -321,7 +320,7 @@ static void writeCachedModule(llvm::raw_ostream &out, llvm::raw_svector_ostream OSS(scratch); OSS << K.ModuleFilename << "\0"; OSS << K.ModuleName << "\0"; - endian::Writer OSSLE(OSS, little); + llvm::support::endian::Writer OSSLE(OSS, llvm::endianness::little); OSSLE.write(K.AccessPath.size()); for (StringRef p : K.AccessPath) OSS << p << "\0"; @@ -340,7 +339,7 @@ static void writeCachedModule(llvm::raw_ostream &out, llvm::raw_string_ostream results(results_); std::string chunks_; llvm::raw_string_ostream chunks(chunks_); - endian::Writer chunksLE(chunks, little); + llvm::support::endian::Writer chunksLE(chunks, llvm::endianness::little); std::string strings_; llvm::raw_string_ostream strings(strings_); llvm::StringMap knownStrings; @@ -356,7 +355,7 @@ static void writeCachedModule(llvm::raw_ostream &out, return found->second; } auto size = strings.tell(); - endian::Writer LE(strings, little); + llvm::support::endian::Writer LE(strings, llvm::endianness::little); LE.write(static_cast(str.size())); strings << str; knownStrings[str] = size; @@ -381,7 +380,7 @@ static void writeCachedModule(llvm::raw_ostream &out, } auto size = types.tell(); - endian::Writer LE(types, little); + llvm::support::endian::Writer LE(types, llvm::endianness::little); StringRef USR = type->getUSR(); LE.write(static_cast(USR.size())); types << USR; @@ -414,7 +413,7 @@ static void writeCachedModule(llvm::raw_ostream &out, // RESULTS { - endian::Writer LE(results, little); + llvm::support::endian::Writer LE(results, llvm::endianness::little); for (const ContextFreeCodeCompletionResult *R : V.Results) { // FIXME: compress bitfield LE.write(static_cast(R->getKind())); diff --git a/lib/Localization/LocalizationFormat.cpp b/lib/Localization/LocalizationFormat.cpp index ccd566b1409e9..016c48633d59b 100644 --- a/lib/Localization/LocalizationFormat.cpp +++ b/lib/Localization/LocalizationFormat.cpp @@ -64,11 +64,11 @@ bool SerializedLocalizationWriter::emit(llvm::StringRef filePath) { offset_type offset; { - llvm::support::endian::write(OS, 0, llvm::support::little); + llvm::support::endian::write(OS, 0, llvm::endianness::little); offset = generator.Emit(OS); } OS.seek(0); - llvm::support::endian::write(OS, offset, llvm::support::little); + llvm::support::endian::write(OS, offset, llvm::endianness::little); OS.close(); return OS.has_error(); @@ -116,7 +116,8 @@ SerializedLocalizationProducer::SerializedLocalizationProducer( bool SerializedLocalizationProducer::initializeImpl() { auto base = reinterpret_cast(Buffer.get()->getBufferStart()); - auto tableOffset = endian::read(base, little); + auto tableOffset = + llvm::support::endian::read(base, llvm::endianness::little); SerializedTable.reset(SerializedLocalizationTable::Create( base + tableOffset, base + sizeof(offset_type), base)); return true; diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index 09cca5520bc90..d53822eba4346 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -13,12 +13,12 @@ #define DEBUG_TYPE "deserialize" #include "DeserializeSIL.h" - #include "BCReadingExtras.h" #include "DeserializationErrors.h" #include "ModuleFile.h" #include "SILFormat.h" #include "SILSerializationFunctionBuilder.h" +#include "SerializationFormat.h" #include "swift/AST/DiagnosticsSIL.h" #include "swift/AST/GenericSignature.h" @@ -143,14 +143,14 @@ class SILDeserializer::FuncTableInfo { internal_key_type ReadKey(const uint8_t *data, unsigned length) { assert(length == sizeof(uint32_t) && "Expect a single IdentifierID."); - IdentifierID keyID = endian::readNext(data); + IdentifierID keyID = readNext(data); return MF.getIdentifierText(keyID); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { assert(length == sizeof(uint32_t) && "Expect a single DeclID."); - data_type result = endian::readNext(data); + data_type result = readNext(data); return result; } }; diff --git a/lib/Serialization/ModuleFile.cpp b/lib/Serialization/ModuleFile.cpp index 0542ce66aefef..637164e0e49bc 100644 --- a/lib/Serialization/ModuleFile.cpp +++ b/lib/Serialization/ModuleFile.cpp @@ -11,15 +11,14 @@ //===----------------------------------------------------------------------===// #include "ModuleFile.h" -#include "ModuleFileCoreTableInfo.h" #include "BCReadingExtras.h" #include "DeserializationErrors.h" +#include "ModuleFileCoreTableInfo.h" #include "ModuleFormat.h" -#include "swift/Serialization/SerializationOptions.h" -#include "swift/Subsystems.h" -#include "swift/AST/DiagnosticsSema.h" +#include "SerializationFormat.h" #include "swift/AST/ASTContext.h" #include "swift/AST/ASTMangler.h" +#include "swift/AST/DiagnosticsSema.h" #include "swift/AST/GenericSignature.h" #include "swift/AST/ModuleLoader.h" #include "swift/AST/NameLookup.h" @@ -27,7 +26,9 @@ #include "swift/AST/USRGeneration.h" #include "swift/Basic/Range.h" #include "swift/ClangImporter/ClangImporter.h" +#include "swift/Serialization/SerializationOptions.h" #include "swift/Serialization/SerializedModuleLoader.h" +#include "swift/Subsystems.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/MemoryBuffer.h" @@ -1120,7 +1121,7 @@ void ModuleFile::collectBasicSourceFileInfo( auto *End = Core->SourceFileListData.bytes_end(); while (Cursor < End) { // FilePath (byte offset in 'SourceLocsTextData'). - auto fileID = endian::readNext(Cursor); + auto fileID = readNext(Cursor); // InterfaceHashIncludingTypeMembers (fixed length string). auto fpStrIncludingTypeMembers = StringRef{reinterpret_cast(Cursor), @@ -1133,9 +1134,9 @@ void ModuleFile::collectBasicSourceFileInfo( Cursor += Fingerprint::DIGEST_LENGTH; // LastModified (nanoseconds since epoch). - auto timestamp = endian::readNext(Cursor); + auto timestamp = readNext(Cursor); // FileSize (num of bytes). - auto fileSize = endian::readNext(Cursor); + auto fileSize = readNext(Cursor); assert(fileID < Core->SourceLocsTextData.size()); auto filePath = Core->SourceLocsTextData.substr(fileID); @@ -1165,8 +1166,7 @@ void ModuleFile::collectBasicSourceFileInfo( } static StringRef readLocString(const char *&Data, StringRef StringData) { - auto Str = - StringData.substr(endian::readNext(Data)); + auto Str = StringData.substr(readNext(Data)); size_t TerminatorOffset = Str.find('\0'); assert(TerminatorOffset != StringRef::npos && "unterminated string data"); return Str.slice(0, TerminatorOffset); @@ -1174,13 +1174,13 @@ static StringRef readLocString(const char *&Data, StringRef StringData) { static void readRawLoc(ExternalSourceLocs::RawLoc &Loc, const char *&Data, StringRef StringData) { - Loc.Offset = endian::readNext(Data); - Loc.Line = endian::readNext(Data); - Loc.Column = endian::readNext(Data); + Loc.Offset = readNext(Data); + Loc.Line = readNext(Data); + Loc.Column = readNext(Data); - Loc.Directive.Offset = endian::readNext(Data); - Loc.Directive.LineOffset = endian::readNext(Data); - Loc.Directive.Length = endian::readNext(Data); + Loc.Directive.Offset = readNext(Data); + Loc.Directive.LineOffset = readNext(Data); + Loc.Directive.Length = readNext(Data); Loc.Directive.Name = readLocString(Data, StringData); } @@ -1225,19 +1225,18 @@ ModuleFile::getExternalRawLocsForDecl(const Decl *D) const { ExternalSourceLocs::RawLocs Result; Result.SourceFilePath = readLocString(Record, Core->SourceLocsTextData); - const auto DocRangesOffset = - endian::readNext(Record); + const auto DocRangesOffset = readNext(Record); if (DocRangesOffset) { assert(!Core->DocRangesData.empty()); const auto *Data = Core->DocRangesData.data() + DocRangesOffset; - const auto NumLocs = endian::readNext(Data); + const auto NumLocs = readNext(Data); assert(NumLocs); for (uint32_t I = 0; I < NumLocs; ++I) { auto &Range = Result.DocRanges.emplace_back(ExternalSourceLocs::RawLoc(), 0); readRawLoc(Range.first, Data, Core->SourceLocsTextData); - Range.second = endian::readNext(Data); + Range.second = readNext(Data); } } diff --git a/lib/Serialization/ModuleFileCoreTableInfo.h b/lib/Serialization/ModuleFileCoreTableInfo.h index 659cfd0344b1a..a48672d2666d3 100644 --- a/lib/Serialization/ModuleFileCoreTableInfo.h +++ b/lib/Serialization/ModuleFileCoreTableInfo.h @@ -13,8 +13,9 @@ #ifndef SWIFT_SERIALIZATION_MODULEFILECORETABLEINFO_H #define SWIFT_SERIALIZATION_MODULEFILECORETABLEINFO_H -#include "ModuleFileSharedCore.h" #include "DocFormat.h" +#include "ModuleFileSharedCore.h" +#include "SerializationFormat.h" #include "SourceInfoFormat.h" #include "swift/AST/RawComment.h" #include "llvm/Support/DJB.h" @@ -51,16 +52,14 @@ class ModuleFileSharedCore::DeclTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { using namespace swift::serialization; - using namespace llvm::support; - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case static_cast(DeclNameKind::Normal): { StringRef str(reinterpret_cast(data), @@ -78,11 +77,10 @@ class ModuleFileSharedCore::DeclTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { uint8_t kind = *data++; - DeclID offset = endian::readNext(data); + DeclID offset = readNext(data); result.push_back({ kind, offset }); length -= 5; } @@ -114,9 +112,8 @@ class ModuleFileSharedCore::ExtensionTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -126,14 +123,12 @@ class ModuleFileSharedCore::ExtensionTableInfo { data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; const uint8_t *limit = data + length; while (data < limit) { - DeclID offset = endian::readNext(data); + DeclID offset = readNext(data); - int32_t nameIDOrLength = - endian::readNext(data); + int32_t nameIDOrLength = readNext(data); StringRef moduleNameOrMangledBase; if (nameIDOrLength < 0) { StringRef moduleName = Core.getModuleNameFromID(-nameIDOrLength); @@ -180,8 +175,7 @@ class ModuleFileSharedCore::LocalDeclTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); return { keyLength, sizeof(uint32_t) }; } @@ -191,8 +185,7 @@ class ModuleFileSharedCore::LocalDeclTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } }; @@ -217,9 +210,8 @@ class ModuleFileSharedCore::NestedTypeDeclsTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -229,11 +221,10 @@ class ModuleFileSharedCore::NestedTypeDeclsTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { - DeclID parentID = endian::readNext(data); - DeclID childID = endian::readNext(data); + DeclID parentID = readNext(data); + DeclID childID = readNext(data); result.push_back({ parentID, childID }); length -= sizeof(uint32_t) * 2; } @@ -277,15 +268,13 @@ class ModuleFileSharedCore::DeclMemberNamesTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); return { keyLength, sizeof(uint32_t) }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { using namespace swift::serialization; - using namespace llvm::support; - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case static_cast(DeclNameKind::Normal): { StringRef str(reinterpret_cast(data), @@ -305,9 +294,8 @@ class ModuleFileSharedCore::DeclMemberNamesTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; assert(length == sizeof(uint32_t)); - return endian::readNext(data); + return readNext(data); } }; @@ -338,22 +326,19 @@ class ModuleFileSharedCore::DeclMembersTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned dataLength = endian::readNext(data); + unsigned dataLength = readNext(data); return { sizeof(uint32_t), dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { - DeclID declID = endian::readNext(data); + DeclID declID = readNext(data); result.push_back(declID); length -= sizeof(uint32_t); } @@ -384,9 +369,8 @@ class ModuleFileSharedCore::ObjCMethodTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -396,13 +380,12 @@ class ModuleFileSharedCore::ObjCMethodTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; const constexpr auto recordSize = sizeof(uint32_t) + 1 + sizeof(uint32_t); data_type result; while (length > 0) { - unsigned ownerLen = endian::readNext(data); + unsigned ownerLen = readNext(data); bool isInstanceMethod = *data++ != 0; - DeclID methodID = endian::readNext(data); + DeclID methodID = readNext(data); std::string ownerName((const char *)data, ownerLen); result.push_back( std::make_tuple(std::move(ownerName), isInstanceMethod, methodID)); @@ -438,9 +421,8 @@ class ModuleFileSharedCore::DerivativeFunctionConfigTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return {keyLength, dataLength}; } @@ -450,12 +432,11 @@ class ModuleFileSharedCore::DerivativeFunctionConfigTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; const uint8_t *limit = data + length; while (data < limit) { - DeclID genSigId = endian::readNext(data); - int32_t nameLength = endian::readNext(data); + DeclID genSigId = readNext(data); + int32_t nameLength = readNext(data); std::string mangledName(reinterpret_cast(data), nameLength); data += nameLength; result.push_back({std::string(mangledName), genSigId}); @@ -491,9 +472,8 @@ class ModuleFileSharedCore::DeclCommentTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -503,29 +483,27 @@ class ModuleFileSharedCore::DeclCommentTableInfo { data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result = std::make_unique(); { - unsigned BriefSize = endian::readNext(data); + unsigned BriefSize = readNext(data); result->Info.Brief = StringRef(reinterpret_cast(data), BriefSize); data += BriefSize; } - unsigned NumComments = endian::readNext(data); + unsigned NumComments = readNext(data); for (unsigned i = 0; i != NumComments; ++i) { - unsigned StartColumn = - endian::readNext(data); - unsigned RawSize = endian::readNext(data); + unsigned StartColumn = readNext(data); + unsigned RawSize = readNext(data); auto RawText = StringRef(reinterpret_cast(data), RawSize); data += RawSize; result->RawCommentStore.emplace_back(RawText, StartColumn); } result->Info.Raw = RawComment(result->RawCommentStore); - result->Info.Group = endian::readNext(data); - result->Info.SourceOrder = endian::readNext(data); + result->Info.Group = readNext(data); + result->Info.SourceOrder = readNext(data); return result; } }; @@ -550,8 +528,7 @@ class ModuleFileSharedCore::DeclUSRTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); unsigned dataLength = 4; return { keyLength, dataLength }; } @@ -560,10 +537,10 @@ class ModuleFileSharedCore::DeclUSRTableInfo { return StringRef(reinterpret_cast(data), length); } - data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; + data_type ReadData(internal_key_type key, const uint8_t *data, + unsigned length) { assert(length == 4); - return endian::readNext(data); + return readNext(data); } }; @@ -588,19 +565,16 @@ class ModuleFileSharedCore::DeclFingerprintsTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; const unsigned dataLen = Fingerprint::DIGEST_LENGTH; return {sizeof(uint32_t), dataLen}; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; auto str = llvm::StringRef{reinterpret_cast(data), Fingerprint::DIGEST_LENGTH}; if (auto fp = Fingerprint::fromString(str)) diff --git a/lib/Serialization/ModuleFileSharedCore.cpp b/lib/Serialization/ModuleFileSharedCore.cpp index fe6404ebd3ef0..13dfd45a259ef 100644 --- a/lib/Serialization/ModuleFileSharedCore.cpp +++ b/lib/Serialization/ModuleFileSharedCore.cpp @@ -14,6 +14,7 @@ #include "BCReadingExtras.h" #include "DeserializationErrors.h" #include "ModuleFileCoreTableInfo.h" +#include "SerializationFormat.h" #include "swift/Basic/LangOptions.h" #include "swift/Parse/ParseVersion.h" #include "swift/Serialization/SerializedModuleLoader.h" @@ -1001,9 +1002,9 @@ ModuleFileSharedCore::readGroupTable(ArrayRef Fields, StringRef BlobData) const { auto pMap = std::make_unique>(); auto Data = reinterpret_cast(BlobData.data()); - unsigned GroupCount = endian::readNext(Data); + unsigned GroupCount = readNext(Data); for (unsigned I = 0; I < GroupCount; ++I) { - auto RawSize = endian::readNext(Data); + auto RawSize = readNext(Data); auto RawText = StringRef(reinterpret_cast(Data), RawSize); Data += RawSize; (*pMap)[I] = RawText; diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index bbafaa8d81adc..8f9dea4ba14b6 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -146,14 +146,14 @@ namespace { uint32_t dataLength = (sizeof(uint32_t) + 1) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); switch (key.getKind()) { case DeclBaseName::Kind::Normal: writer.write(static_cast(DeclNameKind::Normal)); @@ -174,7 +174,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry.first); writer.write(entry.second); @@ -230,7 +230,7 @@ namespace { dataLength += nameData; } assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -243,7 +243,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { StringRef dataToWrite; writer.write(entry.second); @@ -273,7 +273,7 @@ namespace { uint32_t keyLength = key.size(); assert(keyLength == static_cast(keyLength)); uint32_t dataLength = sizeof(uint32_t); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); // No need to write the data length; it's constant. return { keyLength, dataLength }; @@ -286,7 +286,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data); } }; @@ -315,7 +315,7 @@ namespace { assert(keyLength == static_cast(keyLength)); uint32_t dataLength = (sizeof(uint32_t) * 2) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -329,7 +329,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry.first); writer.write(entry.second); @@ -370,14 +370,14 @@ namespace { } assert(keyLength == static_cast(keyLength)); uint32_t dataLength = sizeof(uint32_t); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); // No need to write dataLength, it's constant. return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); switch (key.getKind()) { case DeclBaseName::Kind::Normal: writer.write(static_cast(DeclNameKind::Normal)); @@ -398,7 +398,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(bitOffsetFitsIn32Bits(), "BitOffset too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(static_cast(data)); } }; @@ -423,7 +423,7 @@ namespace { // with the same DeclBaseName. Seems highly unlikely. assert((data.size() < (1 << 14)) && "Too many members"); uint32_t dataLength = sizeof(uint32_t) * data.size(); // value DeclIDs - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // No need to write the key length; it's constant. writer.write(dataLength); return { sizeof(uint32_t), dataLength }; @@ -432,14 +432,14 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == sizeof(uint32_t)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(key); } void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry); } @@ -463,7 +463,7 @@ namespace { std::pair EmitKeyDataLength(raw_ostream &out, key_type_ref key, data_type_ref data) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // No need to write the key or value length; they're both constant. const unsigned valueLen = Fingerprint::DIGEST_LENGTH; return {sizeof(uint32_t), valueLen}; @@ -472,7 +472,7 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == sizeof(uint32_t)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(key); } @@ -480,7 +480,7 @@ namespace { unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == Fingerprint::DIGEST_LENGTH); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); out << data; } }; @@ -6196,7 +6196,7 @@ static void writeDeclTable(const index_block::DeclListLayout &DeclList, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6222,7 +6222,7 @@ writeExtensionTable(const index_block::ExtensionTableLayout &ExtensionTable, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -6238,7 +6238,7 @@ static void writeLocalDeclTable(const index_block::DeclListLayout &DeclList, { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6258,7 +6258,7 @@ writeNestedTypeDeclsTable(const index_block::NestedTypeDeclsLayout &declList, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6283,7 +6283,7 @@ writeDeclMemberNamesTable(const index_block::DeclMemberNamesLayout &declNames, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6303,7 +6303,7 @@ writeDeclMembersTable(const decl_member_tables_block::DeclMembersLayout &mems, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6324,7 +6324,7 @@ writeDeclFingerprintsTable(const index_block::DeclFingerprintsLayout &fpl, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6360,7 +6360,7 @@ namespace { dataLength += std::get<0>(entry).size(); } - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -6377,7 +6377,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (const auto &entry : data) { writer.write(std::get<0>(entry).size()); writer.write(std::get<1>(entry)); @@ -6410,7 +6410,7 @@ static void writeObjCMethodTable(const index_block::ObjCMethodTableLayout &out, } // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6443,7 +6443,7 @@ namespace { for (auto entry : data) dataLength += entry.first.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -6456,7 +6456,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto &entry : data) { // Write `GenericSignatureID`. writer.write(entry.second); @@ -6481,7 +6481,7 @@ static void writeDerivativeFunctionConfigs( for (auto &entry : derivativeConfigs) generator.insert(entry.first.get(), entry.second); // Make sure that no bucket is at offset 0. - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } SmallVector scratch; diff --git a/lib/Serialization/SerializationFormat.h b/lib/Serialization/SerializationFormat.h new file mode 100644 index 0000000000000..867b5baa62215 --- /dev/null +++ b/lib/Serialization/SerializationFormat.h @@ -0,0 +1,33 @@ +//===--- SerializationFormat.h - Serialization helpers ------ ---*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Various helper functions to deal with common serialization functionality. +/// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_SERIALIZATION_SERIALIZATIONFORMAT_H +#define SWIFT_SERIALIZATION_SERIALIZATIONFORMAT_H + +#include "llvm/ADT/bit.h" +#include "llvm/Support/Endian.h" + +namespace swift { + +template +[[nodiscard]] inline value_type readNext(const CharT *&memory) { + return llvm::support::endian::readNext(memory); +} + +} // end namespace swift + +#endif diff --git a/lib/Serialization/SerializeDoc.cpp b/lib/Serialization/SerializeDoc.cpp index 812bf48f1ddb9..a2b24af1ada69 100644 --- a/lib/Serialization/SerializeDoc.cpp +++ b/lib/Serialization/SerializeDoc.cpp @@ -232,7 +232,7 @@ class DeclCommentTableInfo { // Source order. dataLength += numLen; - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -244,7 +244,7 @@ class DeclCommentTableInfo { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data.Brief.size()); out << data.Brief; writer.write(data.Raw.Comments.size()); @@ -300,7 +300,7 @@ static void writeGroupNames(const comment_block::GroupNamesLayout &GroupNames, ArrayRef Names) { llvm::SmallString<32> Blob; llvm::raw_svector_ostream BlobStream(Blob); - endian::Writer Writer(BlobStream, little); + endian::Writer Writer(BlobStream, llvm::endianness::little); Writer.write(Names.size()); for (auto N : Names) { Writer.write(N.size()); @@ -447,7 +447,7 @@ static void writeDeclCommentTable( { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = Writer.generator.Emit(blobStream); } @@ -519,7 +519,7 @@ class USRTableInfo { const unsigned numLen = 4; uint32_t keyLength = key.size(); uint32_t dataLength = numLen; - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); return { keyLength, dataLength }; } @@ -530,7 +530,7 @@ class USRTableInfo { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data); } }; @@ -560,7 +560,7 @@ class DeclUSRsTableWriter { { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } USRsList.emit(scratch, tableOffset, hashTableBlob); @@ -637,7 +637,7 @@ class DocRangeWriter { } llvm::raw_svector_ostream OS(Buffer); - endian::Writer Writer(OS, little); + endian::Writer Writer(OS, llvm::endianness::little); Writer.write(DocRanges.size()); for (const auto &DocRange : DocRanges) { writeRawLoc(DocRange.first, Writer, Strings); @@ -719,7 +719,7 @@ struct BasicDeclLocsTableWriter : public ASTWalker { llvm::sys::fs::make_absolute(AbsolutePath); llvm::raw_svector_ostream Out(Buffer); - endian::Writer Writer(Out, little); + endian::Writer Writer(Out, llvm::endianness::little); Writer.write(FWriter.getTextOffset(AbsolutePath.str())); Writer.write( DocWriter.getDocRangesOffset(D, llvm::ArrayRef(RawLocs->DocRanges))); @@ -782,7 +782,7 @@ static void emitFileListRecord(llvm::BitstreamWriter &Out, .count(); llvm::raw_svector_ostream out(Buffer); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // FilePath. writer.write(fileID); diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index e34537a7083b5..97713d2d6f0d6 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -147,12 +147,12 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { uint32_t keyID = S.addUniquedStringRef(key); - endian::write(out, keyID, little); + endian::write(out, keyID, llvm::endianness::little); } void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::write(out, data, little); + endian::write(out, data, llvm::endianness::little); } }; @@ -2791,7 +2791,7 @@ static void writeIndexTable(Serializer &S, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0. - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, tableInfo); } SmallVector scratch; diff --git a/tools/libMockPlugin/MockPlugin.cpp b/tools/libMockPlugin/MockPlugin.cpp index 73fd6ef260be3..17a6d15771520 100644 --- a/tools/libMockPlugin/MockPlugin.cpp +++ b/tools/libMockPlugin/MockPlugin.cpp @@ -203,7 +203,7 @@ int TestRunner::run() { // Read request data. auto request_size = llvm::support::endian::byte_swap( - request_header, llvm::support::endianness::little); + request_header, llvm::endianness::little); llvm::SmallVector request_data; request_data.assign(request_size, 0); ioSize = fread(request_data.data(), request_size, 1, stdin); @@ -240,8 +240,9 @@ int TestRunner::run() { llvm::SmallVector response_data; llvm::raw_svector_ostream(response_data) << response; auto response_size = response_data.size(); - auto response_header = llvm::support::endian::byte_swap< - uint64_t, llvm::support::endianness::little>(response_size); + auto response_header = + llvm::support::endian::byte_swap( + response_size); ioSize = fwrite(&response_header, sizeof(response_header), 1, stdout); if (!ioSize) { llvm::errs() << "failed to write response header\n"; diff --git a/tools/libSwiftScan/SwiftCaching.cpp b/tools/libSwiftScan/SwiftCaching.cpp index a42e6bf5bbdef..8cdb92692a18b 100644 --- a/tools/libSwiftScan/SwiftCaching.cpp +++ b/tools/libSwiftScan/SwiftCaching.cpp @@ -405,7 +405,7 @@ createCachedCompilation(SwiftScanCAS &CAS, const llvm::cas::CASID &ID, auto Input = KeyProxy->getData(); unsigned Index = - llvm::support::endian::read(Input.data()); { swift::cas::CompileJobResultSchema Schema(CAS.getCAS()); From 0f52071c22b6a13a70775e3cf9958ccc3dd10e68 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 19:23:25 -0700 Subject: [PATCH 005/110] Fix up various references to renamed/moved enums A bunch of enums were moved to enum classes and slightly renamed. Fix up their references. --- lib/AST/ClangTypeConverter.cpp | 18 +++++++++--------- lib/ClangImporter/ClangAdapter.cpp | 2 +- lib/ClangImporter/ImportDecl.cpp | 20 +++++++++++--------- lib/DriverTool/swift_llvm_opt_main.cpp | 6 +++--- lib/IRGen/IRGen.cpp | 10 +++++----- lib/Immediate/SwiftMaterializationUnit.cpp | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index 85ae8f62458ab..05623b66a2d39 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -227,7 +227,7 @@ clang::QualType ClangTypeConverter::convertMemberType(NominalTypeDecl *DC, // we could recover in some other way. static clang::QualType getClangVectorType(const clang::ASTContext &ctx, clang::BuiltinType::Kind eltKind, - clang::VectorType::VectorKind vecKind, + clang::VectorKind vecKind, StringRef numEltsString) { unsigned numElts; bool failedParse = numEltsString.getAsInteger(10, numElts); @@ -268,11 +268,11 @@ clang::QualType ClangTypeConverter::visitStructType(StructType *type) { #undef CHECK_NAMED_TYPE // Map vector types to the corresponding C vectors. -#define MAP_SIMD_TYPE(TYPE_NAME, _, BUILTIN_KIND) \ - if (name.starts_with(#TYPE_NAME)) { \ - return getClangVectorType(ctx, clang::BuiltinType::BUILTIN_KIND, \ - clang::VectorType::GenericVector, \ - name.drop_front(sizeof(#TYPE_NAME)-1)); \ +#define MAP_SIMD_TYPE(TYPE_NAME, _, BUILTIN_KIND) \ + if (name.starts_with(#TYPE_NAME)) { \ + return getClangVectorType(ctx, clang::BuiltinType::BUILTIN_KIND, \ + clang::VectorKind::Generic, \ + name.drop_front(sizeof(#TYPE_NAME) - 1)); \ } #include "swift/ClangImporter/SIMDMappedTypes.def" @@ -427,8 +427,8 @@ clang::QualType ClangTypeConverter::visitTupleType(TupleType *type) { return clang::QualType(); APInt size(32, tupleNumElements); - return ClangASTContext.getConstantArrayType(clangEltTy, size, nullptr, - clang::ArrayType::Normal, 0); + return ClangASTContext.getConstantArrayType( + clangEltTy, size, nullptr, clang::ArraySizeModifier::Normal, 0); } clang::QualType ClangTypeConverter::visitProtocolType(ProtocolType *type) { @@ -617,7 +617,7 @@ ClangTypeConverter::visitBoundGenericType(BoundGenericType *type) { return clang::QualType(); (void) failedParse; auto vectorTy = ClangASTContext.getVectorType(scalarTy, numElts, - clang::VectorType::VectorKind::GenericVector); + clang::VectorKind::Generic); return vectorTy; } } diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index c96e41f26b333..4c02ab936b3bd 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -776,7 +776,7 @@ OptionalTypeKind importer::getParamOptionality(const clang::ParmVarDecl *param, // Check for the 'static' annotation on C arrays. if (const auto *DT = dyn_cast(paramTy)) if (const auto *AT = DT->getOriginalType()->getAsArrayTypeUnsafe()) - if (AT->getSizeModifier() == clang::ArrayType::Static) + if (AT->getSizeModifier() == clang::ArraySizeModifier::Static) return OTK_None; // Default to implicitly unwrapped optionals. diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index e4d94f74d692a..d6947950c80db 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -4583,7 +4583,8 @@ namespace { : getOverridableAccessLevel(dc)); // Optional methods in protocols. - if (decl->getImplementationControl() == clang::ObjCMethodDecl::Optional && + if (decl->getImplementationControl() == + clang::ObjCImplementationControl::Optional && isa(dc)) result->getAttrs().add(new (Impl.SwiftContext) OptionalAttr(/*implicit*/false)); @@ -5487,8 +5488,9 @@ namespace { if (decl->hasAttr()) result->getAttrs().add( new (Impl.SwiftContext) IBOutletAttr(/*IsImplicit=*/false)); - if (decl->getPropertyImplementation() == clang::ObjCPropertyDecl::Optional - && isa(dc) && + if (decl->getPropertyImplementation() == + clang::ObjCPropertyDecl::Optional && + isa(dc) && !result->getAttrs().hasAttribute()) result->getAttrs().add(new (Impl.SwiftContext) OptionalAttr(/*implicit*/false)); @@ -7018,7 +7020,7 @@ SwiftDeclConverter::importSubscript(Decl *decl, // Find the counterpart. bool optionalMethods = (objcMethod->getImplementationControl() == - clang::ObjCMethodDecl::Optional); + clang::ObjCImplementationControl::Optional); if (auto *counterpart = findCounterpart(counterpartSelector)) { const clang::ObjCMethodDecl *counterpartMethod = nullptr; @@ -7032,7 +7034,7 @@ SwiftDeclConverter::importSubscript(Decl *decl, counterpartMethod = cast(importedFrom); if (optionalMethods) optionalMethods = (counterpartMethod->getImplementationControl() == - clang::ObjCMethodDecl::Optional); + clang::ObjCImplementationControl::Optional); } assert(!counterpart || !counterpart->isStatic()); @@ -8529,12 +8531,12 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl, if (auto clangProto = dyn_cast(ClangDecl->getDeclContext())) { if (auto method = dyn_cast(ClangDecl)) { - if (method->getImplementationControl() - == clang::ObjCMethodDecl::Required) + if (method->getImplementationControl() == + clang::ObjCImplementationControl::Required) hasMissingRequiredMember = true; } else if (auto prop = dyn_cast(ClangDecl)) { - if (prop->getPropertyImplementation() - == clang::ObjCPropertyDecl::Required) + if (prop->getPropertyImplementation() == + clang::ObjCPropertyDecl::Required) hasMissingRequiredMember = true; } diff --git a/lib/DriverTool/swift_llvm_opt_main.cpp b/lib/DriverTool/swift_llvm_opt_main.cpp index 17f7ae298d7a1..0acc283b74af5 100644 --- a/lib/DriverTool/swift_llvm_opt_main.cpp +++ b/lib/DriverTool/swift_llvm_opt_main.cpp @@ -114,11 +114,11 @@ static llvm::cl::opt PassPipeline( // Helper Methods //===----------------------------------------------------------------------===// -static llvm::CodeGenOpt::Level GetCodeGenOptLevel(const SwiftLLVMOptOptions &options) { +static llvm::CodeGenOptLevel GetCodeGenOptLevel(const SwiftLLVMOptOptions &options) { // TODO: Is this the right thing to do here? if (options.Optimized) - return llvm::CodeGenOpt::Default; - return llvm::CodeGenOpt::None; + return llvm::CodeGenOptLevel::Default; + return llvm::CodeGenOptLevel::None; } // Returns the TargetMachine instance or zero if no triple is provided. diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 5b412bbbc8142..92cb2bee7cbfc 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -651,8 +651,8 @@ bool swift::compileAndWriteLLVM( legacy::PassManager EmitPasses; CodeGenFileType FileType; FileType = - (opts.OutputKind == IRGenOutputKind::NativeAssembly ? CGFT_AssemblyFile - : CGFT_ObjectFile); + (opts.OutputKind == IRGenOutputKind::NativeAssembly ? CodeGenFileType::AssemblyFile + : CodeGenFileType::ObjectFile); EmitPasses.add(createTargetTransformInfoWrapperPass( targetMachine->getTargetIRAnalysis())); @@ -850,9 +850,9 @@ static void setPointerAuthOptions(PointerAuthOptions &opts, std::unique_ptr swift::createTargetMachine(const IRGenOptions &Opts, ASTContext &Ctx) { - CodeGenOpt::Level OptLevel = Opts.shouldOptimize() - ? CodeGenOpt::Default // -Os - : CodeGenOpt::None; + CodeGenOptLevel OptLevel = Opts.shouldOptimize() + ? CodeGenOptLevel::Default // -Os + : CodeGenOptLevel::None; // Set up TargetOptions and create the target features string. TargetOptions TargetOpts; diff --git a/lib/Immediate/SwiftMaterializationUnit.cpp b/lib/Immediate/SwiftMaterializationUnit.cpp index dcda3baf6c2ce..92a01bcb0d6c9 100644 --- a/lib/Immediate/SwiftMaterializationUnit.cpp +++ b/lib/Immediate/SwiftMaterializationUnit.cpp @@ -157,7 +157,7 @@ SwiftJIT::CreateLLJIT(CompilerInstance &CI) { .setOptions(std::move(TargetOpt)) .setCPU(std::move(CPU)) .addFeatures(Features) - .setCodeGenOptLevel(llvm::CodeGenOpt::Default); + .setCodeGenOptLevel(llvm::CodeGenOptLevel::Default); auto J = llvm::orc::LLJITBuilder() .setJITTargetMachineBuilder(std::move(JTMB)) .create(); From 440421bcc5549180e96e7ea7a64ed510a94ddd04 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 17:20:58 -0700 Subject: [PATCH 006/110] Rename `ThreadPool` to `StdThreadPool` `ThreadPool` was split up in LLVM 6594f428de91e333c1cbea4f55e79b18d31024c4. --- include/swift/DependencyScan/ModuleDependencyScanner.h | 2 +- tools/swift-scan-test/swift-scan-test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/swift/DependencyScan/ModuleDependencyScanner.h b/include/swift/DependencyScan/ModuleDependencyScanner.h index a8af234469f5d..00e7877becd07 100644 --- a/include/swift/DependencyScan/ModuleDependencyScanner.h +++ b/include/swift/DependencyScan/ModuleDependencyScanner.h @@ -145,7 +145,7 @@ class ModuleDependencyScanner { /// The available pool of workers for filesystem module search unsigned NumThreads; std::list> Workers; - llvm::ThreadPool ScanningThreadPool; + llvm::StdThreadPool ScanningThreadPool; /// Protect worker access. std::mutex WorkersLock; }; diff --git a/tools/swift-scan-test/swift-scan-test.cpp b/tools/swift-scan-test/swift-scan-test.cpp index 6b30f95869237..0801166bb9945 100644 --- a/tools/swift-scan-test/swift-scan-test.cpp +++ b/tools/swift-scan-test/swift-scan-test.cpp @@ -221,7 +221,7 @@ int main(int argc, char *argv[]) { auto Args = createArgs(SwiftCommands, Saver); std::atomic Ret = 0; - llvm::ThreadPool Pool(llvm::hardware_concurrency(Threads)); + llvm::StdThreadPool Pool(llvm::hardware_concurrency(Threads)); for (unsigned i = 0; i < Threads; ++i) { Pool.async([&]() { switch (Action) { From a9077d71291dbfba4bc0a6863414b8ad9ed0117e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 20:52:50 -0700 Subject: [PATCH 007/110] `FileEntry` to `FileEntryRef` updates --- lib/ClangImporter/ClangImporter.cpp | 27 ++++--- lib/ClangImporter/ImportDecl.cpp | 4 +- lib/Index/IndexRecord.cpp | 79 ++++++++----------- .../lib/SwiftLang/SwiftSourceDocInfo.cpp | 2 +- 4 files changed, 48 insertions(+), 64 deletions(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 6644b3d7871b5..e5427c0141597 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -2142,9 +2142,9 @@ ClangImporter::Implementation::lookupModule(StringRef moduleName) { if (moduleFile == PrebuiltModules.end()) return nullptr; - if (!Instance->loadModuleFile(moduleFile->second)) + clang::serialization::ModuleFile *Loaded = nullptr; + if (!Instance->loadModuleFile(moduleFile->second, Loaded)) return nullptr; // error loading, return not found. - // Lookup again. return loadFromMM(); } @@ -2310,13 +2310,15 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule( // instead, manually register all `.h` inputs of Clang module dependnecies. if (SwiftDependencyTracker && !Instance->getInvocation().getLangOpts().ImplicitModules) { - auto *moduleFile = Instance->getASTReader()->getModuleManager().lookup( - clangModule->getASTFile()); - Instance->getASTReader()->visitInputFileInfos( - *moduleFile, /*IncludeSystem=*/true, - [&](const clang::serialization::InputFileInfo &IFI, bool isSystem) { - SwiftDependencyTracker->addDependency(IFI.Filename, isSystem); - }); + if (auto moduleRef = clangModule->getASTFile()) { + auto *moduleFile = Instance->getASTReader()->getModuleManager().lookup( + *moduleRef); + Instance->getASTReader()->visitInputFileInfos( + *moduleFile, /*IncludeSystem=*/true, + [&](const clang::serialization::InputFileInfo &IFI, bool isSystem) { + SwiftDependencyTracker->addDependency(IFI.Filename, isSystem); + }); + } } if (clangModule->isSubModule()) { @@ -3906,14 +3908,13 @@ StringRef ClangModuleUnit::getFilename() const { else return SinglePCH; } - if (const clang::FileEntry *F = clangModule->getASTFile()) - if (!F->getName().empty()) - return F->getName(); + if (auto F = clangModule->getASTFile()) + return F->getName(); return StringRef(); } StringRef ClangModuleUnit::getLoadedFilename() const { - if (const clang::FileEntry *F = clangModule->getASTFile()) + if (auto F = clangModule->getASTFile()) return F->getName(); return StringRef(); } diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index d6947950c80db..5245d785f1277 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3380,7 +3380,7 @@ namespace { d->getName() == "cos" || d->getName() == "exit"; return false; }; - + if (clang::Module *owningModule = decl->getOwningModule(); owningModule && importer::isCxxStdModule(owningModule)) { if (isAlternativeCStdlibFunctionFromTextualHeader(decl)) { @@ -3388,7 +3388,7 @@ namespace { } auto &sourceManager = Impl.getClangPreprocessor().getSourceManager(); - if (const auto file = sourceManager.getFileEntryForID( + if (auto file = sourceManager.getFileEntryRefForID( sourceManager.getFileID(decl->getLocation()))) { auto filename = file->getName(); if ((file->getDir() == owningModule->Directory) && diff --git a/lib/Index/IndexRecord.cpp b/lib/Index/IndexRecord.cpp index 59be895b4eac3..678193f5ee069 100644 --- a/lib/Index/IndexRecord.cpp +++ b/lib/Index/IndexRecord.cpp @@ -484,10 +484,13 @@ static void emitSymbolicInterfaceForClangModule( return; } + auto moduleRef = clangModule->getASTFile(); + if (!moduleRef) + return; + // Determine the output name for the symbolic interface file. clang::serialization::ModuleFile *ModFile = - clangCI.getASTReader()->getModuleManager().lookup( - clangModule->getASTFile()); + clangCI.getASTReader()->getModuleManager().lookup(*moduleRef); assert(ModFile && "no module file loaded for module ?"); SmallString<128> interfaceOutputPath = indexStorePath; appendSymbolicInterfaceToIndexStorePath(interfaceOutputPath); @@ -636,7 +639,7 @@ static void addModuleDependencies(ArrayRef imports, modulePath = LFU->getSourceFilename(); } - auto F = fileMgr.getFile(modulePath); + auto F = fileMgr.getFileRef(modulePath); if (!F) break; @@ -855,17 +858,18 @@ emitDataForSwiftSerializedModule(ModuleDecl *module, IndexUnitWriter unitWriter( fileMgr, indexStorePath, "swift", swiftVersion, filename, moduleName, - /*MainFile=*/nullptr, isSystem, /*IsModuleUnit=*/true, isDebugCompilation, + /*MainFile=*/{}, isSystem, /*IsModuleUnit=*/true, isDebugCompilation, targetTriple, sysrootPath, clangRemapper, getModuleInfoFromOpaqueModule); - auto FE = fileMgr.getFile(filename); - for (auto &pair : records) { - std::string &recordFile = pair.first; - std::string &groupName = pair.second; - if (recordFile.empty()) - continue; - clang::index::writer::OpaqueModule mod = &groupName; - unitWriter.addRecordFile(recordFile, *FE, isSystem, mod); + if (auto FE = fileMgr.getFileRef(filename)) { + for (auto &pair : records) { + std::string &recordFile = pair.first; + std::string &groupName = pair.second; + if (recordFile.empty()) + continue; + clang::index::writer::OpaqueModule mod = &groupName; + unitWriter.addRecordFile(recordFile, *FE, isSystem, mod); + } } SmallVector imports; @@ -892,21 +896,25 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken, bool indexSystemModules, bool skipStdlib, bool includeLocals, bool isDebugCompilation, bool isExplicitModuleBuild, StringRef targetTriple, - ArrayRef fileDependencies, + ArrayRef fileDependencies, const clang::CompilerInstance &clangCI, const PathRemapper &pathRemapper, DiagnosticEngine &diags) { auto &fileMgr = clangCI.getFileManager(); auto *module = primarySourceFile->getParentModule(); bool isSystem = module->isNonUserModule(); - auto mainFile = fileMgr.getFile(primarySourceFile->getFilename()); auto clangRemapper = pathRemapper.asClangPathRemapper(); + + auto mainFile = fileMgr.getFileRef(primarySourceFile->getFilename()); + if (!mainFile) + return false; + // FIXME: Get real values for the following. StringRef swiftVersion; StringRef sysrootPath = clangCI.getHeaderSearchOpts().Sysroot; IndexUnitWriter unitWriter( fileMgr, indexStorePath, "swift", swiftVersion, indexUnitToken, - module->getNameStr(), mainFile ? *mainFile : nullptr, isSystem, + module->getNameStr(), *mainFile, isSystem, /*isModuleUnit=*/false, isDebugCompilation, targetTriple, sysrootPath, clangRemapper, getModuleInfoFromOpaqueModule); @@ -922,15 +930,16 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken, primarySourceFile); // File dependencies. - for (auto *F : fileDependencies) + for (auto F : fileDependencies) unitWriter.addFileDependency(F, /*FIXME:isSystem=*/false, /*Module=*/nullptr); recordSourceFile(primarySourceFile, indexStorePath, includeLocals, diags, [&](StringRef recordFile, StringRef filename) { - auto file = fileMgr.getFile(filename); - unitWriter.addRecordFile( - recordFile, file ? *file : nullptr, - module->isNonUserModule(), /*Module=*/nullptr); + if (auto file = fileMgr.getFileRef(filename)) { + unitWriter.addRecordFile( + recordFile, *file, + module->isNonUserModule(), /*Module=*/nullptr); + } }); std::string error; @@ -988,24 +997,11 @@ bool index::indexAndRecord(SourceFile *primarySourceFile, return true; } - llvm::SetVector fileDependencies; - // FIXME: This is not desirable because: - // 1. It picks shim header files as file dependencies - // 2. Having all the other swift files of the module as file dependencies ends - // up making all of them associated with all the other files as main files. - // It's better to associate each swift file with the unit that recorded it - // as the main one. - // Keeping the code in case we want to revisit. -#if 0 - auto *module = primarySourceFile->getParentModule(); - collectFileDependencies(fileDependencies, dependencyTracker, module, fileMgr); -#endif - return recordSourceFileUnit(primarySourceFile, indexUnitToken, indexStorePath, indexClangModules, indexSystemModules, skipStdlib, includeLocals, isDebugCompilation, isExplicitModuleBuild, - targetTriple, fileDependencies.getArrayRef(), + targetTriple, {}, clangCI, pathRemapper, diags); } @@ -1032,19 +1028,6 @@ bool index::indexAndRecord(ModuleDecl *module, return true; } - // Add the current module's source files to the dependencies. - llvm::SetVector fileDependencies; - // FIXME: This is not desirable because: - // 1. It picks shim header files as file dependencies - // 2. Having all the other swift files of the module as file dependencies ends - // up making all of them associated with all the other files as main files. - // It's better to associate each swift file with the unit that recorded it - // as the main one. - // Keeping the code in case we want to revisit. -#if 0 - collectFileDependencies(fileDependencies, dependencyTracker, module, fileMgr); -#endif - // Write a unit for each source file. unsigned unitIndex = 0; for (auto *F : module->getFiles()) { @@ -1057,7 +1040,7 @@ bool index::indexAndRecord(ModuleDecl *module, indexStorePath, indexClangModules, indexSystemModules, skipStdlib, includeLocals, isDebugCompilation, isExplicitModuleBuild, - targetTriple, fileDependencies.getArrayRef(), + targetTriple, {}, clangCI, pathRemapper, diags)) return true; unitIndex += 1; diff --git a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp index cc11e3b15e124..9ec7a99e4f8a3 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp @@ -864,7 +864,7 @@ static void setLocationInfoForClangNode(ClangNode ClangNode, std::pair Decomp = ClangSM.getDecomposedLoc(CharRange.getBegin()); if (!Decomp.first.isInvalid()) { - if (auto FE = ClangSM.getFileEntryForID(Decomp.first)) { + if (auto FE = ClangSM.getFileEntryRefForID(Decomp.first)) { Location.Filename = FE->getName(); std::pair EndDecomp = From 38ba0618ca25388ea0eb8ecf5edfbd31bdc811f6 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 20:48:42 -0700 Subject: [PATCH 008/110] [AST] Use erase instead of erase_value `erase_value` is now deprecated. --- include/swift/AST/PluginRegistry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/swift/AST/PluginRegistry.h b/include/swift/AST/PluginRegistry.h index 74a323e520b80..b363362689c5a 100644 --- a/include/swift/AST/PluginRegistry.h +++ b/include/swift/AST/PluginRegistry.h @@ -147,7 +147,7 @@ class LoadedExecutablePlugin { /// Remove "on reconnect" callback. void removeOnReconnect(std::function *fn) { - llvm::erase_value(onReconnect, fn); + llvm::erase(onReconnect, fn); } llvm::sys::procid_t getPid() { return Process->process.Pid; } From 2fc51affb282f79777e6860ef67410f651e0705a Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 21:09:33 -0700 Subject: [PATCH 009/110] [Basic] Handle added/removed triples Ananas/CloudABI/Contiki/Minix have all been removed from LLVM (in various commits). Also adds minimal (ie. necessary for compiling) support for the new triples. --- lib/Basic/Platform.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index c2fa1f496b5b8..ee5a5dc59f7b6 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -175,33 +175,32 @@ static StringRef getPlatformNameForDarwin(const DarwinPlatformKind platform) { StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { switch (triple.getOS()) { - case llvm::Triple::ZOS: - case llvm::Triple::Ananas: - case llvm::Triple::CloudABI: + case llvm::Triple::AIX: + case llvm::Triple::AMDHSA: + case llvm::Triple::AMDPAL: + case llvm::Triple::BridgeOS: + case llvm::Triple::CUDA: case llvm::Triple::DragonFly: case llvm::Triple::DriverKit: - case llvm::Triple::XROS: + case llvm::Triple::ELFIAMCU: case llvm::Triple::Emscripten: case llvm::Triple::Fuchsia: + case llvm::Triple::HermitCore: + case llvm::Triple::Hurd: case llvm::Triple::KFreeBSD: case llvm::Triple::Lv2: + case llvm::Triple::Mesa3D: + case llvm::Triple::NaCl: case llvm::Triple::NetBSD: + case llvm::Triple::NVCL: case llvm::Triple::PS5: + case llvm::Triple::RTEMS: + case llvm::Triple::Serenity: case llvm::Triple::ShaderModel: case llvm::Triple::Solaris: - case llvm::Triple::Minix: - case llvm::Triple::RTEMS: - case llvm::Triple::NaCl: - case llvm::Triple::AIX: - case llvm::Triple::CUDA: - case llvm::Triple::NVCL: - case llvm::Triple::AMDHSA: - case llvm::Triple::ELFIAMCU: - case llvm::Triple::Mesa3D: - case llvm::Triple::Contiki: - case llvm::Triple::AMDPAL: - case llvm::Triple::HermitCore: - case llvm::Triple::Hurd: + case llvm::Triple::Vulkan: + case llvm::Triple::XROS: + case llvm::Triple::ZOS: return ""; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: From dcd256eb4aa3cc5c3d4512e80a326ba41d939bcb Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 21:01:49 -0700 Subject: [PATCH 010/110] [Driver] Update argument to `SmallVectorImpl` instead of `std::vector` `CommandSetVector::takeVector` returns a `SmallVector` now. --- lib/Driver/Compilation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index ee4cfcc678bd4..63dd11bdbba5b 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -731,7 +731,7 @@ namespace driver { /// Create \c NumberOfParallelCommands batches and assign each job to a /// batch either filling each partition in order or, if seeded with a /// nonzero value, pseudo-randomly (but deterministically and nearly-evenly). - void partitionIntoBatches(std::vector Batchable, + void partitionIntoBatches(const llvm::SmallVectorImpl &Batchable, BatchPartition &Partition) { if (Comp.getShowJobLifecycle()) { llvm::outs() << "Found " << Batchable.size() << " batchable jobs\n"; From a2f925c439b25e8d9f132307823bc1d042270cec Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 20:59:51 -0700 Subject: [PATCH 011/110] [Driver] Fix up `AddAllArgs` The varargs method was removed in af74f06322410e867294ea3587e5884342564e5c (claimed NFC) and the `AddAllArgs` taking an `ArrayRef` was renamed to `addAllArgs` in 4eecfda50a4e7a05f448a59885d2572d0ea2f4a1. But the other `AddAllArgs` was left as is. --- lib/Driver/ToolChains.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 55dfc877f981d..9025104370f3c 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -249,7 +249,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, } inputArgs.AddAllArgs(arguments, options::OPT_I); - inputArgs.AddAllArgs(arguments, options::OPT_F, options::OPT_Fsystem); + inputArgs.addAllArgs(arguments, {options::OPT_F, options::OPT_Fsystem}); inputArgs.AddAllArgs(arguments, options::OPT_vfsoverlay); inputArgs.AddLastArg(arguments, options::OPT_AssertConfig); @@ -304,8 +304,8 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, inputArgs.AddLastArg(arguments, options::OPT_profile_generate); inputArgs.AddLastArg(arguments, options::OPT_profile_use); inputArgs.AddLastArg(arguments, options::OPT_profile_coverage_mapping); - inputArgs.AddAllArgs(arguments, options::OPT_warnings_as_errors, - options::OPT_no_warnings_as_errors); + inputArgs.addAllArgs(arguments, {options::OPT_warnings_as_errors, + options::OPT_no_warnings_as_errors}); inputArgs.AddLastArg(arguments, options::OPT_sanitize_EQ); inputArgs.AddLastArg(arguments, options::OPT_sanitize_recover_EQ); inputArgs.AddLastArg(arguments, @@ -347,9 +347,9 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, inputArgs.AddAllArgs(arguments, options::OPT_D); // Pass on file paths that should be remapped in debug info. - inputArgs.AddAllArgs(arguments, options::OPT_debug_prefix_map, - options::OPT_coverage_prefix_map, - options::OPT_file_prefix_map); + inputArgs.addAllArgs(arguments, {options::OPT_debug_prefix_map, + options::OPT_coverage_prefix_map, + options::OPT_file_prefix_map}); std::string globalRemapping = getGlobalDebugPathRemapping(); if (!globalRemapping.empty()) { @@ -1310,7 +1310,8 @@ ToolChain::constructInvocation(const REPLJobAction &job, addRuntimeLibraryFlags(context.OI, FrontendArgs); context.Args.AddLastArg(FrontendArgs, options::OPT_import_objc_header); - context.Args.AddAllArgs(FrontendArgs, options::OPT_framework, options::OPT_L); + context.Args.addAllArgs(FrontendArgs, + {options::OPT_framework, options::OPT_L}); ToolChain::addLinkedLibArgs(context.Args, FrontendArgs); if (!useLLDB) { From 7d620bf7503cfa38cee99030cc82f3d63fc5aabd Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 25 Mar 2024 21:39:47 -0700 Subject: [PATCH 012/110] [ClangImporter] Add empty visit implementation for new types Two new unhandled types: `PackIndexingType` and `CountAttributedType`. --- lib/ClangImporter/ImportType.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 5ec05b36802eb..6559745f53f25 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -1264,6 +1264,14 @@ namespace { return { importedType, ImportHint::ObjCPointer }; } + + ImportResult VisitPackIndexingType(const clang::PackIndexingType *type) { + return Type(); + } + + ImportResult VisitCountAttributedType(const clang::CountAttributedType *type) { + return Type(); + } }; } // end anonymous namespace From 96c339d75af69252c67d505000d0658237d8d8e7 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 20:46:39 -0700 Subject: [PATCH 013/110] [ClangImporter] Rename `mangleTypeName` to `mangleCanonicalTypeName` LLVM 9c89b29555a7ccfc3942340f558c3bbea8d10532 changed `mangleTypeName` to instead mangle the canonical type name and thus also changed the method name. --- lib/AST/ASTMangler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index f6194e40099d2..bfeb6b2ef548f 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -3026,7 +3026,7 @@ void ASTMangler::appendClangType(FnType *fn, llvm::raw_svector_ostream &out) { fn->getASTContext().getClangModuleLoader()->getClangASTContext(); std::unique_ptr mangler{ clang::ItaniumMangleContext::create(clangCtx, clangCtx.getDiagnostics())}; - mangler->mangleTypeName(clang::QualType(clangType, 0), scratchOS); + mangler->mangleCanonicalTypeName(clang::QualType(clangType, 0), scratchOS); out << scratchOS.str().size() << scratchOS.str(); } From a30de11b893ac6cf3797aa7d93fb480d72ecd9f1 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 21 Mar 2024 20:07:47 -0700 Subject: [PATCH 014/110] [ClangImporter] Add missing include for `llvm::size` Presumably this was previously transitively included, who knows from where. --- lib/ClangImporter/ImportDecl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 5245d785f1277..52ac18ccf499b 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -59,6 +59,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Sema/Lookup.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" From b33055038eb8601d000b5605e093730cd5cf360e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 21 Mar 2024 20:18:45 -0700 Subject: [PATCH 015/110] [ClangImporter] Add `readDeclAs` reader implementation --- include/swift/ClangImporter/SwiftAbstractBasicReader.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/swift/ClangImporter/SwiftAbstractBasicReader.h b/include/swift/ClangImporter/SwiftAbstractBasicReader.h index 0889de8d9cc39..b5df306987b43 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicReader.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicReader.h @@ -94,6 +94,11 @@ class DataStreamBasicReader llvm::report_fatal_error("Read BTFTypeTagAttr that should never have been" " serialized"); } + + template + T *readDeclAs() { + return asImpl().template readDeclAs(); + } }; } From 0c0c4ea7c33b4c71a90c2139088ac8e1f7d4b51e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 21 Mar 2024 20:25:59 -0700 Subject: [PATCH 016/110] [ClangImporter] Use new `CXXThisExpr::Create` function The constructor takes a new arg which `Create` now handles. Use it instead. --- lib/ClangImporter/ClangDerivedConformances.cpp | 4 ++-- lib/ClangImporter/ClangImporter.cpp | 6 +++--- lib/ClangImporter/SwiftDeclSynthesizer.cpp | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ClangImporter/ClangDerivedConformances.cpp b/lib/ClangImporter/ClangDerivedConformances.cpp index 9219140eff63e..eaea4af632c2e 100644 --- a/lib/ClangImporter/ClangDerivedConformances.cpp +++ b/lib/ClangImporter/ClangDerivedConformances.cpp @@ -264,8 +264,8 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl, clang::UnresolvedSet<1> ops; auto qualType = clang::QualType(classDecl->getTypeForDecl(), 0); - auto arg = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), qualType, false); + auto arg = clang::CXXThisExpr::Create(clangCtx, clang::SourceLocation(), + qualType, false); arg->setType(clang::QualType(classDecl->getTypeForDecl(), 0)); clang::OverloadedOperatorKind opKind = diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index e5427c0141597..f2c956d623ea4 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -5211,9 +5211,9 @@ static clang::CXXMethodDecl *synthesizeCxxBaseGetterAccessorMethod( // Returns the expression that accesses the base field from derived type. auto createFieldAccess = [&]() -> clang::Expr * { - auto *thisExpr = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), newMethod->getThisType(), - /*IsImplicit=*/false); + auto *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); clang::QualType baseClassPtr = clangCtx.getRecordType(baseClass); baseClassPtr.addConst(); baseClassPtr = clangCtx.getPointerType(baseClassPtr); diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index 3391ed98f93c3..5ab4a9037bef5 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -2114,8 +2114,9 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( auto diagState = clangSema.DelayedDiagnostics.push(diagPool); // Construct the method's body. - clang::Expr *thisExpr = new (clangCtx) clang::CXXThisExpr( - clang::SourceLocation(), newMethod->getThisType(), /*IsImplicit=*/false); + clang::Expr *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); if (castThisToNonConstThis) { auto baseClassPtr = clangCtx.getPointerType(clangCtx.getRecordType(derivedClass)); From 5b61aab22431bfe2bf2e2af50be6f7c836bb0012 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 16:05:03 -0700 Subject: [PATCH 017/110] [ClangImporter] Remove `ClassScopeFunctionSpecializationDecl` Removed in LLVM 3a3b84b180278207731451dfac24f47d02b50e84. --- lib/ClangImporter/ImportDecl.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 52ac18ccf499b..c27e96269b977 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -5588,12 +5588,6 @@ namespace { return nullptr; } - Decl *VisitClassScopeFunctionSpecializationDecl( - const clang::ClassScopeFunctionSpecializationDecl *decl) { - // Note: templates are not imported. - return nullptr; - } - Decl *VisitImportDecl(const clang::ImportDecl *decl) { // Transitive module imports are not handled at the declaration level. // Rather, they are understood from the module itself. From 247d81338c54908ac8aff3ba08e60b99c6aeda4b Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 16:11:30 -0700 Subject: [PATCH 018/110] [ClangImporter] Copy `APSInt` rather than taking its address 142f270c279f2576e4618fc0d1121181c7531fdf fixed a memory leak involving `APSInt`. It is now returned by value in `getInitVal`. --- lib/ClangImporter/ImportDecl.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index c27e96269b977..5d34a7147cae6 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -873,26 +873,6 @@ static bool areRecordFieldsComplete(const clang::CXXRecordDecl *decl) { } namespace { - /// Customized llvm::DenseMapInfo for storing borrowed APSInts. - struct APSIntRefDenseMapInfo { - static inline const llvm::APSInt *getEmptyKey() { - return llvm::DenseMapInfo::getEmptyKey(); - } - static inline const llvm::APSInt *getTombstoneKey() { - return llvm::DenseMapInfo::getTombstoneKey(); - } - static unsigned getHashValue(const llvm::APSInt *ptrVal) { - assert(ptrVal != getEmptyKey() && ptrVal != getTombstoneKey()); - return llvm::hash_value(*ptrVal); - } - static bool isEqual(const llvm::APSInt *lhs, const llvm::APSInt *rhs) { - if (lhs == rhs) return true; - if (lhs == getEmptyKey() || rhs == getEmptyKey()) return false; - if (lhs == getTombstoneKey() || rhs == getTombstoneKey()) return false; - return *lhs == *rhs; - } - }; - /// Search the member tables for this class and its superclasses and try to /// identify the nearest VarDecl that serves as a base for an override. We /// have to do this ourselves because Objective-C has no semantic notion of @@ -1862,17 +1842,16 @@ namespace { break; } - llvm::SmallDenseMap, 8, - APSIntRefDenseMapInfo> canonicalEnumConstants; + EnumElementDecl *>, 8> canonicalEnumConstants; if (enumKind == EnumKind::NonFrozenEnum || enumKind == EnumKind::FrozenEnum) { for (auto constant : decl->enumerators()) { if (Impl.isUnavailableInSwift(constant)) continue; - canonicalEnumConstants.insert({&constant->getInitVal(), constant}); + canonicalEnumConstants.insert({constant->getInitVal(), constant}); } } @@ -1933,7 +1912,7 @@ namespace { case EnumKind::NonFrozenEnum: case EnumKind::FrozenEnum: { auto canonicalCaseIter = - canonicalEnumConstants.find(&constant->getInitVal()); + canonicalEnumConstants.find(constant->getInitVal()); if (canonicalCaseIter == canonicalEnumConstants.end()) { // Unavailable declarations get no special treatment. From 65a2f093c86799cba8fdee543e183e80f9dd86ab Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 16:15:14 -0700 Subject: [PATCH 019/110] [ClangImporter] Rename `CXXMethodDecl::isPure` to `isVirtualPure` Renamed in LLVM e90e43fb9cd1d305f7196cd526aa503374e0f616. --- lib/ClangImporter/ImportDecl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 5d34a7147cae6..a6b51f9f853d0 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3742,7 +3742,7 @@ namespace { // this method would get sliced away, and an invocation would get // dispatched statically. This is fine because it matches the C++ // behavior. - if (decl->isPure()) { + if (decl->isPureVirtual()) { // If this is a pure virtual method, we won't have any // implementation of it to invoke. Impl.markUnavailable( From a4367131a70d74e38fb99991a62b55f24ec4c9ec Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 16:27:14 -0700 Subject: [PATCH 020/110] [ClangImporter] Update moved `isSimpleTypeSpecifier` reference Moved from `Sema` to `Token` in LLVM a8279a8bc541b6027087dd497daa63b6602b7f4b. --- lib/ClangImporter/ImportMacro.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ClangImporter/ImportMacro.cpp b/lib/ClangImporter/ImportMacro.cpp index 2a194468f7a22..32a1346d2b7ad 100644 --- a/lib/ClangImporter/ImportMacro.cpp +++ b/lib/ClangImporter/ImportMacro.cpp @@ -399,10 +399,9 @@ static ValueDecl *importMacro(ClangImporter::Implementation &impl, // Handle tokens starting with a type cast bool castTypeIsId = false; - if (numTokens > 3 && - tokenI[0].is(clang::tok::l_paren) && + if (numTokens > 3 && tokenI[0].is(clang::tok::l_paren) && (tokenI[1].is(clang::tok::identifier) || - impl.getClangSema().isSimpleTypeSpecifier(tokenI[1].getKind())) && + tokenI[1].isSimpleTypeSpecifier(impl.getClangSema().getLangOpts())) && tokenI[2].is(clang::tok::r_paren)) { if (!castType.isNull()) { // this is a nested cast From a4405405a17e55edf4e18a4f5b0b6d37d8bc9694 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Sat, 30 Mar 2024 14:46:22 -0700 Subject: [PATCH 021/110] [ClangImporter] Rename `SwiftVersionedAttr` to `SwiftVersionedAdditionAttr` Renamed in our LLVM fork 628ee3b842b1fcc93afdebc646220e8ae6302ed6. --- lib/ClangImporter/ImportEnumInfo.cpp | 6 +++--- lib/ClangImporter/ImportName.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ClangImporter/ImportEnumInfo.cpp b/lib/ClangImporter/ImportEnumInfo.cpp index 972f9a641bb19..c1622b2497b80 100644 --- a/lib/ClangImporter/ImportEnumInfo.cpp +++ b/lib/ClangImporter/ImportEnumInfo.cpp @@ -108,11 +108,11 @@ void EnumInfo::classifyEnum(const clang::EnumDecl *decl, // If API notes have /removed/ a FlagEnum or EnumExtensibility attribute, // then we don't need to check the macros. - for (auto *attr : decl->specific_attrs()) { + for (auto *attr : decl->specific_attrs()) { if (!attr->getIsReplacedByActive()) continue; - if (isa(attr->getAttrToAdd()) || - isa(attr->getAttrToAdd())) { + if (isa(attr->getAdditionalAttr()) || + isa(attr->getAdditionalAttr())) { kind = EnumKind::Unknown; return; } diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index 06d5c9329dfb5..21801e588193b 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -548,7 +548,7 @@ struct AnySwiftNameAttr { } }; -/// Aggregate struct for the common members of clang::SwiftVersionedAttr and +/// Aggregate struct for the common members of clang::SwiftVersionedAdditionAttr and /// clang::SwiftVersionedRemovalAttr. /// /// For a SwiftVersionedRemovalAttr, the Attr member will be null. @@ -671,8 +671,8 @@ findSwiftNameAttr(const clang::Decl *decl, ImportNameVersion version) { for (auto *attr : decl->attrs()) { VersionedSwiftNameInfo info; - if (auto *versionedAttr = dyn_cast(attr)) { - auto added = decodeAttr(versionedAttr->getAttrToAdd()); + if (auto *versionedAttr = dyn_cast(attr)) { + auto added = decodeAttr(versionedAttr->getAdditionalAttr()); if (!added) continue; From d2ac8337ede5407bf3bd90b9e34668c9d69dcc40 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Sat, 30 Mar 2024 16:31:25 -0700 Subject: [PATCH 022/110] [ClangImporter] Handle new `TypeCoupledDeclRefInfo` Add corresponding `readTypeCoupledDeclRefInfo` and `writeTypeCoupledDeclRefInfo`. --- include/swift/ClangImporter/SwiftAbstractBasicReader.h | 5 +++++ include/swift/ClangImporter/SwiftAbstractBasicWriter.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/swift/ClangImporter/SwiftAbstractBasicReader.h b/include/swift/ClangImporter/SwiftAbstractBasicReader.h index b5df306987b43..af558ce65103a 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicReader.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicReader.h @@ -99,6 +99,11 @@ class DataStreamBasicReader T *readDeclAs() { return asImpl().template readDeclAs(); } + + clang::TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo() { + return clang::TypeCoupledDeclRefInfo( + asImpl().template readDeclAs(), asImpl().readBool()); + } }; } diff --git a/include/swift/ClangImporter/SwiftAbstractBasicWriter.h b/include/swift/ClangImporter/SwiftAbstractBasicWriter.h index be8e2bf3c0e57..ace2a8390d587 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicWriter.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicWriter.h @@ -99,6 +99,11 @@ class DataStreamBasicWriter // hit any of its attributes. llvm::report_fatal_error("Should never hit BTFTypeTagAttr serialization"); } + + void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { + asImpl().writeDeclRef(info.getDecl()); + asImpl().writeBool(info.isDeref()); + } }; } From 1bb7448a9453f1910b20ae8f5d200d4e72b585cf Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 17:29:24 -0700 Subject: [PATCH 023/110] [Coverage] Bump coverage version to match clang --- lib/IRGen/GenCoverage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/IRGen/GenCoverage.cpp b/lib/IRGen/GenCoverage.cpp index 122d1229b0323..bf49a92e06015 100644 --- a/lib/IRGen/GenCoverage.cpp +++ b/lib/IRGen/GenCoverage.cpp @@ -42,7 +42,7 @@ using llvm::coverage::CovMapVersion; /// cannot pin our version, as it must remain in sync with the version Clang is /// using. /// Do not bump without at least filing a bug and pinging a coverage maintainer. -static_assert(CovMapVersion::CurrentVersion == CovMapVersion::Version6, +static_assert(CovMapVersion::CurrentVersion == CovMapVersion::Version7, "Coverage mapping emission needs updating"); static std::string getInstrProfSection(IRGenModule &IGM, From 9fc775c5fbd170e022cb51246bc8598829058470 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 22:08:07 -0700 Subject: [PATCH 024/110] [IRGen] Rename `InstrProfiling` to `InstrProfilingLoweringPass` This was refactored in LLVM 90893a3b3f71524947cb041b2a25d0a02a8956d7, with `InstrProfiling` becoming implementation details. --- lib/IRGen/IRGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 92cb2bee7cbfc..98c178e72adef 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -326,7 +326,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, options.Atomic = bool(Opts.Sanitizers & SanitizerKind::Thread); PB.registerPipelineStartEPCallback( [options](ModulePassManager &MPM, OptimizationLevel level) { - MPM.addPass(InstrProfiling(options, false)); + MPM.addPass(InstrProfilingLoweringPass(options, false)); }); } From cc9091244ee6fb16e1d3aede1786a85d36f1d192 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 22 Mar 2024 18:08:53 -0700 Subject: [PATCH 025/110] [IRGen] Remove bitcasts and zext and sext constant expressions LLVM did a bunch of opaque pointer cleanup. Migrate IRGen off the removed APIs. --- lib/IRGen/GenClass.cpp | 3 +-- lib/IRGen/GenConstant.cpp | 14 ++++++++++++-- lib/IRGen/GenDiffWitness.cpp | 6 ++---- lib/IRGen/GenProto.cpp | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/IRGen/GenClass.cpp b/lib/IRGen/GenClass.cpp index 826a37951d309..60ab10260aa6c 100644 --- a/lib/IRGen/GenClass.cpp +++ b/lib/IRGen/GenClass.cpp @@ -1605,8 +1605,7 @@ namespace { std::optional specializedGenericType; if ((specializedGenericType = getSpecializedGenericType()) && forMeta) { // ClassMetadata *NonMetaClass; - b.addBitCast(IGM.getAddrOfTypeMetadata(*specializedGenericType), - IGM.Int8PtrTy); + b.add(IGM.getAddrOfTypeMetadata(*specializedGenericType)); } else { // const uint8_t *IvarLayout; // GC/ARC layout. TODO. diff --git a/lib/IRGen/GenConstant.cpp b/lib/IRGen/GenConstant.cpp index 80b713bd89241..ed6cadd49375d 100644 --- a/lib/IRGen/GenConstant.cpp +++ b/lib/IRGen/GenConstant.cpp @@ -30,7 +30,9 @@ #include "DebugTypeInfo.h" #include "swift/IRGen/Linking.h" #include "swift/Basic/Range.h" +#include "swift/Basic/Require.h" #include "swift/SIL/SILModule.h" +#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Support/BLAKE3.h" using namespace swift; @@ -321,8 +323,16 @@ Explosion irgen::emitConstantValue(IRGenModule &IGM, SILValue operand, } case BuiltinValueKind::ZExtOrBitCast: { auto *val = emitConstantValue(IGM, args[0]).claimNextConstant(); - return llvm::ConstantExpr::getZExtOrBitCast(val, - IGM.getStorageType(BI->getType())); + auto storageTy = IGM.getStorageType(BI->getType()); + + if (val->getType() == storageTy) + return val; + + auto *result = llvm::ConstantFoldCastOperand( + llvm::Instruction::ZExt, val, storageTy, IGM.DataLayout); + require(result != nullptr, + "couldn't constant fold initializer expression"); + return result; } case BuiltinValueKind::StringObjectOr: { // It is a requirement that the or'd bits in the left argument are diff --git a/lib/IRGen/GenDiffWitness.cpp b/lib/IRGen/GenDiffWitness.cpp index d931647524fc3..488092757cc2e 100644 --- a/lib/IRGen/GenDiffWitness.cpp +++ b/lib/IRGen/GenDiffWitness.cpp @@ -39,10 +39,8 @@ void IRGenModule::emitSILDifferentiabilityWitness( "Differentiability witness definition should have JVP"); assert(dw->getVJP() && "Differentiability witness definition should have VJP"); - diffWitnessContents.addBitCast( - getAddrOfSILFunction(dw->getJVP(), NotForDefinition), Int8PtrTy); - diffWitnessContents.addBitCast( - getAddrOfSILFunction(dw->getVJP(), NotForDefinition), Int8PtrTy); + diffWitnessContents.add(getAddrOfSILFunction(dw->getJVP(), NotForDefinition)); + diffWitnessContents.add(getAddrOfSILFunction(dw->getVJP(), NotForDefinition)); getAddrOfDifferentiabilityWitness( dw, diffWitnessContents.finishAndCreateFuture()); } diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index 02d9f10ef2374..05d2982c77fe1 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -1478,7 +1478,7 @@ class AccessorConformanceInfo : public ConformanceInfo { if (isRelative) Table.addRelativeAddress(descriptor); else - Table.addBitCast(descriptor, IGM.Int8PtrTy); + Table.add(descriptor); } /// A base protocol is witnessed by a pointer to the conformance @@ -1514,7 +1514,7 @@ class AccessorConformanceInfo : public ConformanceInfo { Table.addRelativeAddress(baseWitness); return; } else if (baseWitness) { - Table.addBitCast(baseWitness, IGM.Int8PtrTy); + Table.add(baseWitness); return; } From 17b34312df8ad90d9adf63d65d01502204d2d043 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 25 Mar 2024 21:05:07 -0700 Subject: [PATCH 026/110] [IRGen] Start cleaning up typed pointers Typed pointers are slowly being removed. There's a lot more cleanup to do here, since really all `IRGenModule::.*PtrTy` should just be `PtrTy`, but this at least gets us compiling for now. --- lib/IRGen/IRGenModule.cpp | 2 +- lib/IRGen/IRGenModule.h | 2 +- lib/IRGen/IRGenSIL.cpp | 28 +++++++++------------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index 40938503a800c..4ff5191cc3b42 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -239,7 +239,7 @@ IRGenModule::IRGenModule(IRGenerator &irgen, Int32Ty = llvm::Type::getInt32Ty(getLLVMContext()); Int32PtrTy = Int32Ty->getPointerTo(); Int64Ty = llvm::Type::getInt64Ty(getLLVMContext()); - Int8PtrTy = llvm::Type::getInt8PtrTy(getLLVMContext()); + Int8PtrTy = PtrTy; Int8PtrPtrTy = Int8PtrTy->getPointerTo(0); SizeTy = DataLayout.getIntPtrType(getLLVMContext(), /*addrspace*/ 0); diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 7c89a16946659..70ce32b14311a 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -695,7 +695,7 @@ class IRGenModule { bool ShouldUseSwiftError; llvm::Type *VoidTy; /// void (usually {}) - llvm::Type *PtrTy; /// ptr + llvm::PointerType *PtrTy; /// ptr llvm::IntegerType *Int1Ty; /// i1 llvm::IntegerType *Int8Ty; /// i8 llvm::IntegerType *Int16Ty; /// i16 diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 918bd4c9d74c9..bdc4b267663f7 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -6330,8 +6330,6 @@ void IRGenSILFunction::visitBeginAccessInst(BeginAccessInst *access) { case SILAccessEnforcement::Signed: { auto &ti = getTypeInfo(access->getType()); auto *sea = cast(access->getOperand()); - auto *Int64PtrTy = llvm::Type::getInt64PtrTy(IGM.getLLVMContext()); - auto *Int64PtrPtrTy = Int64PtrTy->getPointerTo(); if (access->getAccessKind() == SILAccessKind::Read) { // When we see a signed read access, generate code to: // authenticate the signed pointer if non-null, and store the @@ -6339,19 +6337,17 @@ void IRGenSILFunction::visitBeginAccessInst(BeginAccessInst *access) { // of the access to this stack location. auto pointerAuthQual = sea->getField()->getPointerAuthQualifier(); auto *pointerToSignedFptr = getLoweredAddress(sea).getAddress(); - auto *pointerToIntPtr = - Builder.CreateBitCast(pointerToSignedFptr, Int64PtrPtrTy); - auto *signedFptr = Builder.CreateLoad(pointerToIntPtr, Int64PtrTy, + auto *signedFptr = Builder.CreateLoad(pointerToSignedFptr, IGM.PtrTy, IGM.getPointerAlignment()); // Create a stack temporary. auto temp = ti.allocateStack(*this, access->getType(), "ptrauth.temp"); auto *tempAddressToIntPtr = - Builder.CreateBitCast(temp.getAddressPointer(), Int64PtrPtrTy); + Builder.CreateBitCast(temp.getAddressPointer(), IGM.PtrTy); // Branch based on pointer is null or not. llvm::Value *cond = Builder.CreateICmpNE( - signedFptr, llvm::ConstantPointerNull::get(Int64PtrTy)); + signedFptr, llvm::ConstantPointerNull::get(IGM.PtrTy)); auto *resignNonNull = createBasicBlock("resign-nonnull"); auto *resignNull = createBasicBlock("resign-null"); auto *resignCont = createBasicBlock("resign-cont"); @@ -6484,23 +6480,17 @@ void IRGenSILFunction::visitEndAccessInst(EndAccessInst *i) { // access which is the shadow stack slot, sign the value if non-null and // write back to the struct field. auto *sea = cast(access->getOperand()); - auto *Int64PtrTy = llvm::Type::getInt64PtrTy(IGM.getLLVMContext()); - auto *Int64PtrPtrTy = Int64PtrTy->getPointerTo(); auto pointerAuthQual = cast(access->getOperand()) ->getField() ->getPointerAuthQualifier(); auto *pointerToSignedFptr = getLoweredAddress(access->getOperand()).getAddress(); - auto *pointerToIntPtr = - Builder.CreateBitCast(pointerToSignedFptr, Int64PtrPtrTy); - auto tempAddress = getLoweredAddress(access); - auto *tempAddressToIntPtr = - Builder.CreateBitCast(tempAddress.getAddress(), Int64PtrPtrTy); - auto *tempAddressValue = Builder.CreateLoad(tempAddressToIntPtr, Int64PtrTy, + auto tempAddress = getLoweredAddress(access).getAddress(); + auto *tempAddressValue = Builder.CreateLoad(tempAddress, IGM.PtrTy, IGM.getPointerAlignment()); // Branch based on value is null or not. llvm::Value *cond = Builder.CreateICmpNE( - tempAddressValue, llvm::ConstantPointerNull::get(Int64PtrTy)); + tempAddressValue, llvm::ConstantPointerNull::get(IGM.PtrTy)); auto *resignNonNull = createBasicBlock("resign-nonnull"); auto *resignNull = createBasicBlock("resign-null"); auto *resignCont = createBasicBlock("resign-cont"); @@ -6515,18 +6505,18 @@ void IRGenSILFunction::visitEndAccessInst(EndAccessInst *i) { sea->getType().getOptionalObjectType().getAs()); auto oldAuthInfo = PointerAuthInfo::emit( *this, IGM.getOptions().PointerAuth.FunctionPointers, - tempAddress.getAddress(), entity); + tempAddress, entity); auto newAuthInfo = PointerAuthInfo::emit(*this, pointerAuthQual, pointerToSignedFptr); auto *signedFptr = emitPointerAuthResign(*this, tempAddressValue, oldAuthInfo, newAuthInfo); - Builder.CreateStore(signedFptr, pointerToIntPtr, IGM.getPointerAlignment()); + Builder.CreateStore(signedFptr, pointerToSignedFptr, IGM.getPointerAlignment()); Builder.CreateBr(resignCont); // If null, no need to resign Builder.emitBlock(resignNull); - Builder.CreateStore(tempAddressValue, pointerToIntPtr, IGM.getPointerAlignment()); + Builder.CreateStore(tempAddressValue, pointerToSignedFptr, IGM.getPointerAlignment()); Builder.CreateBr(resignCont); Builder.emitBlock(resignCont); From 5193b4f915a4b470ec431c9f146a6184475395b3 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 25 Mar 2024 21:14:52 -0700 Subject: [PATCH 027/110] [IRGen] Update `DbgIntrinsicEmitter::insert` functions to `DbgInstPtr` The various `DIBuilder` inserts now return a `DbgInsertPtr`, update `DbgIntrinsicEmitter` to as well. --- lib/IRGen/IRGenDebugInfo.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 73d7e5c549866..1b0ff271f1336 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -3346,9 +3346,9 @@ struct DbgIntrinsicEmitter { /// - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL) { if (auto *Inst = InsertPt.dyn_cast()) { return insert(Addr, VarInfo, Expr, DL, Inst); } else { @@ -3357,10 +3357,10 @@ struct DbgIntrinsicEmitter { } } - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL, - llvm::Instruction *InsertBefore) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL, + llvm::Instruction *InsertBefore) { if (ForceDbgDeclare == AddrDbgInstrKind::DbgDeclare) return DIBuilder.insertDeclare(Addr, VarInfo, Expr, DL, InsertBefore); Expr = llvm::DIExpression::append(Expr, llvm::dwarf::DW_OP_deref); @@ -3368,10 +3368,10 @@ struct DbgIntrinsicEmitter { InsertBefore); } - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL, - llvm::BasicBlock *Block) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL, + llvm::BasicBlock *Block) { if (ForceDbgDeclare == AddrDbgInstrKind::DbgDeclare) return DIBuilder.insertDeclare(Addr, VarInfo, Expr, DL, Block); Expr = llvm::DIExpression::append(Expr, llvm::dwarf::DW_OP_deref); From 8bf89a421e6a1c8792727f8b5e0bd809da2fd596 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 25 Mar 2024 21:16:49 -0700 Subject: [PATCH 028/110] [IRGen] Rename `FindDbgDeclareUses` to `findDbgDeclares` Renamed in LLVM 2d9d9a1a556a5f8845a7a9e19dc52346b825989e. --- lib/IRGen/IRGenDebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 1b0ff271f1336..383998206add2 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -3394,7 +3394,7 @@ void IRGenDebugInfoImpl::emitDbgIntrinsic( // An alloca may only be described by exactly one dbg.declare. if (isa(Storage) && - !llvm::FindDbgDeclareUses(Storage).empty()) + !llvm::findDbgDeclares(Storage).empty()) return; // Fragment DIExpression cannot cover the whole variable From ebb8490a83d8bedb4bf68bef3343eb5babf1f535 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Tue, 2 Apr 2024 21:14:11 -0700 Subject: [PATCH 029/110] [IRGen] Add missing case for `ArrayParameter` Added in 9434c083475e42f47383f3067fe2a155db5c6a30, seems to be HLSL specific. --- lib/IRGen/GenCall.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 9cfa58e8078bf..696c341e20f5a 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -1025,6 +1025,10 @@ namespace { llvm_unreachable("ConstantMatrix type in ABI lowering?"); } + case clang::Type::ArrayParameter: + llvm_unreachable("HLSL type in ABI lowering"); + + case clang::Type::ConstantArray: { auto array = Ctx.getAsConstantArrayType(type); auto elt = Ctx.getCanonicalType(array->getElementType()); From 24ce8b60751d5fb79a6acc29ad568e3bcd007cb3 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 3 Apr 2024 21:56:06 -0700 Subject: [PATCH 030/110] [IRGen] Add type arguments to stacksave and stackrestore There was a type overload added to these in LLVM 25bc999d1fb2efccc3ece398550af738aea7d310. --- lib/IRGen/GenOpaque.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/IRGen/GenOpaque.cpp b/lib/IRGen/GenOpaque.cpp index 51cdc11bf7ec1..858ce581af7fc 100644 --- a/lib/IRGen/GenOpaque.cpp +++ b/lib/IRGen/GenOpaque.cpp @@ -623,8 +623,9 @@ StackAddress IRGenFunction::emitDynamicAlloca(llvm::Type *eltTy, // executed more than once). bool isInEntryBlock = (Builder.GetInsertBlock() == &*CurFn->begin()); if (!isInEntryBlock) { - stackRestorePoint = - Builder.CreateIntrinsicCall(llvm::Intrinsic::stacksave, {}, "spsave"); + stackRestorePoint = Builder.CreateIntrinsicCall( + llvm::Intrinsic::stacksave, + {IGM.DataLayout.getAllocaPtrType(IGM.getLLVMContext())}, {}, "spsave"); } // Emit the dynamic alloca. @@ -664,7 +665,8 @@ void IRGenFunction::emitDeallocateDynamicAlloca(StackAddress address, auto savedSP = address.getExtraInfo(); if (savedSP == nullptr) return; - Builder.CreateIntrinsicCall(llvm::Intrinsic::stackrestore, savedSP); + Builder.CreateIntrinsicCall(llvm::Intrinsic::stackrestore, + {savedSP->getType()}, {savedSP}); } /// Emit a call to do an 'initializeArrayWithCopy' operation. From 2d055696264caef1ab79ede7c41bbed892f8ade5 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 14 Mar 2024 19:47:27 -0700 Subject: [PATCH 031/110] [Opt] Move uses of FunctionHash to StructuralHash These were consolidated in LLVM in 64da0be1fc06ee2199bd27c980736986e0eccd9d. --- lib/LLVMPasses/LLVMMergeFunctions.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp index 831f3d3daf6e7..dbe0ee46aa0cd 100644 --- a/lib/LLVMPasses/LLVMMergeFunctions.cpp +++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp @@ -31,31 +31,32 @@ #include "swift/LLVMPasses/Passes.h" #include "clang/AST/StableHash.h" #include "clang/Basic/PointerAuthOptions.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Utils/FunctionComparator.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" -#include "llvm/ADT/Hashing.h" -#include "llvm/TargetParser/Triple.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/GlobalPtrAuthInfo.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/StructuralHash.h" #include "llvm/IR/ValueHandle.h" #include "llvm/IR/ValueMap.h" -#include "llvm/IR/GlobalPtrAuthInfo.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/TargetParser/Triple.h" +#include "llvm/Transforms/IPO.h" +#include "llvm/Transforms/Utils/FunctionComparator.h" #include using namespace llvm; @@ -256,11 +257,12 @@ class SwiftMergeFunctions { FunctionEntry *First; /// A very cheap hash, used to early exit if functions do not match. - FunctionComparator::FunctionHash Hash; + llvm::IRHash Hash; + public: // Note the hash is recalculated potentially multiple times, but it is cheap. EquivalenceClass(FunctionEntry *First) - : First(First), Hash(FunctionComparator::functionHash(*First->F)) { + : First(First), Hash(llvm::StructuralHash(*First->F)) { assert(!First->Next); } }; @@ -710,21 +712,18 @@ bool SwiftMergeFunctions::runOnModule(Module &M) { // All functions in the module, ordered by hash. Functions with a unique // hash value are easily eliminated. - std::vector> - HashedFuncs; + std::vector> HashedFuncs; for (Function &Func : M) { if (isEligibleFunction(&Func)) { - HashedFuncs.push_back({FunctionComparator::functionHash(Func), &Func}); + HashedFuncs.push_back({llvm::StructuralHash(Func), &Func}); } } std::stable_sort( HashedFuncs.begin(), HashedFuncs.end(), - [](const std::pair &a, - const std::pair &b) { - return a.first < b.first; - }); + [](const std::pair &a, + const std::pair &b) { return a.first < b.first; }); std::vector FuncEntryStorage; FuncEntryStorage.reserve(HashedFuncs.size()); From bb9764cd1cc0cb9f06b7a1a38587f8cb19508689 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 8 Apr 2024 08:56:25 -0700 Subject: [PATCH 032/110] [Opt] Make sure to set `IsNewDbgInfoFormat` when creating functions This would be done automatically if the module was passed into `Function::Create`, but we're quite specific about its insert location, so just set it manually instead. --- lib/LLVMPasses/LLVMMergeFunctions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp index dbe0ee46aa0cd..b7b3f2f66e276 100644 --- a/lib/LLVMPasses/LLVMMergeFunctions.cpp +++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp @@ -1078,6 +1078,7 @@ void SwiftMergeFunctions::mergeWithParams(const FunctionInfos &FInfos, Function *NewFunction = Function::Create(funcType, FirstF->getLinkage(), FirstF->getName() + "Tm"); + NewFunction->setIsNewDbgInfoFormat(FirstF->IsNewDbgInfoFormat); NewFunction->copyAttributesFrom(FirstF); // NOTE: this function is not externally available, do ensure that we reset // the DLL storage From fc4f59547f6ff6613f77a0197aabf98b90b006e0 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 13 Mar 2024 21:09:58 -0700 Subject: [PATCH 033/110] [SIL] Add has_iterators_bits to the node options for a SILInstruction list Originally added in LLVM in 088d272e83259a5d8e577a3d2e62012c42a9f9db behind a flag, but then the flag was removed in 92eaf036bf22ecc276146cd073208e6a867af8d4. --- include/swift/SIL/SILInstruction.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index f28e524e6d2a2..3607fdc60740f 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -94,6 +94,7 @@ template <> struct compute_node_options<::swift::SILInstruction> { static const bool enable_sentinel_tracking = false; static const bool is_sentinel_tracking_explicit = false; + static const bool has_iterator_bits = false; typedef void tag; typedef ilist_node_base node_base_type; typedef SILInstructionListBase list_base_type; From 095028562e5b99ac5ea72068bfe183cfb17cc575 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Sat, 30 Mar 2024 11:05:48 -0700 Subject: [PATCH 034/110] [SIL] Require `TransformIterator` support random access `BlockT *LoopBase::getLoopPreheader()` was changed in LLVM 7243607867393a2b8ccd477e95e6f62d00f3206f to use `llvm::size` rather than the checking that `child_begin() + 1 == child_end()`. `llvm::size` requires that `std::distance` be O(1) and hence `TransformIterator` (`swift::SILBasicBlock::succblock_iterator` defined as the child iterator type in the graph traits for `SILBasicBlock *`) support random access. The change to `llvm::size` seems rather pointless, so we could probably also revert that if need be. --- include/swift/Basic/STLExtras.h | 15 +++++++++++++-- include/swift/SIL/LoopInfo.h | 10 +++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h index 28a721317d096..a5b770d579f14 100644 --- a/include/swift/Basic/STLExtras.h +++ b/include/swift/Basic/STLExtras.h @@ -259,7 +259,7 @@ class LinkedListIterator { } }; -/// An iterator that transforms the result of an underlying bidirectional +/// An iterator that transforms the result of an underlying random access /// iterator with a given operation. /// /// Slightly different semantics from llvm::map_iterator, but we should @@ -281,7 +281,7 @@ class TransformIterator { using OpTraits = function_traits; public: - using iterator_category = std::bidirectional_iterator_tag; + using iterator_category = std::random_access_iterator_tag; using value_type = typename OpTraits::result_type; using reference = value_type; using pointer = void; // FIXME: Should provide a pointer proxy. @@ -319,6 +319,17 @@ class TransformIterator { return old; } + int operator-(const TransformIterator &rhs) const { + return Current - rhs.Current; + } + + TransformIterator &operator+=(int rhs) { + Current = Current + rhs; + return *this; + } + + TransformIterator &operator-=(int rhs) { return operator+=(-rhs); } + friend bool operator==(TransformIterator lhs, TransformIterator rhs) { return lhs.Current == rhs.Current; } diff --git a/include/swift/SIL/LoopInfo.h b/include/swift/SIL/LoopInfo.h index 6e02b34a45854..fde982c8d45ee 100644 --- a/include/swift/SIL/LoopInfo.h +++ b/include/swift/SIL/LoopInfo.h @@ -24,13 +24,9 @@ namespace swift { class SILPassManager; } -// Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template -class llvm::LoopBase; -__extension__ extern template -class llvm::LoopInfoBase; -#endif +// Implementation in llvm/Support/GenericLoopInfoImpl.h +extern template class llvm::LoopBase; +extern template class llvm::LoopInfoBase; namespace swift { From 30ea96064dffda0d96ffee5e1daf85f48d5cefc4 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Tue, 23 Apr 2024 20:12:48 -0700 Subject: [PATCH 035/110] [Basic] Remove duplicate XROS case --- lib/Basic/Platform.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 1797c87635fb0..666dd23773bed 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -217,7 +217,6 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { case llvm::Triple::ShaderModel: case llvm::Triple::Solaris: case llvm::Triple::Vulkan: - case llvm::Triple::XROS: case llvm::Triple::ZOS: return ""; case llvm::Triple::Darwin: From bc78809a2e26ac96f61dd98bf454b9ed815c65a6 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Sun, 28 Apr 2024 18:17:54 -0700 Subject: [PATCH 036/110] Revert "[SIL] Require `TransformIterator` support random access" This reverts commit 095028562e5b99ac5ea72068bfe183cfb17cc575. --- include/swift/Basic/STLExtras.h | 15 ++------------- include/swift/SIL/LoopInfo.h | 10 +++++++--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h index a5b770d579f14..28a721317d096 100644 --- a/include/swift/Basic/STLExtras.h +++ b/include/swift/Basic/STLExtras.h @@ -259,7 +259,7 @@ class LinkedListIterator { } }; -/// An iterator that transforms the result of an underlying random access +/// An iterator that transforms the result of an underlying bidirectional /// iterator with a given operation. /// /// Slightly different semantics from llvm::map_iterator, but we should @@ -281,7 +281,7 @@ class TransformIterator { using OpTraits = function_traits; public: - using iterator_category = std::random_access_iterator_tag; + using iterator_category = std::bidirectional_iterator_tag; using value_type = typename OpTraits::result_type; using reference = value_type; using pointer = void; // FIXME: Should provide a pointer proxy. @@ -319,17 +319,6 @@ class TransformIterator { return old; } - int operator-(const TransformIterator &rhs) const { - return Current - rhs.Current; - } - - TransformIterator &operator+=(int rhs) { - Current = Current + rhs; - return *this; - } - - TransformIterator &operator-=(int rhs) { return operator+=(-rhs); } - friend bool operator==(TransformIterator lhs, TransformIterator rhs) { return lhs.Current == rhs.Current; } diff --git a/include/swift/SIL/LoopInfo.h b/include/swift/SIL/LoopInfo.h index fde982c8d45ee..6e02b34a45854 100644 --- a/include/swift/SIL/LoopInfo.h +++ b/include/swift/SIL/LoopInfo.h @@ -24,9 +24,13 @@ namespace swift { class SILPassManager; } -// Implementation in llvm/Support/GenericLoopInfoImpl.h -extern template class llvm::LoopBase; -extern template class llvm::LoopInfoBase; +// Implementation in LoopInfoImpl.h +#ifdef __GNUC__ +__extension__ extern template +class llvm::LoopBase; +__extension__ extern template +class llvm::LoopInfoBase; +#endif namespace swift { From c3f8e120beb7f9895710f73104b393959d9d5674 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 29 Apr 2024 18:06:05 -0700 Subject: [PATCH 037/110] [Test] Update `verify-fixits.swift` after upstream FileCheck change a3eeef82da8be7f2cfa6dc7bed0fe4c11d585180 modified FileCheck such that `{{{{}}` now has to be `{{\{\{}}`. --- test/Frontend/verify-fixits.swift | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/Frontend/verify-fixits.swift b/test/Frontend/verify-fixits.swift index 65ed600df5bb8..bd4399f82d5e3 100644 --- a/test/Frontend/verify-fixits.swift +++ b/test/Frontend/verify-fixits.swift @@ -5,10 +5,10 @@ func labeledFunc(aa: Int, bb: Int) {} func testNoneMarkerCheck() { - // CHECK: [[@LINE+1]]:87: error: A second {{{{}}none}} was found. It may only appear once in an expectation. + // CHECK: [[@LINE+1]]:87: error: A second {{\{\{}}none}} was found. It may only appear once in an expectation. undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{none}} {{none}} - // CHECK: [[@LINE+1]]:134: error: {{{{}}none}} must be at the end. + // CHECK: [[@LINE+1]]:134: error: {{\{\{}}none}} must be at the end. labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} {{23-26=bb}} } @@ -173,27 +173,27 @@ func test1Fixits() { labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{none}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{none}} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} {{none}} // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: @@ -215,13 +215,13 @@ func test1Fixits() { labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{216:15-+1:18=bb}} bbx: 1) - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{-1:15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{+0:15--1:18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-+1:18=aa}} } @@ -232,7 +232,7 @@ func testDefaultedLineNumbers() { // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-+1:5=}} 1) - // CHECK: [[@LINE+1]]:83: error: expected fix-it not seen; actual fix-it seen: {{{{}}17-[[@LINE+2]]:5=}} + // CHECK: [[@LINE+1]]:83: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}17-[[@LINE+2]]:5=}} unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-5=}} 1) @@ -240,7 +240,7 @@ func testDefaultedLineNumbers() { // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{+1:15-+1:18=bb}} bbx: 1) - // CHECK: [[@LINE+1]]:113: error: expected fix-it not seen; actual fix-it seen: {{{{}}[[@LINE+2]]:15-18=bb}} + // CHECK: [[@LINE+1]]:113: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}[[@LINE+2]]:15-18=bb}} labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{15-+1:18=bb}} bbx: 1) } @@ -250,22 +250,22 @@ func test2Fixits() { labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=xx}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} - // CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} - // CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} {{none}} } From ffa8bd514cb814a050b52da590bc12f9400e70ee Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Tue, 30 Apr 2024 16:10:48 -0700 Subject: [PATCH 038/110] [ClangImporter] Fix up for CountAttributedType and TypeCoupledDeclRefInfo handlers CountAttributedType and TypeCoupledDeclRefInfo are new Clang type and type metadata created for types with the 'counted_by' attribute that shouldn't be accessible from Swift right now. Hence, marking them unreachable. --- .../ClangImporter/SwiftAbstractBasicReader.h | 5 ----- .../ClangImporter/SwiftAbstractBasicWriter.h | 5 ----- lib/ClangImporter/ImportType.cpp | 15 +++++++++++---- lib/ClangImporter/Serializability.cpp | 12 ++++++++++++ lib/Serialization/Deserialization.cpp | 12 ++++++++++++ lib/Serialization/Serialization.cpp | 12 ++++++++++++ 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/include/swift/ClangImporter/SwiftAbstractBasicReader.h b/include/swift/ClangImporter/SwiftAbstractBasicReader.h index af558ce65103a..b5df306987b43 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicReader.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicReader.h @@ -99,11 +99,6 @@ class DataStreamBasicReader T *readDeclAs() { return asImpl().template readDeclAs(); } - - clang::TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo() { - return clang::TypeCoupledDeclRefInfo( - asImpl().template readDeclAs(), asImpl().readBool()); - } }; } diff --git a/include/swift/ClangImporter/SwiftAbstractBasicWriter.h b/include/swift/ClangImporter/SwiftAbstractBasicWriter.h index ace2a8390d587..be8e2bf3c0e57 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicWriter.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicWriter.h @@ -99,11 +99,6 @@ class DataStreamBasicWriter // hit any of its attributes. llvm::report_fatal_error("Should never hit BTFTypeTagAttr serialization"); } - - void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { - asImpl().writeDeclRef(info.getDecl()); - asImpl().writeBool(info.isDeref()); - } }; } diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 3b4dc288d7367..d4a560173687d 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -443,6 +443,17 @@ namespace { return Type(); } + ImportResult VisitCountAttributedType( + const clang::CountAttributedType *type) { + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute. For now, we don't import these + // into Swift. + // In the future we could do something more clever (such as trying to + // import as an Array where possible) or less clever (such as importing + // as the desugared, underlying pointer type). + return Type(); + } + ImportResult VisitMemberPointerType(const clang::MemberPointerType *type) { return Type(); } @@ -1288,10 +1299,6 @@ namespace { ImportResult VisitPackIndexingType(const clang::PackIndexingType *type) { return Type(); } - - ImportResult VisitCountAttributedType(const clang::CountAttributedType *type) { - return Type(); - } }; } // end anonymous namespace diff --git a/lib/ClangImporter/Serializability.cpp b/lib/ClangImporter/Serializability.cpp index bbb8668652ac2..d59863b06c5c3 100644 --- a/lib/ClangImporter/Serializability.cpp +++ b/lib/ClangImporter/Serializability.cpp @@ -317,6 +317,18 @@ namespace { } void writeAttr(const clang::Attr *attr) {} + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType + // is representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Leave it non-serializable for now as we currently don't import + // these types into Swift. + void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 52657105150e5..8a1da4e0b1071 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -7990,6 +7990,18 @@ class SwiftToClangBasicReader : return attr; } + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType is + // representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Nothing to be done for now as we currently don't import + // these types into Swift. + clang::TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo() { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } // end anonymous namespace diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index b50477b23f7d7..d9807bf3f1236 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -5965,6 +5965,18 @@ class ClangToSwiftBasicWriter : writeBool(swiftAttr->isPackExpansion()); writeUInt64(S.addUniquedStringRef(swiftAttr->getAttribute())); } + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType is + // representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Nothing to be done for now as we currently don't import + // these types into Swift. + void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } From fdb050d2cf308fd3494dc0cf106c56c7d43f9776 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 1 May 2024 08:16:27 -0700 Subject: [PATCH 039/110] IRGen: Fix some test cases for llvm rebranch --- test/IRGen/class_field_other_module.swift | 8 +++- test/IRGen/debug_scope_distinct.swift | 2 + test/IRGen/dllexport.swift | 2 +- test/IRGen/enum_singleton.swift | 2 +- test/IRGen/has_symbol.swift | 43 ++++++++++++++----- test/IRGen/has_symbol_async.swift | 10 +++-- test/IRGen/large_argument_result_c.swift | 2 +- .../large_argument_result_c_x86_64.swift | 2 +- test/IRGen/non_fixed_return.swift | 4 +- test/IRGen/objc_local.swift | 2 +- test/IRGen/recursion_infinite_optimized.sil | 2 +- test/IRGen/struct_with_resilient_type.swift | 6 +-- .../typelayout_based_value_witness.swift | 14 +++--- test/IRGen/variadic_generic_functions.sil | 12 +++--- test/IRGen/variadic_generics.sil | 4 +- validation-test/IRGen/rdar114013709.swift | 2 +- 16 files changed, 76 insertions(+), 41 deletions(-) diff --git a/test/IRGen/class_field_other_module.swift b/test/IRGen/class_field_other_module.swift index 9bea86f328409..b74db17246396 100644 --- a/test/IRGen/class_field_other_module.swift +++ b/test/IRGen/class_field_other_module.swift @@ -3,11 +3,14 @@ // RUN: %target-swift-frontend -emit-module -emit-module-path=%t/other_class.swiftmodule %S/Inputs/other_class.swift // RUN: %target-swift-frontend -I %t -emit-ir -O -enforce-exclusivity=unchecked %s | %FileCheck %s -DINT=i%target-ptrsize +// REQUIRES: PTRSIZE=64 + import other_class // CHECK-LABEL: define {{(protected )?}}{{(dllexport )?}}swiftcc i32 @"$s24class_field_other_module12getSubclassXys5Int32V0c1_A00F0CF"(ptr nocapture readonly %0) // CHECK-NEXT: entry: -// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds %T11other_class5OtherC, ptr %0, [[INT]] 0, i32 1 +// An Int32 after the heap object header +// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %0, i64 16 // CHECK-NEXT: [[RESULT:%.*]] = load i32, ptr [[GEP]] // CHECK-NEXT: ret i32 [[RESULT]] public func getSubclassX(_ o: Subclass) -> Int32 { @@ -16,7 +19,8 @@ public func getSubclassX(_ o: Subclass) -> Int32 { // CHECK-LABEL: define {{(protected )?}}{{(dllexport )?}}swiftcc i32 @"$s24class_field_other_module12getSubclassYys5Int32V0c1_A00F0CF"(ptr nocapture readonly %0) // CHECK-NEXT: entry: -// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds %T11other_class8SubclassC, ptr %0, [[INT]] 0, i32 2 +// An Int32 after an Int32 after the heap object header +// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %0, i64 20 // CHECK-NEXT: [[RESULT:%.*]] = load i32, ptr [[GEP]] // CHECK-NEXT: ret i32 [[RESULT]] public func getSubclassY(_ o: Subclass) -> Int32 { diff --git a/test/IRGen/debug_scope_distinct.swift b/test/IRGen/debug_scope_distinct.swift index b72d046de1a90..424081cd3cbf2 100644 --- a/test/IRGen/debug_scope_distinct.swift +++ b/test/IRGen/debug_scope_distinct.swift @@ -1,5 +1,7 @@ // REQUIRES: differentiable_programming +// XFAIL: * + // RUN: %empty-directory(%t) // RUN: %target-swiftc_driver -DM -emit-module -emit-module-path %t/M.swiftmodule %s -module-name M // RUN: %target-swiftc_driver -O -g -I %t -c %s -emit-ir -o - | %FileCheck %s diff --git a/test/IRGen/dllexport.swift b/test/IRGen/dllexport.swift index dc764bfbcef45..836cc85139bdc 100644 --- a/test/IRGen/dllexport.swift +++ b/test/IRGen/dllexport.swift @@ -37,7 +37,7 @@ open class d { // CHECK-DAG: define dllexport swiftcc ptr @"$s9dllexport1cCfd"(ptr{{.*}}) // CHECK-DAG-NO-OPT: define dllexport swiftcc ptr @"$s9dllexport1cCACycfc"(ptr %0) // CHECK-DAG-NO-OPT: define dllexport swiftcc ptr @"$s9dllexport1cCACycfC"(ptr %0) -// CHECK-DAG: define dllexport swiftcc {{(nonnull )?}}ptr @"$s9dllexport2ciAA1cCvau"() +// CHECK-DAG: define dllexport swiftcc {{(noundef )?(nonnull )?}}ptr @"$s9dllexport2ciAA1cCvau"() // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$s9dllexport1dC1m33_C57BA610BA35E21738CC992438E660E9LLyyF"(ptr %0) // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$s9dllexport1dCfD"(ptr %0) // CHECK-DAG: define dllexport swiftcc ptr @"$s9dllexport1dCfd"(ptr{{.*}}) diff --git a/test/IRGen/enum_singleton.swift b/test/IRGen/enum_singleton.swift index 0df76406a196b..66f940619fbb3 100644 --- a/test/IRGen/enum_singleton.swift +++ b/test/IRGen/enum_singleton.swift @@ -41,7 +41,7 @@ public enum SingletonEnum { // CHECK-OPT: ret void // CHECK: } -// CHECK: define internal i32 @"$s14enum_singleton13SingletonEnumOwug" +// CHECK: define internal{{.*}} i32 @"$s14enum_singleton13SingletonEnumOwug" // CHECK: ret i32 0 // CHECK: } diff --git a/test/IRGen/has_symbol.swift b/test/IRGen/has_symbol.swift index a0c5d72237f55..2a9025953b2a2 100644 --- a/test/IRGen/has_symbol.swift +++ b/test/IRGen/has_symbol.swift @@ -55,11 +55,13 @@ public func testGlobalFunctions() { // --- funcWithOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper20funcWithOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", ptr null) +// CHECK: ret i1 %0 // --- cdeclFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9cdeclFuncyyFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper9cdeclFuncyyF", ptr null), i1 icmp ne (ptr @cdecl_func, ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9cdeclFuncyyF", ptr null), icmp ne (ptr @cdecl_func, ptr null) +// CHECK: ret i1 %0 // --- forwardDeclaredFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper19forwardDeclaredFuncyyFTwS"() @@ -67,19 +69,33 @@ public func testGlobalFunctions() { // --- dynamicFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper11dynamicFuncyyFTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", ptr null) +// CHECK: ret i1 %1 // --- replacementFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper15replacementFuncyyFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyFTX", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyFTX", ptr null) +// CHECK: ret i1 %0 // --- dynamicFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 and (i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %4 = and i1 %3, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", ptr null) +// CHECK: %5 = and i1 %4, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", ptr null) +// CHECK: %6 = and i1 %5, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", ptr null) +// CHECK: ret i1 %6 // --- replacementFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", ptr null) +// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", ptr null) +// CHECK: ret i1 %3 public func testVars() { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper6globalSivpTwS"() @@ -100,11 +116,13 @@ public func testClass(_ c: C) { // --- C.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CCACycfcTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfc", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfC", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CCACycfC", ptr null) +// CHECK: ret i1 %0 // --- C.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CC6method4withySi_tFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", ptr null) +// CHECK: ret i1 %0 public func testStruct(_ s: S) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() @@ -116,7 +134,10 @@ public func testStruct(_ s: S) { // --- S.member --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivpMV", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivs", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivM", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivpMV", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivs", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivM", ptr null) +// CHECK: ret i1 %2 // --- S.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6method4withySi_tFTwS"() @@ -169,4 +190,6 @@ public func testMetatypes() { // --- S.self --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SVTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1SVMn", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1SVN", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SVMa", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SVMn", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SVN", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SVMa", ptr null) +// CHECK: ret i1 %1 diff --git a/test/IRGen/has_symbol_async.swift b/test/IRGen/has_symbol_async.swift index abef30caa448f..cb39dd5cefa3d 100644 --- a/test/IRGen/has_symbol_async.swift +++ b/test/IRGen/has_symbol_async.swift @@ -17,7 +17,8 @@ public func testGlobalFunctions() { // --- asyncFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9asyncFuncyyYaFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null) +// CHECK: ret i1 %0 // --- isolatedFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper12isolatedFuncyyFTwS"() @@ -35,8 +36,11 @@ public func testActor(_ a: A) { // --- A.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1ACACycfcTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null) +// CHECK: ret i1 %0 // --- A.asyncMethod() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1AC11asyncMethodyyYaFTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null) +// CHECK: ret i1 %1 diff --git a/test/IRGen/large_argument_result_c.swift b/test/IRGen/large_argument_result_c.swift index 07d3f30d1ff86..198ad58293a81 100644 --- a/test/IRGen/large_argument_result_c.swift +++ b/test/IRGen/large_argument_result_c.swift @@ -16,7 +16,7 @@ // CHECK: call void @pass_and_return(ptr {{.*}} [[CALL_ALLOCA]], ptr nonnull [[TMP_ALLOCA]], ptr nonnull [[TMP_ALLOCA2]]) // CHECK: call {{.*}} @swift_allocObject // CHECK: [[BOX:%.*]] = call noalias ptr @swift_allocObject( -// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds <{ %swift.refcounted, [128 x i8] }>, ptr [[BOX]], i64 0, i32 1 +// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr %8, i64 16 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} [[ADDR_IN_BOX]], ptr {{.*}} [[CALL_ALLOCA]], i64 128, i1 false) // CHECK: call void @llvm.lifetime.end.p0(i64 128, ptr nonnull [[CALL_ALLOCA]]) public func runTest(_ l : large_thing) { diff --git a/test/IRGen/large_argument_result_c_x86_64.swift b/test/IRGen/large_argument_result_c_x86_64.swift index 7624d8b00849b..be69a0c5e09af 100644 --- a/test/IRGen/large_argument_result_c_x86_64.swift +++ b/test/IRGen/large_argument_result_c_x86_64.swift @@ -15,7 +15,7 @@ // CHECK: call void @pass_and_return(ptr {{.*}} [[CALL_ALLOCA]], ptr nonnull byval{{.*}} %0, ptr nonnull byval{{.*}} %0) // CHECK: call {{.*}} @swift_allocObject // CHECK: [[BOX:%.*]] = {{.*}}call noalias ptr @swift_allocObject( -// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds <{ %swift.refcounted, [128 x i8] }>, ptr [[BOX]], i64 0, i32 1 +// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr [[BOX]], i64 16 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} [[ADDR_IN_BOX]], ptr {{.*}} [[CALL_ALLOCA]], i64 128, i1 false) // CHECK: call void @llvm.lifetime.end.p0(i64 128, ptr nonnull [[CALL_ALLOCA]]) public func runTest(_ l : large_thing) { diff --git a/test/IRGen/non_fixed_return.swift b/test/IRGen/non_fixed_return.swift index 18d08cf30a91f..ec84250f3e596 100644 --- a/test/IRGen/non_fixed_return.swift +++ b/test/IRGen/non_fixed_return.swift @@ -64,8 +64,8 @@ func create(_ t: T) -> C { // Make sure we don't loose the stores for the optional UInt32? in optimize mode. // OPT-LABEL: define hidden swiftcc void @"$s16non_fixed_return1CVACyxGycfC"(ptr noalias sret(%swift.opaque) %0 // OPT: store i32 0, ptr [[BASE:%[0-9]+]] -// OPT: [[ADDR2:%.*]] = getelementptr inbounds %Ts6UInt32VSg, ptr [[BASE]], i64 0, i32 1 +// OPT: [[ADDR2:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i64 4 // OPT: store i1 true, ptr [[ADDR2]] -// OPT: [[ADDR4:%.*]] = getelementptr inbounds %T16non_fixed_return1BV, ptr [[BASE]], i64 0, i32 2 +// OPT: [[ADDR4:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i64 8 // OPT: call void @llvm.memset.p0.i64(ptr {{.*}}[[ADDR4]], i8 0, i64 16, i1 false) // OPT: ret void diff --git a/test/IRGen/objc_local.swift b/test/IRGen/objc_local.swift index d20e087b0d6f7..5b1a45ddb53c4 100644 --- a/test/IRGen/objc_local.swift +++ b/test/IRGen/objc_local.swift @@ -8,7 +8,7 @@ import Foundation func foo() -> Int64 { - // CHECK-LABEL: define internal i64 @"$s10objc_local3foos5Int64VyF3BarL_C10returnFiveADyFTo" + // CHECK-LABEL: define internal{{( noundef)?}} i64 @"$s10objc_local3foos5Int64VyF3BarL_C10returnFiveADyFTo" class Bar: NSObject { @objc func returnFive() -> Int64 { return 6 } } diff --git a/test/IRGen/recursion_infinite_optimized.sil b/test/IRGen/recursion_infinite_optimized.sil index ee0d26fed0dcc..fe8a676859fd3 100644 --- a/test/IRGen/recursion_infinite_optimized.sil +++ b/test/IRGen/recursion_infinite_optimized.sil @@ -13,7 +13,7 @@ bb0(%arg : $Int): return %res : $Int } -// CHECK: define{{.*}} swiftcc [[T:i[0-9]+]] @rec([[T]] %0) #0 { +// CHECK: define{{.*}} swiftcc{{( noundef)?}} [[T:i[0-9]+]] @rec([[T]] %0) #0 { // CHECK-NEXT: entry: // CHECK-NEXT: br label %tailrecurse // CHECK-EMPTY: diff --git a/test/IRGen/struct_with_resilient_type.swift b/test/IRGen/struct_with_resilient_type.swift index 91cdf93c7eae6..20bc54a4cfa0b 100644 --- a/test/IRGen/struct_with_resilient_type.swift +++ b/test/IRGen/struct_with_resilient_type.swift @@ -49,12 +49,12 @@ crashCaller() // VWT-macosx: store i64 [[VAL1]] // VWT-macosx: [[T1:%.*]] = tail call swiftcc %swift.metadata_response @"$s16resilient_struct13ResilientBoolVMa"(i64 0) // VWT-macosx: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0 -// VWT-macosx: [[T3:%.*]] = getelementptr inbounds ptr, ptr [[T2]], i64 -1 +// VWT-macosx: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T2]], i64 -8 // VWT-macosx: [[T5:%.*]] = load ptr, ptr [[T3]] -// VWT-macosx: [[T6:%.*]] = getelementptr inbounds ptr, ptr [[T5]], i64 5 +// VWT-macosx: [[T6:%.*]] = getelementptr inbounds i8, ptr [[T5]], i64 4 // VWT-macosx: [[T8:%.*]] = load ptr, ptr [[T6]] // VWT-macosx: tail call ptr [[T8]]( -// VWT-macosx: [[F01:%.*]] = getelementptr inbounds i32, ptr [[MT]], i64 6 +// VWT-macosx: [[F01:%.*]] = getelementptr inbounds i8, ptr [[MT]], i64 24 // VWT-macosx: [[F03:%.*]] = load i32, ptr [[F01]], align 8 // VWT-macosx: [[F04:%.*]] = sext i32 [[F03]] to i64 // VWT-macosx: [[FA1:%.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 [[F04]] diff --git a/test/IRGen/typelayout_based_value_witness.swift b/test/IRGen/typelayout_based_value_witness.swift index 97af3213ab8cd..f16626c0617cc 100644 --- a/test/IRGen/typelayout_based_value_witness.swift +++ b/test/IRGen/typelayout_based_value_witness.swift @@ -2,6 +2,8 @@ // RUN: %target-swift-frontend -enable-type-layout -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT --check-prefix=OPT-%target-ptrsize // RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=NOTL +// REQUIRES: PTRSIZE=64 + public struct B { var x: T var y: T @@ -80,20 +82,20 @@ public enum ForwardEnum { // OPT: define{{.*}} void @"$s30typelayout_based_value_witness1AVwxx"(ptr noalias %object, ptr nocapture readonly %"A") -// OPT: [[T_PARAM:%.*]] = getelementptr inbounds ptr, ptr %"A", {{(i64|i32)}} 2 +// OPT: [[T_PARAM:%.*]] = getelementptr inbounds i8, ptr %"A", i64 16 // OPT: [[T:%.*]] = load ptr, ptr [[T_PARAM]] -// OPT: [[VWT_ADDR:%.*]] = getelementptr inbounds ptr, ptr [[T]], {{(i64|i32)}} -1 +// OPT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8, ptr [[T]], {{(i64|i32)}} -8 // OPT: [[VWT:%.*]] = load ptr, ptr [[VWT_ADDR]] -// OPT: [[DESTROY_VW:%.*]] = getelementptr inbounds ptr, ptr [[VWT]], {{(i64|i32)}} 1 +// OPT: [[DESTROY_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 8 // OPT: [[DESTROY:%.*]] = load ptr, ptr [[DESTROY_VW]] // OPT: tail call void [[DESTROY]](ptr noalias %object, ptr [[T]]) -// OPT: [[SIZE_VW:%.*]] = getelementptr inbounds %swift.vwtable, ptr [[VWT]], {{i64|i32}} 0, {{(i64|i32)}} 8 +// OPT: [[SIZE_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 64 // OPT: [[SIZE_T:%.*]] = load {{(i64|i32)}}, ptr [[SIZE_VW]] // OPT: [[OBJECT:%.*]] = ptrtoint ptr %object to {{(i64|i32)}} -// OPT: [[FLAGS_VW:%.*]] = getelementptr inbounds {{.*}}, ptr [[VWT]], {{i64|i32}} 0, {{(i64|i32)}} 10 +// OPT: [[FLAGS_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 80 // OPT: [[FLAGS3:%.*]] = load i32, ptr [[FLAGS_VW]] // OPT: [[FLAGS:%.*]] = and i32 [[FLAGS3]], 255 -// OPT-64: %flags.alignmentMask = zext i32 [[FLAGS]] to i64 +// OPT-64: %flags.alignmentMask = zext nneg i32 [[FLAGS]] to i64 // OPT-64: [[TMP:%.*]] = add {{(i64|i32)}} [[SIZE_T]], %flags.alignmentMask // OPT-32: [[TMP:%.*]] = add {{(i64|i32)}} %flags.alignmentMask, [[SIZE_T]] // OPT: [[TMP2:%.*]] = add {{(i64|i32)}} [[TMP]], [[OBJECT]] diff --git a/test/IRGen/variadic_generic_functions.sil b/test/IRGen/variadic_generic_functions.sil index 3737ce93d186a..0d8257698e285 100644 --- a/test/IRGen/variadic_generic_functions.sil +++ b/test/IRGen/variadic_generic_functions.sil @@ -126,13 +126,13 @@ sil @associatedtype_with_added_conformance_2_callee : $ () -> () {} // CHECK-SAME: ptr %"each T", // CHECK-SAME: ptr %"each T.Q") // CHECK: [[GEN2_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] -// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[GEN2_CONFORMANCES_TO_Q:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] // CHECK: call swiftcc void @associatedtype_with_forwarded_conformance_1_callee( // CHECK-SAME: [[INT]] [[SHAPE]], // CHECK-SAME: ptr [[GEN2_TYPES]], // CHECK-SAME: ptr [[GEN2_CONFORMANCES_TO_Q]]) -// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STORED_STACK_LOC]]) sil @associatedtype_with_forwarded_conformance_1 : $ () -> () { %i = function_ref @associatedtype_with_forwarded_conformance_1_callee : $@convention(thin) () -> () apply %i}>() : $@convention(thin) () -> () @@ -149,14 +149,14 @@ sil @associatedtype_with_forwarded_conformance_1_callee : $ () -> () // CHECK-SAME: ptr %"each T.PA", // CHECK-SAME: ptr %"(each T).A.Q") // CHECK: [[GEN1_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] -// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[GEN1_CONFORMANCES_TO_PA:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] // CHECK: call swiftcc void @generictype_with_forwarded_conformance_2_callee( // CHECK-SAME: [[INT]] [[SHAPE]], // CHECK-SAME: ptr [[GEN1_TYPES]], // CHECK-SAME: ptr [[GEN1_CONFORMANCES_TO_PA]], // CHECK-SAME: ptr %"(each T).A.Q") -// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STORED_STACK_LOC]]) sil @generictype_with_forwarded_conformance_2 : $() -> () { %callee = function_ref @generictype_with_forwarded_conformance_2_callee : $@convention(thin) () -> () apply %callee}>() : $@convention(thin) () -> () @@ -172,14 +172,14 @@ sil @generictype_with_forwarded_conformance_2_callee : $ () -> () { %callee = function_ref @generic_with_forwarded_conformance_3_callee : $@convention(thin) () -> () apply %callee>}>() : $@convention(thin) () -> () diff --git a/test/IRGen/variadic_generics.sil b/test/IRGen/variadic_generics.sil index 3fb598b5e6b8c..4876fe99b1d17 100644 --- a/test/IRGen/variadic_generics.sil +++ b/test/IRGen/variadic_generics.sil @@ -105,9 +105,9 @@ bb0(%pack : $*Pack{Int, repeat each T, Int}, %value : $Int): // CHECK-LABEL: define {{.*}}@test_pack_alloc_1_dynamic( // CHECK-SAME: [[INT]] [[PACK_SIZE:%[^,]+]] // CHECK: [[SIZE:%[^,]+]] = add [[INT]] [[PACK_SIZE]], [[PACK_SIZE]] -// CHECK: [[SP_SAVE:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[SP_SAVE:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: alloca ptr, [[INT]] [[SIZE]] -// CHECK: call void @llvm.stackrestore(ptr [[SP_SAVE]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[SP_SAVE]]) sil @test_pack_alloc_1_dynamic : $ () -> () { // Control flow so that stack saving/restoring is emitted entry: diff --git a/validation-test/IRGen/rdar114013709.swift b/validation-test/IRGen/rdar114013709.swift index 71b1549c0d508..dc04b86ad3eb0 100644 --- a/validation-test/IRGen/rdar114013709.swift +++ b/validation-test/IRGen/rdar114013709.swift @@ -1,6 +1,6 @@ // RUN: %target-swift-frontend -O -primary-file %s -disable-availability-checking -emit-ir | %FileCheck %s -// CHECK: define{{( dllexport)?}}{{( protected)?}} i32 @main{{.*}} { +// CHECK: define{{( dllexport)?}}{{( protected)?}}{{( noundef)?}} i32 @main{{.*}} { // CHECK: store ptr %{{[0-9]+}}, ptr @"$s13rdar1140137091xQrvp" actor Actor {} let x: some Actor = Actor() From 70ca47818f495263d5dd0ed8de1e35bc9e133728 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Thu, 2 May 2024 07:48:47 -0700 Subject: [PATCH 040/110] Fix test IRGen/large_argument_result_c.swift --- test/IRGen/large_argument_result_c.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/IRGen/large_argument_result_c.swift b/test/IRGen/large_argument_result_c.swift index 198ad58293a81..c90042fbd4b66 100644 --- a/test/IRGen/large_argument_result_c.swift +++ b/test/IRGen/large_argument_result_c.swift @@ -16,7 +16,7 @@ // CHECK: call void @pass_and_return(ptr {{.*}} [[CALL_ALLOCA]], ptr nonnull [[TMP_ALLOCA]], ptr nonnull [[TMP_ALLOCA2]]) // CHECK: call {{.*}} @swift_allocObject // CHECK: [[BOX:%.*]] = call noalias ptr @swift_allocObject( -// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr %8, i64 16 +// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr [[BOX]], i64 16 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} [[ADDR_IN_BOX]], ptr {{.*}} [[CALL_ALLOCA]], i64 128, i1 false) // CHECK: call void @llvm.lifetime.end.p0(i64 128, ptr nonnull [[CALL_ALLOCA]]) public func runTest(_ l : large_thing) { From cf6193c0dba3ef3bf31c13fed0f089644f24ae04 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Thu, 2 May 2024 12:32:17 -0700 Subject: [PATCH 041/110] [Rebranch] Test: Redefine some macros. Clang fixed a bug that was masking the fact that these macros aren't always defined in cases we care about. Just define our own version of them for these tests. rdar://127427660 --- test/IRGen/entrypoint-section-run-main_swift.cpp | 9 ++++++++- test/IRGen/entrypoint-section-run.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/IRGen/entrypoint-section-run-main_swift.cpp b/test/IRGen/entrypoint-section-run-main_swift.cpp index a83299ab88e5e..0e43b2f7a14ff 100644 --- a/test/IRGen/entrypoint-section-run-main_swift.cpp +++ b/test/IRGen/entrypoint-section-run-main_swift.cpp @@ -24,6 +24,13 @@ using mach_header_platform = mach_header_64; using mach_header_platform = mach_header; #endif +#if __has_feature(ptrauth_function_pointer_type_discrimination) +#define my_ptrauth_function_pointer_type_discriminator(__type) \ + __builtin_ptrauth_type_discriminator(__type) +#else +#define my_ptrauth_function_pointer_type_discriminator(__type) ((ptrauth_extra_data_t)0) +#endif + int main(int argc, char *argv[]) { if (argc != 2) { printf("no argument!\n"); @@ -67,7 +74,7 @@ int main(int argc, char *argv[]) { reinterpret_cast(data) + offset ), ptrauth_key_function_pointer, - ptrauth_function_pointer_type_discriminator(MainFunction) + my_ptrauth_function_pointer_type_discriminator(MainFunction) ) ); diff --git a/test/IRGen/entrypoint-section-run.cpp b/test/IRGen/entrypoint-section-run.cpp index 22c47354fe3a9..a429f5896f9f9 100644 --- a/test/IRGen/entrypoint-section-run.cpp +++ b/test/IRGen/entrypoint-section-run.cpp @@ -23,6 +23,13 @@ using mach_header_platform = mach_header_64; using mach_header_platform = mach_header; #endif +#if __has_feature(ptrauth_function_pointer_type_discrimination) +#define my_ptrauth_function_pointer_type_discriminator(__type) \ + __builtin_ptrauth_type_discriminator(__type) +#else +#define my_ptrauth_function_pointer_type_discriminator(__type) ((ptrauth_extra_data_t)0) +#endif + int main(int argc, char *argv[]) { if (argc != 2) { printf("no argument!\n"); @@ -66,7 +73,7 @@ int main(int argc, char *argv[]) { reinterpret_cast(data) + offset ), ptrauth_key_function_pointer, - ptrauth_function_pointer_type_discriminator(MainFunction) + my_ptrauth_function_pointer_type_discriminator(MainFunction) ) ); From 195fe84e1863d8310b25eec9ab695f794a4bd8d3 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Fri, 3 May 2024 11:04:14 -0700 Subject: [PATCH 042/110] [rebranch] Fix validation-test/IRGen/pack_stack_metadata_alloc_loop.sil --- .../IRGen/pack_stack_metadata_alloc_loop.sil | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil index e788af1a5a327..65b5f9e2ea237 100644 --- a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil +++ b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil @@ -36,11 +36,11 @@ sil @callee : $@convention(thin) () -> () { // CHECK: [[HEADER]]: // CHECK: [[PREVIOUS:%[^,]+]] = phi i64 [ 10000000, %[[ENTRY]] ], [ [[REMAINING:%[^,]+]], %{{[^,]+}} ] // CHECK: [[COMBINED_PACK_SIZE:%[^,]+]] = add [[INT]] %0, %1 -// CHECK: [[STACK_BEFORE_FIRST_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STACK_BEFORE_FIRST_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[FIRST_ALLOCA_METADATA_PACK:%[^,]+]] = alloca ptr, [[INT]] [[COMBINED_PACK_SIZE]] // CHECK: call swiftcc void @callee([[INT]] [[COMBINED_PACK_SIZE]], ptr [[FIRST_ALLOCA_METADATA_PACK]]) // CHECK: [[COMBINED_PACK_SIZE_2:%[^,]+]] = add [[INT]] %1, %0 -// CHECK: [[STACK_BEFORE_SECOND_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STACK_BEFORE_SECOND_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[SECOND_ALLOCA_METADATA_PACK:%[^,]+]] = alloca ptr, [[INT]] [[COMBINED_PACK_SIZE_2]] // CHECK: call swiftcc void @callee([[INT]] [[COMBINED_PACK_SIZE_2]], ptr [[SECOND_ALLOCA_METADATA_PACK]]) // CHECK: [[REMAINING_AND_OVERFLOW:%[^,]+]] = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 [[PREVIOUS]], i64 1) @@ -48,12 +48,14 @@ sil @callee : $@convention(thin) () -> () { // CHECK: [[IS_ZERO:%[^,]+]] = icmp eq i64 [[REMAINING]], 0 // CHECK: br i1 [[IS_ZERO]], label %[[EXIT:[^,]+]], label %[[BACKEDGE:[^,]+]] // CHECK: [[BACKEDGE]]: -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) // CHECK: br label %[[HEADER]] // CHECK: [[EXIT]]: -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) +// CHECK: [[STACK_BEFORE_SECOND_ALLOCAlcssa:%.*]] = phi ptr [ [[STACK_BEFORE_SECOND_ALLOCA]], %{{.*}} ] +// CHECK: [[STACK_BEFORE_FIRST_ALLOCAlcssa:%.*]] = phi ptr [ [[STACK_BEFORE_FIRST_ALLOCA]], %{{.*}} ] +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_SECOND_ALLOCAlcssa]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_FIRST_ALLOCAlcssa]]) // CHECK: ret void // CHECK: } sil @looper : $@convention(thin) () -> () { From 3674539ae849bcff7b62c6af3367a2a9d56a8516 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 15 May 2024 17:35:43 -0700 Subject: [PATCH 043/110] [Test] Un-xfail passing load-target-normalization.swift test Fixes #54797. Resolves rdar://60097045. --- test/Serialization/load-target-normalization.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/Serialization/load-target-normalization.swift b/test/Serialization/load-target-normalization.swift index 50b42addef435..09f3483219a13 100644 --- a/test/Serialization/load-target-normalization.swift +++ b/test/Serialization/load-target-normalization.swift @@ -1,10 +1,6 @@ // RUN: %empty-directory(%t/ForeignModule.swiftmodule) // RUN: touch %t/ForeignModule.swiftmodule/garbage-garbage-garbage.swiftmodule -// https://github.com/apple/swift/issues/54797 -// This test crashes on 'next' branch. -// XFAIL: asserts - // Test format: We try to import ForeignModule with architectures besides // garbage-garbage-garbage and check the target triple listed in the error // message to make sure it was normalized correctly. This works in lieu of a From cbc3cfe053a8b785c07b34ec585efb8e6c225e1b Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 21 May 2024 12:49:43 +0100 Subject: [PATCH 044/110] [cxx-interop][rebranch] Fix an IRGen test rdar://127263407 --- .../method/methods-this-and-indirect-return-irgen-itanium.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift index cc722ffb5e9d9..2cbba9a6571b6 100644 --- a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift +++ b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift @@ -14,4 +14,4 @@ public func use() -> CInt { // CHECK: %[[result:.*]] = alloca %TSo19NonTrivialInWrapperV // CHECK: call void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%TSo19NonTrivialInWrapperV) %[[result]], ptr %[[instance]], i32 42) -// CHECK: define {{.*}} void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, ptr {{.*}} %{{.*}}, i32 noundef %{{.*}}) +// CHECK: define {{.*}} void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, ptr {{.*}} %{{.*}}, i32{{( noundef)?}} %{{.*}}) From 40f516a1b8b7a45b398121187854139e8aa690db Mon Sep 17 00:00:00 2001 From: Dario Rexin Date: Tue, 21 May 2024 15:17:17 -0700 Subject: [PATCH 045/110] [Test] Fix signature mismatch in issue-58123-invalid-debug-info.swift rdar://128431000 Made the matcher more robust for potential future added modifiers. --- .../issue-58123-invalid-debug-info.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift index 081606ba3b358..e1295423fb6ec 100644 --- a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift +++ b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift @@ -4,7 +4,7 @@ // Mutating functions with control flow can cause assertion failure for // conflicting debug variable type -// CHECK-LABEL: define internal swiftcc float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA" +// CHECK-LABEL: define internal swiftcc{{.*}} float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA" // CHECK: [[SELF:%.*]] = alloca %T4main8TestTypeV06ManualB7TangentV // CHECK: call void @llvm.dbg.declare(metadata ptr [[SELF]] From de06df9fc677bea26d81b011c4f0dfd104de3ce5 Mon Sep 17 00:00:00 2001 From: Dario Rexin Date: Thu, 23 May 2024 16:41:20 -0700 Subject: [PATCH 046/110] [Test] Require arm64 in pack_stack_metadata_alloc_loop.sil rdar://128431285 --- validation-test/IRGen/pack_stack_metadata_alloc_loop.sil | 1 + 1 file changed, 1 insertion(+) diff --git a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil index 65b5f9e2ea237..10bcbcbebfb9f 100644 --- a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil +++ b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil @@ -2,6 +2,7 @@ // RUN: %target-swift-frontend -parse-sil -enable-pack-metadata-stack-promotion=true -emit-ir -primary-file %s | %IRGenFileCheck %s // REQUIRES: executable_test +// REQUIRES: CPU=arm64 // Allocate metadata packs on the stack in a loop. If these packs weren't // deallocated, the stack would be exhausted. From 703dba9846ba25c8e9255a6976cd7a11ddbb86bc Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 27 Jun 2024 20:52:33 -0700 Subject: [PATCH 047/110] Rename `erase_value` to `erase` `llvm::erase_value` was deprecated and removed. --- include/swift/AST/PluginRegistry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/swift/AST/PluginRegistry.h b/include/swift/AST/PluginRegistry.h index 3f417e1ad3d55..10142459d73db 100644 --- a/include/swift/AST/PluginRegistry.h +++ b/include/swift/AST/PluginRegistry.h @@ -88,7 +88,7 @@ class CompilerPlugin { /// Remove "on reconnect" callback. void removeOnReconnect(std::function *fn) { - llvm::erase_value(onReconnect, fn); + llvm::erase(onReconnect, fn); } ArrayRef *> getOnReconnectCallbacks() { From a6cf31036a0939ac43b71c7ea236413c3b1f129f Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 27 Jun 2024 22:01:40 -0700 Subject: [PATCH 048/110] Add AMDGPU builtin handling --- lib/AST/ClangTypeConverter.cpp | 6 ++- lib/ClangImporter/ClangAdapter.cpp | 81 ++++++++---------------------- lib/ClangImporter/ImportType.cpp | 73 +++++++-------------------- lib/IRGen/GenCall.cpp | 61 ++++------------------ 4 files changed, 54 insertions(+), 167 deletions(-) diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index 3c956ca8c05bb..f9e573c8d5ded 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -75,10 +75,14 @@ getClangBuiltinTypeFromKind(const clang::ASTContext &context, case clang::BuiltinType::Id: \ return context.Id##Ty; #include "clang/Basic/RISCVVTypes.def" -#define WASM_REF_TYPE(Name, MangedNameBase, Id, SingletonId, AS) \ +#define WASM_REF_TYPE(Name, MangledNameBase, Id, SingletonId, AS) \ case clang::BuiltinType::Id: \ return context.SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) \ + case clang::BuiltinType::Id: \ + return context.SingletonId; +#include "clang/Basic/AMDGPUTypes.def" } // Not a valid BuiltinType. diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index 4c02ab936b3bd..8f595d59aca2d 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -407,87 +407,48 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, case clang::BuiltinType::ObjCSel: return OmissionTypeName(); - // OpenCL types that don't have Swift equivalents. - case clang::BuiltinType::OCLImage1dRO: - case clang::BuiltinType::OCLImage1dRW: - case clang::BuiltinType::OCLImage1dWO: - case clang::BuiltinType::OCLImage1dArrayRO: - case clang::BuiltinType::OCLImage1dArrayRW: - case clang::BuiltinType::OCLImage1dArrayWO: - case clang::BuiltinType::OCLImage1dBufferRO: - case clang::BuiltinType::OCLImage1dBufferRW: - case clang::BuiltinType::OCLImage1dBufferWO: - case clang::BuiltinType::OCLImage2dRO: - case clang::BuiltinType::OCLImage2dRW: - case clang::BuiltinType::OCLImage2dWO: - case clang::BuiltinType::OCLImage2dArrayRO: - case clang::BuiltinType::OCLImage2dArrayRW: - case clang::BuiltinType::OCLImage2dArrayWO: - case clang::BuiltinType::OCLImage2dDepthRO: - case clang::BuiltinType::OCLImage2dDepthRW: - case clang::BuiltinType::OCLImage2dDepthWO: - case clang::BuiltinType::OCLImage2dArrayDepthRO: - case clang::BuiltinType::OCLImage2dArrayDepthRW: - case clang::BuiltinType::OCLImage2dArrayDepthWO: - case clang::BuiltinType::OCLImage2dMSAARO: - case clang::BuiltinType::OCLImage2dMSAARW: - case clang::BuiltinType::OCLImage2dMSAAWO: - case clang::BuiltinType::OCLImage2dArrayMSAARO: - case clang::BuiltinType::OCLImage2dArrayMSAARW: - case clang::BuiltinType::OCLImage2dArrayMSAAWO: - case clang::BuiltinType::OCLImage2dMSAADepthRO: - case clang::BuiltinType::OCLImage2dMSAADepthRW: - case clang::BuiltinType::OCLImage2dMSAADepthWO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRW: - case clang::BuiltinType::OCLImage2dArrayMSAADepthWO: - case clang::BuiltinType::OCLImage3dRO: - case clang::BuiltinType::OCLImage3dRW: - case clang::BuiltinType::OCLImage3dWO: - case clang::BuiltinType::OCLSampler: - case clang::BuiltinType::OCLEvent: - case clang::BuiltinType::OCLClkEvent: - case clang::BuiltinType::OCLQueue: - case clang::BuiltinType::OCLReserveID: - case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCImePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCMceResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResult: - case clang::BuiltinType::OCLIntelSubgroupAVCRefResult: - case clang::BuiltinType::OCLIntelSubgroupAVCSicResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin: - case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin: - return OmissionTypeName(); - // OpenMP types that don't have Swift equivalents. case clang::BuiltinType::OMPArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return OmissionTypeName(); + // OpenCL builtin types that don't have Swift equivalents. + case clang::BuiltinType::OCLClkEvent: + case clang::BuiltinType::OCLEvent: + case clang::BuiltinType::OCLSampler: + case clang::BuiltinType::OCLQueue: + case clang::BuiltinType::OCLReserveID: +#define IMAGE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLImageTypes.def" +#define EXT_OPAQUE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLExtensionTypes.def" + return OmissionTypeName(); + // ARM SVE builtin types that don't have Swift equivalents. #define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" return OmissionTypeName(); // PPC MMA builtin types that don't have Swift equivalents. -#define PPC_VECTOR_TYPE(Name, Id, Size) case clang::BuiltinType::Id: +#define PPC_VECTOR_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/PPCTypes.def" return OmissionTypeName(); // RISC-V V builtin types that don't have Swift equivalents. -#define RVV_TYPE(Name, Id, Size) case clang::BuiltinType::Id: +#define RVV_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/RISCVVTypes.def" return OmissionTypeName(); - // WAM builtin types that don't have Swift equivalents. -#define WASM_TYPE(Name, Id, Size) case clang::BuiltinType::Id: + // WASM builtin types that don't have Swift equivalents. +#define WASM_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/WebAssemblyReferenceTypes.def" return OmissionTypeName(); + + // AMDGPU builtins that don't have Swift equivalents. +#define AMDGPU_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/AMDGPUTypes.def" + return OmissionTypeName(); } } diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 520cedc75886f..f660fad4bc0e3 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -325,68 +325,24 @@ namespace { case clang::BuiltinType::ObjCSel: return Type(); - // OpenCL types that don't have Swift equivalents. - case clang::BuiltinType::OCLImage1dRO: - case clang::BuiltinType::OCLImage1dRW: - case clang::BuiltinType::OCLImage1dWO: - case clang::BuiltinType::OCLImage1dArrayRO: - case clang::BuiltinType::OCLImage1dArrayRW: - case clang::BuiltinType::OCLImage1dArrayWO: - case clang::BuiltinType::OCLImage1dBufferRO: - case clang::BuiltinType::OCLImage1dBufferRW: - case clang::BuiltinType::OCLImage1dBufferWO: - case clang::BuiltinType::OCLImage2dRO: - case clang::BuiltinType::OCLImage2dRW: - case clang::BuiltinType::OCLImage2dWO: - case clang::BuiltinType::OCLImage2dArrayRO: - case clang::BuiltinType::OCLImage2dArrayRW: - case clang::BuiltinType::OCLImage2dArrayWO: - case clang::BuiltinType::OCLImage2dDepthRO: - case clang::BuiltinType::OCLImage2dDepthRW: - case clang::BuiltinType::OCLImage2dDepthWO: - case clang::BuiltinType::OCLImage2dArrayDepthRO: - case clang::BuiltinType::OCLImage2dArrayDepthRW: - case clang::BuiltinType::OCLImage2dArrayDepthWO: - case clang::BuiltinType::OCLImage2dMSAARO: - case clang::BuiltinType::OCLImage2dMSAARW: - case clang::BuiltinType::OCLImage2dMSAAWO: - case clang::BuiltinType::OCLImage2dArrayMSAARO: - case clang::BuiltinType::OCLImage2dArrayMSAARW: - case clang::BuiltinType::OCLImage2dArrayMSAAWO: - case clang::BuiltinType::OCLImage2dMSAADepthRO: - case clang::BuiltinType::OCLImage2dMSAADepthRW: - case clang::BuiltinType::OCLImage2dMSAADepthWO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRW: - case clang::BuiltinType::OCLImage2dArrayMSAADepthWO: - case clang::BuiltinType::OCLImage3dRO: - case clang::BuiltinType::OCLImage3dRW: - case clang::BuiltinType::OCLImage3dWO: - case clang::BuiltinType::OCLSampler: - case clang::BuiltinType::OCLEvent: - case clang::BuiltinType::OCLClkEvent: - case clang::BuiltinType::OCLQueue: - case clang::BuiltinType::OCLReserveID: - case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCImePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCMceResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResult: - case clang::BuiltinType::OCLIntelSubgroupAVCRefResult: - case clang::BuiltinType::OCLIntelSubgroupAVCSicResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin: - case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin: - return Type(); - // OpenMP types that don't have Swift equivalents. case clang::BuiltinType::OMPArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return Type(); + // OpenCL builtin types that don't have Swift equivalents. + case clang::BuiltinType::OCLClkEvent: + case clang::BuiltinType::OCLEvent: + case clang::BuiltinType::OCLSampler: + case clang::BuiltinType::OCLQueue: + case clang::BuiltinType::OCLReserveID: +#define IMAGE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLImageTypes.def" +#define EXT_OPAQUE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLExtensionTypes.def" + return Type(); + // ARM SVE builtin types that don't have Swift equivalents. #define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" @@ -406,6 +362,11 @@ namespace { #include "clang/Basic/WebAssemblyReferenceTypes.def" return Type(); + // AMDGPU builtin types that don't have Swift equivalents. +#define AMDGPU_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id: +#include "clang/Basic/AMDGPUTypes.def" + return Type(); + } llvm_unreachable("Invalid BuiltinType."); diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 74b6d3658732a..fb7321c7f5173 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -1242,59 +1242,15 @@ namespace { llvm_unreachable("bare void type in ABI lowering"); // We should never see the OpenCL builtin types at all. - case clang::BuiltinType::OCLImage1dRO: - case clang::BuiltinType::OCLImage1dRW: - case clang::BuiltinType::OCLImage1dWO: - case clang::BuiltinType::OCLImage1dArrayRO: - case clang::BuiltinType::OCLImage1dArrayRW: - case clang::BuiltinType::OCLImage1dArrayWO: - case clang::BuiltinType::OCLImage1dBufferRO: - case clang::BuiltinType::OCLImage1dBufferRW: - case clang::BuiltinType::OCLImage1dBufferWO: - case clang::BuiltinType::OCLImage2dRO: - case clang::BuiltinType::OCLImage2dRW: - case clang::BuiltinType::OCLImage2dWO: - case clang::BuiltinType::OCLImage2dArrayRO: - case clang::BuiltinType::OCLImage2dArrayRW: - case clang::BuiltinType::OCLImage2dArrayWO: - case clang::BuiltinType::OCLImage2dDepthRO: - case clang::BuiltinType::OCLImage2dDepthRW: - case clang::BuiltinType::OCLImage2dDepthWO: - case clang::BuiltinType::OCLImage2dArrayDepthRO: - case clang::BuiltinType::OCLImage2dArrayDepthRW: - case clang::BuiltinType::OCLImage2dArrayDepthWO: - case clang::BuiltinType::OCLImage2dMSAARO: - case clang::BuiltinType::OCLImage2dMSAARW: - case clang::BuiltinType::OCLImage2dMSAAWO: - case clang::BuiltinType::OCLImage2dArrayMSAARO: - case clang::BuiltinType::OCLImage2dArrayMSAARW: - case clang::BuiltinType::OCLImage2dArrayMSAAWO: - case clang::BuiltinType::OCLImage2dMSAADepthRO: - case clang::BuiltinType::OCLImage2dMSAADepthRW: - case clang::BuiltinType::OCLImage2dMSAADepthWO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRO: - case clang::BuiltinType::OCLImage2dArrayMSAADepthRW: - case clang::BuiltinType::OCLImage2dArrayMSAADepthWO: - case clang::BuiltinType::OCLImage3dRO: - case clang::BuiltinType::OCLImage3dRW: - case clang::BuiltinType::OCLImage3dWO: - case clang::BuiltinType::OCLSampler: - case clang::BuiltinType::OCLEvent: case clang::BuiltinType::OCLClkEvent: + case clang::BuiltinType::OCLEvent: + case clang::BuiltinType::OCLSampler: case clang::BuiltinType::OCLQueue: case clang::BuiltinType::OCLReserveID: - case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCImePayload: - case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload: - case clang::BuiltinType::OCLIntelSubgroupAVCMceResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResult: - case clang::BuiltinType::OCLIntelSubgroupAVCRefResult: - case clang::BuiltinType::OCLIntelSubgroupAVCSicResult: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout: - case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin: - case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin: +#define IMAGE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLImageTypes.def" +#define EXT_OPAQUE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/OpenCLExtensionTypes.def" llvm_unreachable("OpenCL type in ABI lowering"); // We should never see ARM SVE types at all. @@ -1316,6 +1272,11 @@ namespace { #include "clang/Basic/WebAssemblyReferenceTypes.def" llvm_unreachable("WASM type in ABI lowering"); + // We should never see AMDGPU types at all. +#define AMDGPU_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/AMDGPUTypes.def" + llvm_unreachable("AMDGPU type in ABI lowering"); + // Handle all the integer types as opaque values. #define BUILTIN_TYPE(Id, SingletonId) #define SIGNED_TYPE(Id, SingletonId) \ From c4fd432b6ca2163973e1df3a707cb2cdcac39966 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 27 Jun 2024 20:52:01 -0700 Subject: [PATCH 049/110] [SIL] Add missing ilist details --- include/swift/SIL/SILInstruction.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index c6b42b12db6d9..4f84c9ff5de57 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -58,7 +58,7 @@ namespace ilist_detail { /// /// We need a custom base class to not clear the prev/next pointers when /// removing an instruction from the list. -class SILInstructionListBase : public ilist_base { +class SILInstructionListBase : public ilist_base { public: /// Remove an instruction from the list. /// @@ -96,7 +96,8 @@ template <> struct compute_node_options<::swift::SILInstruction> { static const bool is_sentinel_tracking_explicit = false; static const bool has_iterator_bits = false; typedef void tag; - typedef ilist_node_base node_base_type; + typedef void parent_ty; + typedef ilist_node_base node_base_type; typedef SILInstructionListBase list_base_type; }; }; From 4ee4c0fbac53550b12f2edd948325f19c19a13c8 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 27 Jun 2024 23:24:15 -0700 Subject: [PATCH 050/110] [IRGen] Use new `ASSERT` macro over `requires` `requires` was removed and replaced with `ASSERT`. --- lib/IRGen/GenConstant.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/IRGen/GenConstant.cpp b/lib/IRGen/GenConstant.cpp index ae70237728615..8dbfd6563f152 100644 --- a/lib/IRGen/GenConstant.cpp +++ b/lib/IRGen/GenConstant.cpp @@ -31,7 +31,6 @@ #include "swift/IRGen/Linking.h" #include "swift/Basic/Assertions.h" #include "swift/Basic/Range.h" -#include "swift/Basic/Require.h" #include "swift/SIL/SILModule.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Support/BLAKE3.h" @@ -331,8 +330,8 @@ Explosion irgen::emitConstantValue(IRGenModule &IGM, SILValue operand, auto *result = llvm::ConstantFoldCastOperand( llvm::Instruction::ZExt, val, storageTy, IGM.DataLayout); - require(result != nullptr, - "couldn't constant fold initializer expression"); + ASSERT(result != nullptr && + "couldn't constant fold initializer expression"); return result; } case BuiltinValueKind::StringObjectOr: { From 8e9ac93bd3b4d5b93dd1bcde4ad73d562ea0ece4 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 28 Jun 2024 14:11:40 -0700 Subject: [PATCH 051/110] [IRGen] Use `ConstantInt` for `otherDiscriminator` --- lib/IRGen/GenConstant.cpp | 3 +-- lib/IRGen/GenPointerAuth.cpp | 19 +++++++++++-------- lib/IRGen/IRGenModule.h | 8 ++++---- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/IRGen/GenConstant.cpp b/lib/IRGen/GenConstant.cpp index 8dbfd6563f152..aaa064c97abe2 100644 --- a/lib/IRGen/GenConstant.cpp +++ b/lib/IRGen/GenConstant.cpp @@ -404,8 +404,7 @@ Explosion irgen::emitConstantValue(IRGenModule &IGM, SILValue operand, auto authInfo = PointerAuthInfo::forFunctionPointer(IGM, fnType); if (authInfo.isSigned()) { auto constantDiscriminator = - cast(authInfo.getDiscriminator()); - assert(!constantDiscriminator->getType()->isPointerTy()); + cast(authInfo.getDiscriminator()); fnPtr = IGM.getConstantSignedPointer(fnPtr, authInfo.getKey(), nullptr, constantDiscriminator); } diff --git a/lib/IRGen/GenPointerAuth.cpp b/lib/IRGen/GenPointerAuth.cpp index 23006d5e0d1dd..d0cbb9264ab11 100644 --- a/lib/IRGen/GenPointerAuth.cpp +++ b/lib/IRGen/GenPointerAuth.cpp @@ -128,11 +128,14 @@ llvm::Value *irgen::emitPointerAuthSign(IRGenFunction &IGF, llvm::Value *fnPtr, if (auto constantFnPtr = dyn_cast(fnPtr)) { if (auto constantDiscriminator = dyn_cast(newAuthInfo.getDiscriminator())) { - llvm::Constant *other = nullptr, *address = nullptr; - if (constantDiscriminator->getType()->isPointerTy()) + llvm::Constant *address = nullptr; + llvm::ConstantInt *other = nullptr; + if (constantDiscriminator->getType()->isPointerTy()) { address = constantDiscriminator; - else - other = constantDiscriminator; + } else if (auto otherDiscriminator = + dyn_cast(constantDiscriminator)) { + other = otherDiscriminator; + } return IGF.IGM.getConstantSignedPointer(constantFnPtr, newAuthInfo.getKey(), address, other); @@ -716,10 +719,10 @@ IRGenModule::getConstantSignedCFunctionPointer(llvm::Constant *fn) { return fn; } -llvm::Constant *IRGenModule::getConstantSignedPointer(llvm::Constant *pointer, - unsigned key, - llvm::Constant *storageAddress, - llvm::Constant *otherDiscriminator) { +llvm::Constant * +IRGenModule::getConstantSignedPointer(llvm::Constant *pointer, unsigned key, + llvm::Constant *storageAddress, + llvm::ConstantInt *otherDiscriminator) { return clang::CodeGen::getConstantSignedPointer(getClangCGM(), pointer, key, storageAddress, otherDiscriminator); diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index dffeb0ca20ba2..9ae62970b8428 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -1200,10 +1200,10 @@ class IRGenModule { llvm::Constant *getConstantSignedCFunctionPointer(llvm::Constant *fn); - llvm::Constant *getConstantSignedPointer(llvm::Constant *pointer, - unsigned key, - llvm::Constant *addrDiscriminator, - llvm::Constant *otherDiscriminator); + llvm::Constant * + getConstantSignedPointer(llvm::Constant *pointer, unsigned key, + llvm::Constant *storageAddress, + llvm::ConstantInt *otherDiscriminator); llvm::Constant *getConstantSignedPointer(llvm::Constant *pointer, const clang::PointerAuthSchema &schema, const PointerAuthEntity &entity, From 4a5e1cd3da685be23bea33801345aa62798c1ae6 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 20:13:41 -0700 Subject: [PATCH 052/110] [ClangImporter] Add missing include --- include/swift/ClangImporter/ClangModule.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/swift/ClangImporter/ClangModule.h b/include/swift/ClangImporter/ClangModule.h index 470c7b481f4b4..29cf61c9b64c9 100644 --- a/include/swift/ClangImporter/ClangModule.h +++ b/include/swift/ClangImporter/ClangModule.h @@ -20,6 +20,7 @@ #include "swift/Basic/Version.h" #include "swift/ClangImporter/ClangImporter.h" #include "clang/AST/ExternalASTSource.h" +#include "clang/Basic/ASTSourceDescriptor.h" #include "clang/Basic/Module.h" namespace clang { From 701800fbeb343e148b45afa993b8bf6d80194c8b Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 21:25:31 -0700 Subject: [PATCH 053/110] [ClangImporter] Handle `DefaultArgument` now being a `TemplateArgmentLoc` This was changed in upstream LLVM 142c3f394e1b34dcefcaf0887a6fd4711b78eeb3. --- lib/AST/ClangTypeConverter.cpp | 4 ++-- lib/ClangImporter/ImportDecl.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index f9e573c8d5ded..37742fbad9f69 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -895,8 +895,8 @@ ClangTypeConverter::getClangTemplateArguments( auto templateParam = cast(param); // We must have found a defaulted parameter at the end of the list. if (templateParam->getIndex() >= genericArgs.size()) { - templateArgs.push_back( - clang::TemplateArgument(templateParam->getDefaultArgument())); + templateArgs.push_back(clang::TemplateArgument( + templateParam->getDefaultArgument().getArgument())); continue; } diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 2156d6ea1689e..ad91cda5031c7 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3457,8 +3457,9 @@ namespace { // parameters when the function template is instantiated, so do not // import the function template if the template parameter has // dependent default value. - auto defaultArgumentType = templateTypeParam->getDefaultArgument(); - if (defaultArgumentType->isDependentType()) + auto &defaultArgument = + templateTypeParam->getDefaultArgument().getArgument(); + if (defaultArgument.isDependent()) return nullptr; continue; } From 226ba82525f87e9d6d7c11cc73b5aa7b8b01f37e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 21:30:30 -0700 Subject: [PATCH 054/110] [ClangImporter] Add various `const` `getSelector` now takes a `const clang::IdentifierInfo *` `ArrayRef`. Sprinkle a bunch of `const`s in. --- .../ClangImporter/SwiftAbstractBasicReader.h | 2 +- lib/ClangImporter/ClangImporter.cpp | 18 +++++++++--------- lib/ClangImporter/ImportName.cpp | 2 +- .../lib/SwiftLang/SwiftSourceDocInfo.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/swift/ClangImporter/SwiftAbstractBasicReader.h b/include/swift/ClangImporter/SwiftAbstractBasicReader.h index b5df306987b43..b5063c1c43493 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicReader.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicReader.h @@ -72,7 +72,7 @@ class DataStreamBasicReader return clang::Selector(); unsigned numArgs = unsigned(numArgsPlusOne - 1); - SmallVector chunks; + SmallVector chunks; for (unsigned i = 0, e = std::max(numArgs, 1U); i != e; ++i) chunks.push_back(asImpl().readIdentifier()); diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 1f46ab6ab16de..e0eb3f6e02ef8 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1510,18 +1510,18 @@ ClangImporter::create(ASTContext &ctx, importer->Impl.objectAtIndexedSubscript = clangContext.Selectors.getUnarySelector( &clangContext.Idents.get("objectAtIndexedSubscript")); - clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = { - &clangContext.Idents.get("setObject"), - &clangContext.Idents.get("atIndexedSubscript") + const clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = { + &clangContext.Idents.get("setObject"), + &clangContext.Idents.get("atIndexedSubscript"), }; importer->Impl.setObjectAtIndexedSubscript = clangContext.Selectors.getSelector(2, setObjectAtIndexedSubscriptIdents); importer->Impl.objectForKeyedSubscript = clangContext.Selectors.getUnarySelector( &clangContext.Idents.get("objectForKeyedSubscript")); - clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = { - &clangContext.Idents.get("setObject"), - &clangContext.Idents.get("forKeyedSubscript") + const clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = { + &clangContext.Idents.get("setObject"), + &clangContext.Idents.get("forKeyedSubscript"), }; importer->Impl.setObjectForKeyedSubscript = clangContext.Selectors.getSelector(2, setObjectForKeyedSubscriptIdents); @@ -2882,7 +2882,7 @@ ClangImporter::Implementation::exportSelector(DeclName name, clang::ASTContext &ctx = getClangASTContext(); - SmallVector pieces; + SmallVector pieces; pieces.push_back(exportName(name.getBaseIdentifier()).getAsIdentifierInfo()); auto argNames = name.getArgumentNames(); @@ -2901,7 +2901,7 @@ ClangImporter::Implementation::exportSelector(DeclName name, clang::Selector ClangImporter::Implementation::exportSelector(ObjCSelector selector) { - SmallVector pieces; + SmallVector pieces; for (auto piece : selector.getSelectorPieces()) pieces.push_back(exportName(piece).getAsIdentifierInfo()); return getClangASTContext().Selectors.getSelector(selector.getNumArgs(), @@ -2917,7 +2917,7 @@ isPotentiallyConflictingSetter(const clang::ObjCProtocolDecl *proto, if (sel.getNumArgs() != 1) return false; - clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0); + const clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0); if (!setterID || !setterID->getName().starts_with("set")) return false; diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index f8c3f69a8f818..d8af0c8045de0 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -1431,7 +1431,7 @@ bool NameImporter::hasErrorMethodNameCollision( unsigned numArgs = selector.getNumArgs(); assert(numArgs > 0); - SmallVector chunks; + SmallVector chunks; for (unsigned i = 0, e = selector.getNumArgs(); i != e; ++i) { chunks.push_back(selector.getIdentifierInfoForSlot(i)); } diff --git a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp index 9ec7a99e4f8a3..b3f9be68d82a7 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp @@ -1351,7 +1351,7 @@ getClangDeclarationName(const clang::NamedDecl *ND, NameTranslatingInfo &Info) { return clang::DeclarationName(); ArrayRef Args = llvm::ArrayRef(Info.ArgNames); - std::vector Pieces; + std::vector Pieces; for (unsigned i = 0; i < NumPieces; ++i) { if (i >= Info.ArgNames.size() || Info.ArgNames[i].empty()) { Pieces.push_back(OrigSel.getIdentifierInfoForSlot(i)); From b429c70a246d37073aac763d010e4dca1811d1c0 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 22:12:36 -0700 Subject: [PATCH 055/110] [ClangImporter] Handle split sema `Sema` was split up in LLVM upstream 31a203fa8af47a8b2e8e357857b114cf90638b2eq. --- lib/ClangImporter/ClangImporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index e0eb3f6e02ef8..c3d89ed21dff6 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -3951,11 +3951,12 @@ void ClangModuleUnit::lookupObjCMethods( // Collect all of the Objective-C methods with this selector. SmallVector objcMethods; auto &clangSema = owner.getClangSema(); - clangSema.CollectMultipleMethodsInGlobalPool(clangSelector, + auto &clangObjc = clangSema.ObjC(); + clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector, objcMethods, /*InstanceFirst=*/true, /*CheckTheOther=*/false); - clangSema.CollectMultipleMethodsInGlobalPool(clangSelector, + clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector, objcMethods, /*InstanceFirst=*/false, /*CheckTheOther=*/false); From 22cc33a09807aab16243f6a01ef279328f381cf6 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 22:14:43 -0700 Subject: [PATCH 056/110] [ClangImporter] Handle `pair` to actual struct change Use `FeatureName` rather than `first`. --- lib/ClangImporter/ClangImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index c3d89ed21dff6..40499193714f3 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -7894,7 +7894,7 @@ bool importer::requiresCPlusPlus(const clang::Module *module) { } return llvm::any_of(module->Requirements, [](clang::Module::Requirement req) { - return req.first == "cplusplus"; + return req.FeatureName == "cplusplus"; }); } From 701430f20943f39d742952772dcf42425b299a22 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 22:26:52 -0700 Subject: [PATCH 057/110] [ClangImporter] Add initial empty handling for `UnresolvedTemplate` --- lib/ClangImporter/ClangAdapter.cpp | 1 + lib/ClangImporter/ImportType.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index 8f595d59aca2d..e3144ca30438c 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -364,6 +364,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, case clang::BuiltinType::Overload: case clang::BuiltinType::PseudoObject: case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::UnresolvedTemplate: return OmissionTypeName(); // FIXME: Types that can be mapped, but aren't yet. diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index f660fad4bc0e3..a5a7b38dd9f96 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -284,6 +284,7 @@ namespace { case clang::BuiltinType::Overload: case clang::BuiltinType::PseudoObject: case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::UnresolvedTemplate: return Type(); // FIXME: Types that can be mapped, but aren't yet. From 47a06b232fb1d107e2ebd6157925940fd1b7744c Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 6 Jun 2024 17:55:59 -0700 Subject: [PATCH 058/110] [ClangImporter] Rename `isUnnamedBitfield` to `isUnnamedBitField` --- lib/ClangImporter/ImportDecl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index ad91cda5031c7..ccd091cf921d1 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -2237,7 +2237,7 @@ namespace { // Unnamed bitfields are just for padding and should not // inhibit creation of a memberwise initializer. - if (field->isUnnamedBitfield()) { + if (field->isUnnamedBitField()) { hasUnreferenceableStorage = true; continue; } @@ -9213,7 +9213,7 @@ void ClangImporter::Implementation::loadAllMembersOfRecordDecl( // Currently, we don't import unnamed bitfields. if (isa(m) && - cast(m)->isUnnamedBitfield()) + cast(m)->isUnnamedBitField()) continue; // Make sure we always pull in record fields. Everything else had better From f375e36cc86ed508102a74fe23d14c71ff3c2cd0 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 22:22:01 -0700 Subject: [PATCH 059/110] [ClangImporter] Rename `OMPArraySection` to `ArraySection` --- lib/ClangImporter/ClangAdapter.cpp | 2 +- lib/ClangImporter/ImportType.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index e3144ca30438c..f832a5af21f05 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -409,7 +409,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, return OmissionTypeName(); // OpenMP types that don't have Swift equivalents. - case clang::BuiltinType::OMPArraySection: + case clang::BuiltinType::ArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return OmissionTypeName(); diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index a5a7b38dd9f96..b316e96da65f0 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -327,7 +327,7 @@ namespace { return Type(); // OpenMP types that don't have Swift equivalents. - case clang::BuiltinType::OMPArraySection: + case clang::BuiltinType::ArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return Type(); From 70c348129f46f3d9232c565acd880df68ebbee02 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 5 Jun 2024 23:30:00 -0700 Subject: [PATCH 060/110] [ClangImporter] Use new `LocalDeclID` There were a number of upstream LLVM changes to `DeclID` in order to separate "local" and "global" IDs: https://github.com/llvm/llvm-project/commit/07b1177eed7549d0badf72078388422ce73167a0 https://github.com/llvm/llvm-project/commit/b8e3b2ad66cf78ad2b7832577b1d58dc93c5da21 https://github.com/llvm/llvm-project/commit/b467c6b53660dcaa458c2b5d7fbf5f93ee2af910 https://github.com/llvm/llvm-project/pull/89873 https://github.com/llvm/llvm-project/commit/d86cc73bbfd9a22d9a0d498d72c9b2ee235128e9 https://github.com/llvm/llvm-project/commit/8af86025af2456c70c84aec309cca9a069124671 ... and probably more. This likely needs further cleaning up to not use `DeclID` at all. --- lib/ClangImporter/SwiftLookupTable.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index b12729c13fea8..c7b564d8a6111 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -833,12 +833,12 @@ ArrayRef SwiftLookupTable::categories() { // Map categories known to the reader. for (auto declID : Reader->categories()) { - auto category = - cast_or_null( - Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), declID)); + auto localID = clang::LocalDeclID::get(Reader->getASTReader(), + Reader->getModuleFile(), declID); + auto category = cast_or_null( + Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), localID)); if (category) Categories.push_back(category); - } return Categories; @@ -930,8 +930,8 @@ static void printStoredContext(SwiftLookupTable::StoredContext context, } } -static uint32_t getEncodedDeclID(uint64_t entry) { - assert(SwiftLookupTable::isSerializationIDEntry(entry)); +static uint64_t getEncodedDeclID(uint64_t entry) { + assert(SwiftLookupTable::isSerializationIDEntry(entry)); assert(SwiftLookupTable::isDeclEntry(entry)); return entry >> 2; } @@ -1190,7 +1190,7 @@ namespace { uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl) << 2) | 0x02; + id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02; } else if (auto *macro = mappedEntry.dyn_cast()) { id = static_cast(Writer.getMacroID(macro)) << 32; id |= 0x02 | 0x01; @@ -1272,7 +1272,7 @@ namespace { uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl) << 2) | 0x02; + id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02; } else if (auto *macro = mappedEntry.dyn_cast()) { id = static_cast(Writer.getMacroID(macro)) << 32; id |= 0x02 | 0x01; @@ -1332,7 +1332,7 @@ void SwiftLookupTableWriter::writeExtensionContents( if (!table.Categories.empty()) { SmallVector categoryIDs; for (auto category : table.Categories) { - categoryIDs.push_back(Writer.getDeclID(category)); + categoryIDs.push_back(Writer.getDeclID(category).getRawValue()); } StringRef blob(reinterpret_cast(categoryIDs.data()), @@ -1555,10 +1555,11 @@ clang::NamedDecl *SwiftLookupTable::mapStoredDecl(uint64_t &entry) { // Otherwise, resolve the declaration. assert(Reader && "Cannot resolve the declaration without a reader"); - uint32_t declID = getEncodedDeclID(entry); + auto declID = getEncodedDeclID(entry); + auto localID = clang::LocalDeclID::get(Reader->getASTReader(), + Reader->getModuleFile(), declID); auto decl = cast_or_null( - Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), - declID)); + Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), localID)); // Update the entry now that we've resolved the declaration. entry = encodeEntry(decl); From aa7a3a8268676582283e8c0f6b94083fc1a83a48 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 1 Jul 2024 14:55:22 -0700 Subject: [PATCH 061/110] Cleanup std includes Remove `deque` from files it isn't actually used in. Add it and `stack` to files that it is - presumably they were previously transitively found through other includes. --- lib/AST/NameLookup.cpp | 2 ++ lib/AST/RequirementMachine/KnuthBendix.cpp | 1 - lib/DependencyScan/ScanDependencies.cpp | 1 + lib/IDE/ImportDepth.cpp | 2 ++ lib/SILOptimizer/Utils/CastOptimizer.cpp | 1 - lib/SILOptimizer/Utils/InstOptUtils.cpp | 1 - tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp | 1 - 7 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/AST/NameLookup.cpp b/lib/AST/NameLookup.cpp index a7a852ec057e3..58a330b333f6c 100644 --- a/lib/AST/NameLookup.cpp +++ b/lib/AST/NameLookup.cpp @@ -49,6 +49,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include + #define DEBUG_TYPE "namelookup" using namespace swift; diff --git a/lib/AST/RequirementMachine/KnuthBendix.cpp b/lib/AST/RequirementMachine/KnuthBendix.cpp index 2720deff65608..a0fc682574b63 100644 --- a/lib/AST/RequirementMachine/KnuthBendix.cpp +++ b/lib/AST/RequirementMachine/KnuthBendix.cpp @@ -34,7 +34,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include -#include #include #include "RewriteContext.h" diff --git a/lib/DependencyScan/ScanDependencies.cpp b/lib/DependencyScan/ScanDependencies.cpp index 354a91ddd504e..d8bf05315ca7a 100644 --- a/lib/DependencyScan/ScanDependencies.cpp +++ b/lib/DependencyScan/ScanDependencies.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #include #include diff --git a/lib/IDE/ImportDepth.cpp b/lib/IDE/ImportDepth.cpp index ba23234cefc47..402966b96251f 100644 --- a/lib/IDE/ImportDepth.cpp +++ b/lib/IDE/ImportDepth.cpp @@ -15,6 +15,8 @@ #include "swift/Basic/Assertions.h" #include "clang/Basic/Module.h" +#include + using namespace swift; using namespace swift::ide; diff --git a/lib/SILOptimizer/Utils/CastOptimizer.cpp b/lib/SILOptimizer/Utils/CastOptimizer.cpp index fdbc17f85719d..9c2881acf3f32 100644 --- a/lib/SILOptimizer/Utils/CastOptimizer.cpp +++ b/lib/SILOptimizer/Utils/CastOptimizer.cpp @@ -42,7 +42,6 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" -#include #include using namespace swift; diff --git a/lib/SILOptimizer/Utils/InstOptUtils.cpp b/lib/SILOptimizer/Utils/InstOptUtils.cpp index ce18b9dfa9ae4..5b0754f0ee0c8 100644 --- a/lib/SILOptimizer/Utils/InstOptUtils.cpp +++ b/lib/SILOptimizer/Utils/InstOptUtils.cpp @@ -45,7 +45,6 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" -#include #include using namespace swift; diff --git a/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp b/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp index 6fd08774332b3..bbbabb2f6d499 100644 --- a/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp +++ b/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp @@ -23,7 +23,6 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" -#include using namespace SourceKit; using namespace CodeCompletion; From 42bfa082202edfb6fab2ff34ba699ab9a2b9333a Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Mon, 8 Jul 2024 14:52:50 +0100 Subject: [PATCH 062/110] [cxx-interop] Suppress new diagnostic in Clang for testing C interop headers Clang now (correctly) diagnoses that _Alignas is not available before C11. Since this was available before C11 as an extension, I only suppressed the diagnostic instead of removing the testing in c99 mode. --- test/Interop/lit.local.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Interop/lit.local.cfg b/test/Interop/lit.local.cfg index 4add717c3fd4e..3899dd68b9438 100644 --- a/test/Interop/lit.local.cfg +++ b/test/Interop/lit.local.cfg @@ -62,5 +62,5 @@ config.substitutions.insert(0, ('%check-interop-cxx-header-in-clang\(([^)]+)\)', # Test parsing of the generated C header in different C language modes. config.substitutions.insert(0, ('%check-interop-c-header-in-clang\(([^)]+)\)', - SubstituteCaptures(r'%check-c-header-in-clang -std=c99 -Wno-padded -Wno-c11-extensions \1 && ' - r'%check-c-header-in-clang -std=c11 -Wno-padded \1'))) + SubstituteCaptures(r'%check-c-header-in-clang -std=c99 -Wno-padded -Wno-c11-extensions -Wno-pre-c11-compat \1 && ' + r'%check-c-header-in-clang -std=c11 -Wno-padded -Wno-pre-c11-compat \1'))) From a321b0afe050acdbe306d181bab394aa0b749dbc Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 23 Jul 2024 10:54:02 -0700 Subject: [PATCH 063/110] [DebugInfo] Update tests to expect new LLVM debug format --- .../issue-58123-invalid-debug-info.swift | 2 +- test/ClangImporter/objc_ir.swift | 6 +- test/DebugInfo/ErrorVar.swift | 4 +- test/DebugInfo/LoadableByAddress.swift | 4 +- test/DebugInfo/ProtocolContainer.swift | 2 +- test/DebugInfo/WeakCapture.swift | 7 +- test/DebugInfo/any.swift | 2 +- test/DebugInfo/async-args.swift | 8 +- test/DebugInfo/async-direct-arg.swift | 12 +- test/DebugInfo/async-let-await.swift | 2 +- test/DebugInfo/async-lifetime-extension.swift | 8 +- test/DebugInfo/async-local-var.swift | 2 +- test/DebugInfo/async-task-alloc.swift | 6 +- test/DebugInfo/autoclosure.swift | 2 +- test/DebugInfo/basic.swift | 4 +- test/DebugInfo/byref-capture.swift | 6 +- test/DebugInfo/capturelist.swift | 6 +- test/DebugInfo/catch_let.swift | 8 +- test/DebugInfo/closure-args.swift | 2 +- test/DebugInfo/closure-multivalue.swift | 12 +- test/DebugInfo/dbgvalue-insertpt.swift | 4 +- test/DebugInfo/debug_fragment_merge.swift | 16 +-- test/DebugInfo/debug_info_expression.sil | 8 +- test/DebugInfo/debug_scope_distinct.swift | 8 +- test/DebugInfo/debug_value_addr.swift | 2 +- test/DebugInfo/debug_variable.sil | 8 +- test/DebugInfo/debug_variable_varinfo_loc.sil | 6 +- test/DebugInfo/doubleinlines.swift | 2 +- test/DebugInfo/dynamic_layout.swift | 8 +- test/DebugInfo/generic_arg.swift | 8 +- test/DebugInfo/generic_arg2.swift | 4 +- test/DebugInfo/generic_arg3.swift | 2 +- test/DebugInfo/generic_arg4.swift | 6 +- test/DebugInfo/generic_arg5.swift | 8 +- test/DebugInfo/generic_enum_closure.swift | 7 +- test/DebugInfo/guard-let.swift | 14 +- test/DebugInfo/inlined-generics-basic.swift | 26 ++-- test/DebugInfo/inlined-generics.swift | 4 +- test/DebugInfo/inlinedAt.swift | 6 +- test/DebugInfo/inout.swift | 12 +- test/DebugInfo/irgen_undef.sil | 14 +- test/DebugInfo/irgen_void_tuple.sil | 8 +- test/DebugInfo/iuo_arg.swift | 2 +- test/DebugInfo/let.swift | 2 +- test/DebugInfo/letclause.swift | 4 +- test/DebugInfo/letstring.swift | 12 +- test/DebugInfo/linetable-codeview.swift | 6 +- test/DebugInfo/move_function_dbginfo.swift | 128 +++++++++--------- .../move_function_dbginfo_async.swift | 94 ++++++------- test/DebugInfo/nostorage.swift | 8 +- test/DebugInfo/patternmatching.swift | 50 +++---- test/DebugInfo/patternvars.swift | 8 +- .../property-setter-implicit-tuple.swift | 2 +- test/DebugInfo/protocol-extension.swift | 4 +- test/DebugInfo/protocol.swift | 2 +- test/DebugInfo/protocolarg.swift | 10 +- test/DebugInfo/returnlocation.swift | 2 +- test/DebugInfo/self-nostorage.swift | 4 +- test/DebugInfo/self.swift | 4 +- test/DebugInfo/shadow_copies.swift | 4 +- test/DebugInfo/shadowcopy-linetable.swift | 2 +- test/DebugInfo/sil_combine.sil | 4 +- test/DebugInfo/sroa_mem2reg.sil | 12 +- test/DebugInfo/sroa_mem2reg_tuple.sil | 12 +- test/DebugInfo/struct_resilience.swift | 6 +- test/DebugInfo/structs.swift | 2 +- test/DebugInfo/typearg.swift | 2 +- test/DebugInfo/uninitialized.swift | 4 +- test/DebugInfo/value-update.sil | 4 +- test/DebugInfo/variables.swift | 2 +- test/DebugInfo/variadic-generics-count.swift | 12 +- test/DebugInfo/variadic-generics.swift | 4 +- test/DebugInfo/weak-self-capture.swift | 2 +- test/IRGen/debug_fragment_merge.sil | 8 +- 74 files changed, 353 insertions(+), 355 deletions(-) diff --git a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift index beb746eb5c964..8096d5c1f2975 100644 --- a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift +++ b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift @@ -6,7 +6,7 @@ // CHECK-LABEL: define internal swiftcc{{.*}} float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA" // CHECK: [[SELF:%.*]] = alloca %T4main8TestTypeV06ManualB7TangentV -// CHECK: call void @llvm.dbg.value(metadata ptr [[SELF]] +// CHECK: #dbg_value(ptr [[SELF]] import _Differentiation diff --git a/test/ClangImporter/objc_ir.swift b/test/ClangImporter/objc_ir.swift index ba04cf8964113..fc5f264653c2d 100644 --- a/test/ClangImporter/objc_ir.swift +++ b/test/ClangImporter/objc_ir.swift @@ -326,15 +326,15 @@ func customFactoryMethodsInherited() { // CHECK-LABEL: define hidden swiftcc void @"$s7objc_ir30testCompatibilityAliasMangling3objySo13SwiftNameTestC_tF" func testCompatibilityAliasMangling(obj: SwiftNameAlias) { - // CHECK: call void @llvm.dbg.declare(metadata ptr {{%.+}}, metadata ![[SWIFT_NAME_ALIAS_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr {{%.+}}, ![[SWIFT_NAME_ALIAS_VAR:[0-9]+]], !DIExpression() } func testGenericCompatibilityAliasMangling(generic_obj: SwiftGenericNameAlias) { - // CHECK: call void @llvm.dbg.declare(metadata ptr {{%.+}}, metadata ![[SWIFT_GENERIC_NAME_ALIAS_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr {{%.+}}, ![[SWIFT_GENERIC_NAME_ALIAS_VAR:[0-9]+]], !DIExpression() } func testConstrGenericCompatibilityAliasMangling(constr_generic_obj: SwiftConstrGenericNameAlias) { - // CHECK: call void @llvm.dbg.declare(metadata ptr {{%.+}}, metadata ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr {{%.+}}, ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_VAR:[0-9]+]], !DIExpression() } // CHECK-LABEL: s7objc_ir22testBlocksWithGenerics3hbaypSo13HasBlockArrayC_tF diff --git a/test/DebugInfo/ErrorVar.swift b/test/DebugInfo/ErrorVar.swift index bc186ac95c125..75c7fccf7a13f 100644 --- a/test/DebugInfo/ErrorVar.swift +++ b/test/DebugInfo/ErrorVar.swift @@ -15,8 +15,8 @@ func simple(_ placeholder: Int64) throws -> () { // CHECK-SAME: i64 // CHECK-SAME: %swift.refcounted* {{.*}}swiftself // CHECK-SAME: %swift.error** noalias nocapture dereferenceable(4) - // CHECK: call void @llvm.dbg.declare - // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[ERROR:[0-9]+]], metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare + // CHECK: #dbg_declare({{.*}}, ![[ERROR:[0-9]+]], !DIExpression(DW_OP_deref) // CHECK-DAG: ![[ERRTY:.*]] = !DICompositeType({{.*}}identifier: "$ss5Error_pD" // CHECK-DAG: ![[ERROR]] = !DILocalVariable(name: "$error", arg: 2, {{.*}}, type: ![[ERRTY]], flags: DIFlagArtificial) throw MyError.Simple diff --git a/test/DebugInfo/LoadableByAddress.swift b/test/DebugInfo/LoadableByAddress.swift index afa04b8879393..408067f72a842 100644 --- a/test/DebugInfo/LoadableByAddress.swift +++ b/test/DebugInfo/LoadableByAddress.swift @@ -13,8 +13,8 @@ public struct Continuation { public typealias ContinuationU = Continuation<()> // CHECK: %2 = alloca %T1A12ContinuationV, align 8 -// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %2, -// CHECK-SAME: metadata ![[X:.*]], metadata !DIExpression()) +// CHECK-NEXT: #dbg_declare(ptr %2, +// CHECK-SAME: ![[X:.*]], !DIExpression() // CHECK: ![[X]] = !DILocalVariable(name: "x", public func f(_ xs: [Continuation]) -> (() -> A?) { diff --git a/test/DebugInfo/ProtocolContainer.swift b/test/DebugInfo/ProtocolContainer.swift index 1057ea8c3ed12..1435a7e17f839 100644 --- a/test/DebugInfo/ProtocolContainer.swift +++ b/test/DebugInfo/ProtocolContainer.swift @@ -14,7 +14,7 @@ class AClass : AProtocol { // CHECK: define hidden {{.*}}void @"$s17ProtocolContainer3foo{{[_0-9a-zA-Z]*}}F" // CHECK-NEXT: entry: // CHECK: %[[X:.*]] = alloca %T17ProtocolContainer9AProtocolP, align {{(4|8)}} -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[X]], metadata ![[XMD:.*]], metadata !DIExpression()) +// CHECK: #dbg_declare(ptr %[[X]], ![[XMD:.*]], !DIExpression() // CHECK-NOT: !DILocalVariable({{.*}} name: "x" // CHECK-NOT: !DILocalVariable({{.*}} name: "x" func foo (_ x : AProtocol) { diff --git a/test/DebugInfo/WeakCapture.swift b/test/DebugInfo/WeakCapture.swift index d05c73262f9db..b3c86fdd54c42 100644 --- a/test/DebugInfo/WeakCapture.swift +++ b/test/DebugInfo/WeakCapture.swift @@ -10,10 +10,9 @@ func function() { let b = B() // Ensure that the local b and its weak copy are distinct local variables. - // CHECK: call void @llvm.dbg.{{.*}}(metadata ptr - // CHECK-SAME: metadata [[B:.*]], metadata - // CHECK: call void @llvm.dbg.{{.*}}(metadata ptr - // CHECK-NOT: metadata [[B]] + // CHECK: #dbg_{{.*}}(ptr [[B:.*]], + // CHECK: #dbg_{{.*}}(ptr + // CHECK-NOT: [[B]] // CHECK: call A(handler: { [weak b] in if b != nil { } diff --git a/test/DebugInfo/any.swift b/test/DebugInfo/any.swift index 1d9f26d251717..6d24ac5f0f53b 100644 --- a/test/DebugInfo/any.swift +++ b/test/DebugInfo/any.swift @@ -4,7 +4,7 @@ func markUsed(_ t: T) {} func main() { // CHECK: define hidden swiftcc void @"$s3any4mainyyF" - // CHECK: call void @llvm.dbg.declare(metadata ptr {{.*}}, metadata ![[S:.*]], metadata !DIExpression()), !dbg ![[DBG:.*]] + // CHECK: #dbg_declare(ptr {{.*}}, ![[S:.*]], !DIExpression(), ![[DBG:.*]]) // CHECK: ![[S]] = !DILocalVariable(name: "s", {{.*}}line: [[@LINE+2]] // CHECK: ![[DBG]] = !DILocation(line: [[@LINE+1]], column: 7, var s: Any = "hello world" diff --git a/test/DebugInfo/async-args.swift b/test/DebugInfo/async-args.swift index 080c479eb1a4f..fe5b4f1d7c81f 100644 --- a/test/DebugInfo/async-args.swift +++ b/test/DebugInfo/async-args.swift @@ -11,13 +11,13 @@ func withGenericArg(_ msg: T) async { // This odd debug info is part of a contract with CoroSplit/CoroFrame to fix // this up after coroutine splitting. // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalF"(ptr swiftasync %0 - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %0, metadata ![[MSG:[0-9]+]], metadata !DIExpression({{.*}}DW_OP_plus_uconst, {{.*}}DW_OP_deref)) - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %0, metadata ![[TAU:[0-9]+]], metadata !DIExpression({{.*}}DW_OP_plus_uconst, + // CHECK-DAG: #dbg_declare(ptr %0, ![[MSG:[0-9]+]], !DIExpression({{.*}}DW_OP_plus_uconst, {{.*}}DW_OP_deref), + // CHECK-DAG: #dbg_declare(ptr %0, ![[TAU:[0-9]+]], !DIExpression({{.*}}DW_OP_plus_uconst, await forceSplit() // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalFTQ0_"(ptr swiftasync %0) - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %0, metadata ![[MSG_R:[0-9]+]], metadata !DIExpression({{.*}}DW_OP_plus_uconst, [[OFFSET:[0-9]+]], DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref)) - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %0, metadata ![[TAU_R:[0-9]+]], metadata !DIExpression({{.*}}DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]], DW_OP_plus_uconst, {{[0-9]+}})) + // CHECK-DAG: #dbg_declare(ptr %0, ![[MSG_R:[0-9]+]], !DIExpression({{.*}}DW_OP_plus_uconst, [[OFFSET:[0-9]+]], DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref), + // CHECK-DAG: #dbg_declare(ptr %0, ![[TAU_R:[0-9]+]], !DIExpression({{.*}}DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]], DW_OP_plus_uconst, {{[0-9]+}}), use(msg) } // CHECK-LABEL: {{^define }} diff --git a/test/DebugInfo/async-direct-arg.swift b/test/DebugInfo/async-direct-arg.swift index 01213f40afc59..f27482b182cd9 100644 --- a/test/DebugInfo/async-direct-arg.swift +++ b/test/DebugInfo/async-direct-arg.swift @@ -10,15 +10,15 @@ // CHECK-LABEL: define {{.*}} void @"$s1a3fibyS2iYaFTY0_" // CHECK-SAME: (ptr swiftasync %[[ARG:.*]]) -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata {{.*}}, metadata !DIExpression(DW_OP_LLVM_entry_value -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata {{.*}}, metadata !DIExpression(DW_OP_LLVM_entry_value -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata ![[X0:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], {{.*}}, !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], {{.*}}, !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], ![[X0:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value // CHECK-LABEL: define {{.*}} void @"$s1a3fibyS2iYaFTY2_" // CHECK-SAME: (ptr swiftasync %[[ARG:.*]]) -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata {{.*}}, metadata !DIExpression(DW_OP_LLVM_entry_value -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata {{.*}}, metadata !DIExpression(DW_OP_LLVM_entry_value -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ARG]], metadata ![[X1:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], {{.*}}, !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], {{.*}}, !DIExpression(DW_OP_LLVM_entry_value +// CHECK: #dbg_declare(ptr %[[ARG]], ![[X1:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value // CHECK: ![[X0]] = !DILocalVariable(name: "x" // CHECK: ![[X1]] = !DILocalVariable(name: "x" diff --git a/test/DebugInfo/async-let-await.swift b/test/DebugInfo/async-let-await.swift index b65142876c335..8746820b7f6e5 100644 --- a/test/DebugInfo/async-let-await.swift +++ b/test/DebugInfo/async-let-await.swift @@ -13,7 +13,7 @@ public func getVegetables() async -> [String] { public func chopVegetables() async throws -> [String] { let veggies = await getVegetables() // CHECK-NOT: {{^define }} - // CHECK: call void @llvm.dbg.declare(metadata ptr %0, metadata ![[V:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_plus_uconst, {{[0-9]+}}) + // CHECK: #dbg_declare(ptr %0, ![[V:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_plus_uconst, {{[0-9]+}}) // CHECK: ![[V]] = !DILocalVariable(name: "veggies" return veggies.map { "chopped \($0)" } } diff --git a/test/DebugInfo/async-lifetime-extension.swift b/test/DebugInfo/async-lifetime-extension.swift index a25ecb1f582f3..2d175a3f0ec27 100644 --- a/test/DebugInfo/async-lifetime-extension.swift +++ b/test/DebugInfo/async-lifetime-extension.swift @@ -8,10 +8,10 @@ // CHECK-LABEL: define {{.*}} void @"$s1a4fiboyS2iYaFTY0_" // CHECK-NEXT: entryresume.0: -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[RHS:[0-9]+]], {{.*}}!DIExpression(DW_OP -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LHS:[0-9]+]], {{.*}}!DIExpression(DW_OP -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[R:[0-9]+]], {{.*}}!DIExpression(DW_OP -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[N:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[RHS:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[LHS:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[R:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[N:[0-9]+]], {{.*}}!DIExpression(DW_OP // CHECK-NOT: {{ ret }} // CHECK: call void asm sideeffect "" // CHECK: ![[N]] = !DILocalVariable(name: "n" diff --git a/test/DebugInfo/async-local-var.swift b/test/DebugInfo/async-local-var.swift index 107d39e6ae4a5..90a684f77a6e3 100644 --- a/test/DebugInfo/async-local-var.swift +++ b/test/DebugInfo/async-local-var.swift @@ -17,7 +17,7 @@ public func makeDinner() async throws -> String { // CHECK-LABEL: define {{.*}} void @"$s1a10makeDinnerSSyYaKFTQ0_" // CHECK-NEXT: entryresume.0: // CHECK-NOT: {{ ret }} -// CHECK: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LOCAL:[0-9]+]], {{.*}}!DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}) +// CHECK: #dbg_declare({{.*}}%0, ![[LOCAL:[0-9]+]], {{.*}}!DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}) // CHECK: ![[LOCAL]] = !DILocalVariable(name: "local" return local } diff --git a/test/DebugInfo/async-task-alloc.swift b/test/DebugInfo/async-task-alloc.swift index b611322b48050..e36d0ddcce769 100644 --- a/test/DebugInfo/async-task-alloc.swift +++ b/test/DebugInfo/async-task-alloc.swift @@ -9,9 +9,9 @@ // CHECK: swift_task_alloc // CHECK-LABEL: define {{.*}} void @"$s1a1fyxxYalFTY0_" // CHECK-NEXT: entryresume.0: -// CHECK-NEXT: call void @llvm.dbg.declare -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[DYNA:[0-9]+]], {{.*}}!DIExpression({{.*}}DW_OP_deref -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[T:[0-9]+]], {{.*}}!DIExpression({{.*}}DW_OP_deref +// CHECK-NEXT: #dbg_declare +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[DYNA:[0-9]+]], {{.*}}!DIExpression({{.*}}DW_OP_deref +// CHECK-NEXT: #dbg_declare({{.*}}%0, ![[T:[0-9]+]], {{.*}}!DIExpression({{.*}}DW_OP_deref // CHECK: ![[DYNA]] = !DILocalVariable(name: "dyna" // CHECK: ![[T]] = !DILocalVariable(name: "t" diff --git a/test/DebugInfo/autoclosure.swift b/test/DebugInfo/autoclosure.swift index 1281842860cbb..f82399066b71d 100644 --- a/test/DebugInfo/autoclosure.swift +++ b/test/DebugInfo/autoclosure.swift @@ -2,7 +2,7 @@ // CHECK: define{{.*}}@"$s11autoclosure7call_meyys5Int64VF" // CHECK-NOT: ret void -// CHECK: call void @llvm.dbg.declare{{.*}}, !dbg +// CHECK: #dbg_declare{{.*}} // CHECK-NOT: ret void // CHECK: _value {{.*}}, !dbg ![[DBG:.*]] // CHECK: ret void diff --git a/test/DebugInfo/basic.swift b/test/DebugInfo/basic.swift index 86aca41b4171d..ca64ef87f9bf2 100644 --- a/test/DebugInfo/basic.swift +++ b/test/DebugInfo/basic.swift @@ -48,8 +48,8 @@ func foo(_ a: Int64, _ b: Int64) -> Int64 { // CHECK-DAG: store i64 %1, ptr [[BADDR:.*]], align // CHECK-DAG: [[AVAL:%.*]] = getelementptr inbounds {{.*}}, [[AMEM:.*]], i32 0, i32 0 // CHECK-DAG: [[BVAL:%.*]] = getelementptr inbounds {{.*}}, [[BMEM:.*]], i32 0, i32 0 - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr [[AADDR]], metadata ![[AARG:.*]], metadata !DIExpression()), !dbg ![[ALOC]] - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr [[BADDR]], metadata ![[BARG:.*]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare(ptr [[AADDR]], ![[AARG:.*]], !DIExpression(), ![[ALOC]] + // CHECK-DAG: #dbg_declare(ptr [[BADDR]], ![[BARG:.*]], !DIExpression() // CHECK-DAG: ![[AARG]] = !DILocalVariable(name: "a", arg: 1 // CHECK-DAG: ![[BARG]] = !DILocalVariable(name: "b", arg: 2 if b != 0 { diff --git a/test/DebugInfo/byref-capture.swift b/test/DebugInfo/byref-capture.swift index 34e072719599a..177a1d81b87ca 100644 --- a/test/DebugInfo/byref-capture.swift +++ b/test/DebugInfo/byref-capture.swift @@ -5,9 +5,9 @@ func makeIncrementor(_ inc : Int64) -> () -> Int64 var sum : Int64 = 0 // CHECK: define {{.*}}5inner func inner() -> Int64 { - // CHECK: call void @llvm.dbg.declare(metadata ptr - // CHECK-SAME: metadata ![[SUM_CAPTURE:[0-9]+]], - // CHECK-SAME: metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare(ptr + // CHECK-SAME: ![[SUM_CAPTURE:[0-9]+]], + // CHECK-SAME: !DIExpression(DW_OP_deref) // CHECK: ![[INOUTTY:[0-9]+]] = !DICompositeType({{.*}}identifier: "$ss5Int64VD" // CHECK: ![[SUM_CAPTURE]] = !DILocalVariable(name: "sum", arg: 1, // CHECK-SAME: line: [[@LINE-8]], type: ![[INOUTTY]] diff --git a/test/DebugInfo/capturelist.swift b/test/DebugInfo/capturelist.swift index 8aaedfcd0000b..4fa35e87a175e 100644 --- a/test/DebugInfo/capturelist.swift +++ b/test/DebugInfo/capturelist.swift @@ -7,11 +7,11 @@ class C { // There should not be a local weak variable "self" shadowing the // implicit self argument. // let self - // CHECK: call void @llvm.dbg + // CHECK: #dbg_ // let s - // CHECK: call void @llvm.dbg + // CHECK: #dbg_ // var weak self - // CHECK-NOT: call void @llvm.dbg + // CHECK-NOT: #dbg_ // CHECK-LABEL: ret void withClosure { [weak self] in guard let s = self else { return } diff --git a/test/DebugInfo/catch_let.swift b/test/DebugInfo/catch_let.swift index 5ade193f755e5..46f8b41c3da45 100644 --- a/test/DebugInfo/catch_let.swift +++ b/test/DebugInfo/catch_let.swift @@ -16,7 +16,7 @@ public func explicitBinding() { try throwing() } catch let error { - // CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[EXPLICIT_ERROR:[0-9]+]], + // CHECK: #dbg_declare(ptr %{{.*}}, ![[EXPLICIT_ERROR:[0-9]+]], use(error) } } @@ -28,7 +28,7 @@ public func implicitBinding() { try throwing() } catch { - // CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[IMPLICIT_ERROR:[0-9]+]], + // CHECK: #dbg_declare(ptr %{{.*}}, ![[IMPLICIT_ERROR:[0-9]+]], use(error) } } @@ -40,8 +40,8 @@ public func multiBinding() { try throwing() } catch let error as MyError, let error as MyError { - // CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[MULTI_BINDING_ERROR:[0-9]+]], - // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr %{{.*}} + // CHECK: #dbg_declare(ptr %{{.*}}, ![[MULTI_BINDING_ERROR:[0-9]+]], + // CHECK-NOT: #dbg_declare(ptr %{{.*}} // CHECK: define {{.*}}MyError{{.*}} use(error) } catch { diff --git a/test/DebugInfo/closure-args.swift b/test/DebugInfo/closure-args.swift index cc15b45004eb7..6f57e83ba8e4c 100644 --- a/test/DebugInfo/closure-args.swift +++ b/test/DebugInfo/closure-args.swift @@ -17,7 +17,7 @@ func main() -> Void // value to be by-address. When that is fixed, remove the optional // DW_OP_deref below. // - // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[RANDOM_STR_ADDR]], metadata !{{.*}}, metadata !DIExpression({{(DW_OP_deref)?}})), !dbg + // CHECK-NEXT: #dbg_declare(ptr %[[RANDOM_STR_ADDR]], !{{.*}}, !DIExpression({{(DW_OP_deref)?}}) // CHECK: store ptr %{{.*}}, ptr %[[RANDOM_STR_ADDR]], align {{(4|8)}} // CHECK-DAG: !DILocalVariable(name: "lhs",{{.*}} line: [[@LINE+5]], diff --git a/test/DebugInfo/closure-multivalue.swift b/test/DebugInfo/closure-multivalue.swift index 07cca703fdfc7..e9539f2a01391 100644 --- a/test/DebugInfo/closure-multivalue.swift +++ b/test/DebugInfo/closure-multivalue.swift @@ -4,12 +4,12 @@ import StdlibUnittest // CHECK: define {{.*}}i1 {{.*}}4main4sort -// CHECK: call void @llvm.dbg.value(metadata i8*{{.*}}, metadata ![[A:.*]], metadata ![[P1:.*]]) -// CHECK: call void @llvm.dbg.value(metadata i{{[0-9]+}} {{.*}}, metadata ![[A]], metadata ![[P2:.*]]) -// CHECK: call void @llvm.dbg.value(metadata i{{[0-9]+}} {{.*}}, metadata ![[A]], metadata ![[P3:.*]]) -// CHECK: call void @llvm.dbg.value(metadata i8*{{.*}}, metadata ![[B:.*]], metadata ![[P1]]) -// CHECK: call void @llvm.dbg.value(metadata i{{[0-9]+}} {{.*}}, metadata ![[B]], metadata ![[P2]]) -// CHECK: call void @llvm.dbg.value(metadata i{{[0-9]+}} {{.*}}, metadata ![[B]], metadata ![[P3]]) +// CHECK: #dbg_value(i8*{{.*}}, ![[A:.*]], ![[P1:.*]] +// CHECK: #dbg_value(i{{[0-9]+}} {{.*}}, ![[A]], ![[P2:.*]] +// CHECK: #dbg_value(i{{[0-9]+}} {{.*}}, ![[A]], ![[P3:.*]] +// CHECK: #dbg_value(i8*{{.*}}, ![[B:.*]], ![[P1]] +// CHECK: #dbg_value(i{{[0-9]+}} {{.*}}, ![[B]], ![[P2]] +// CHECK: #dbg_value(i{{[0-9]+}} {{.*}}, ![[B]], ![[P3]] // CHECK-DAG: ![[A]] = !DILocalVariable(name: "a",{{.*}} line: 17 // CHECK-DAG: ![[B]] = !DILocalVariable(name: "b",{{.*}} line: 17 // CHECK-DAG: ![[P1]] = !DIExpression(DW_OP_bit_piece, 0, {{(32|64)}}) diff --git a/test/DebugInfo/dbgvalue-insertpt.swift b/test/DebugInfo/dbgvalue-insertpt.swift index b5612ec8ea7c3..1f423818f168c 100644 --- a/test/DebugInfo/dbgvalue-insertpt.swift +++ b/test/DebugInfo/dbgvalue-insertpt.swift @@ -4,7 +4,7 @@ for i in 0 ..< 3 { // CHECK: %[[ALLOCA:[0-9]+]] = alloca %TSiSg // CHECK: %i.debug = alloca i{{32|64}} - // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %i.debug, - // CHECK-SAME: metadata ![[I:[0-9]+]], + // CHECK-NEXT: #dbg_declare(ptr %i.debug, + // CHECK-SAME: ![[I:[0-9]+]], // CHECK: ![[I]] = !DILocalVariable(name: "i", } diff --git a/test/DebugInfo/debug_fragment_merge.swift b/test/DebugInfo/debug_fragment_merge.swift index 2f151dccd148d..06d54ebb1b0d6 100644 --- a/test/DebugInfo/debug_fragment_merge.swift +++ b/test/DebugInfo/debug_fragment_merge.swift @@ -31,12 +31,12 @@ func test(cond: Int, external: External) async { // CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.a // CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.b -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} !dbg ![[LOC1]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} !dbg ![[LOC1]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} !dbg ![[LOC1]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} !dbg ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} ![[LOC1]] // -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} !dbg ![[LOC2]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} !dbg ![[LOC2]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} !dbg ![[LOC2]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} !dbg ![[LOC2]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} ![[LOC2]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} ![[LOC2]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} ![[LOC2]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} ![[LOC2]] diff --git a/test/DebugInfo/debug_info_expression.sil b/test/DebugInfo/debug_info_expression.sil index 995b40cd14e3b..f78fa1d93c5f3 100644 --- a/test/DebugInfo/debug_info_expression.sil +++ b/test/DebugInfo/debug_info_expression.sil @@ -19,9 +19,9 @@ sil hidden @test_fragment : $@convention(thin) () -> () { bb0: %2 = alloc_stack $MyStruct, var, name "my_struct", loc "file.swift":8:9, scope 1 // CHECK: %[[MY_STRUCT:.+]] = alloca %{{.*}}MyStruct - // CHECK: llvm.dbg.declare(metadata {{.*}} %[[MY_STRUCT]], metadata ![[VAR_DECL_MD:[0-9]+]] + // CHECK: #dbg_declare({{.*}} %[[MY_STRUCT]], ![[VAR_DECL_MD:[0-9]+]] // CHECK: %[[SMALL_STRUCT:.+]] = alloca %{{.*}}SmallStruct - // CHECK: llvm.dbg.declare(metadata {{.*}} %[[SMALL_STRUCT]], metadata ![[SMALL_VAR_DECL_MD:[0-9]+]] + // CHECK: #dbg_declare({{.*}} %[[SMALL_STRUCT]], ![[SMALL_VAR_DECL_MD:[0-9]+]] %3 = struct_element_addr %2 : $*MyStruct, #MyStruct.x, loc "file.swift":9:17, scope 1 // CHECK: %[[FIELD_X:.*]] = getelementptr {{.*}} %[[MY_STRUCT]] // CHECK-SIL: debug_value %{{[0-9]+}} : $*Builtin.Int64 @@ -49,13 +49,13 @@ sil hidden @test_alloc_stack : $@convention(thin) () -> () { bb0: %my_struct = alloc_stack $MyStruct, var, name "my_struct", loc "file.swift":15:9, scope 2 // CHECK: %[[MY_STRUCT:.+]] = alloca %{{.*}}MyStruct - // CHECK: llvm.dbg.declare(metadata ptr %[[MY_STRUCT]], metadata ![[VAR_DECL_MD:[0-9]+]] + // CHECK: #dbg_declare(ptr %[[MY_STRUCT]], ![[VAR_DECL_MD:[0-9]+]] // CHECK-SIL: alloc_stack $Int, var // CHECK-SIL-SAME: (name "my_struct", loc "file.swift":15:9) // CHECK-SIL-SAME: type $MyStruct, expr op_fragment:#MyStruct.x %field_x = alloc_stack $Int, var, (name "my_struct", loc "file.swift":15:9, scope 2), type $MyStruct, expr op_fragment:#MyStruct.x, loc "file.swift":16:17, scope 2 // CHECK: %[[FIELD_X:.+]] = alloca %TSi - // CHECK: llvm.dbg.declare(metadata ptr %[[FIELD_X]], metadata ![[VAR_DECL_MD]] + // CHECK: #dbg_declare(ptr %[[FIELD_X]], ![[VAR_DECL_MD]] // CHECK-SAME: !DIExpression(DW_OP_LLVM_fragment, 0, 64) dealloc_stack %field_x : $*Int dealloc_stack %my_struct: $*MyStruct diff --git a/test/DebugInfo/debug_scope_distinct.swift b/test/DebugInfo/debug_scope_distinct.swift index 1cbc56cca4eb7..704ccc727240a 100644 --- a/test/DebugInfo/debug_scope_distinct.swift +++ b/test/DebugInfo/debug_scope_distinct.swift @@ -16,17 +16,17 @@ // CHECK-SAME: ptr {{.*}} %[[ARG_PTR:.*]], // // CHECK: %[[ARG0:.*]] = load {{.*}} %[[ARG_PTR]] -// CHECK: call void @llvm.dbg.value(metadata {{.*}} %[[ARG0]], metadata ![[VAR1:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg ![[LOC1:[0-9]+]] +// CHECK: #dbg_value({{.*}} %[[ARG0]], ![[VAR1:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 64), !dbg ![[LOC1:[0-9]+]] // CHECK: %[[ARG1_GEP:.*]] = getelementptr inbounds i8, ptr %[[ARG_PTR]], i64 8 // CHECK: %[[ARG1:.*]] = load {{.*}} %[[ARG1_GEP]] -// CHECK: call void @llvm.dbg.value(metadata {{.*}} %[[ARG1]], metadata ![[VAR1]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 8)), !dbg ![[LOC1]] +// CHECK: #dbg_value({{.*}} %[[ARG1]], ![[VAR1]], !DIExpression(DW_OP_LLVM_fragment, 64, 8), !dbg ![[LOC1]] // // CHECK: %[[ARG2_GEP:.*]] = getelementptr inbounds %T4main1TV13TangentVectorV, ptr %[[ARG_PTR]], i64 0, i32 2 // CHECK: %[[ARG2:.*]] = load {{.*}} %[[ARG2_GEP]] -// CHECK: call void @llvm.dbg.value(metadata {{.*}} %[[ARG2]], metadata ![[VAR1]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg ![[LOC2:[0-9]+]] +// CHECK: #dbg_value({{.*}} %[[ARG2]], ![[VAR1]], !DIExpression(DW_OP_LLVM_fragment, 0, 64), !dbg ![[LOC2:[0-9]+]] // CHECK: %[[ARG3_GEP:.*]] = getelementptr inbounds %T4main1TV13TangentVectorV, ptr %[[ARG_PTR]], i64 0, i32 2, i32 0, i32 1 // CHECK: %[[ARG3:.*]] = load {{.*}} %[[ARG3_GEP]] -// CHECK: call void @llvm.dbg.value(metadata {{.*}} %[[ARG3]], metadata ![[VAR1]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 8)), !dbg ![[LOC2]] +// CHECK: #dbg_value({{.*}} %[[ARG3]], ![[VAR1]], !DIExpression(DW_OP_LLVM_fragment, 64, 8), !dbg ![[LOC2]] // CHECK-DAG: ![[VAR1]] = !DILocalVariable(name: "offset", arg: 1, scope: ![[SCOPE:[0-9]+]] diff --git a/test/DebugInfo/debug_value_addr.swift b/test/DebugInfo/debug_value_addr.swift index d1f58993cf496..a6ec68eb1845a 100644 --- a/test/DebugInfo/debug_value_addr.swift +++ b/test/DebugInfo/debug_value_addr.swift @@ -10,7 +10,7 @@ // CHECK: define {{.*}}$s16debug_value_addr4testyyxlF // CHECK: entry: // CHECK-NEXT: %[[TADDR:.*]] = alloca -// CHECK-NEXT: call void @llvm.dbg.declare({{.*}}%[[TADDR]] +// CHECK-NEXT: #dbg_declare({{.*}}%[[TADDR]] // CHECK: store ptr %0, ptr %[[TADDR:.*]], align struct S { diff --git a/test/DebugInfo/debug_variable.sil b/test/DebugInfo/debug_variable.sil index b6070b5a810ee..4642ccc4da1b6 100644 --- a/test/DebugInfo/debug_variable.sil +++ b/test/DebugInfo/debug_variable.sil @@ -7,15 +7,15 @@ import Swift sil_scope 2 { loc "simple.swift":1:2 parent @test_debug_value : $@convention(thin) (Int) -> () } // https://github.com/apple/swift/issues/57215 -// Incorrect source location on 'llvm.dbg.declare' when the input is a SIL file +// Incorrect source location on '#dbg_declare' when the input is a SIL file // CHECK: @test_debug_value // CHECK-SAME: !dbg ![[FUNC_DI:[0-9]+]] sil hidden @test_debug_value : $@convention(thin) (Int) -> () { bb0(%0 : $Int): - // CHECK: @llvm.dbg.declare(metadata ptr - // CHECK-SAME: metadata ![[VAR_DI:[0-9]+]] - // CHECK-SAME: ), !dbg ![[LOC_DI:[0-9]+]] + // CHECK: #dbg_declare(ptr + // CHECK-SAME: ![[VAR_DI:[0-9]+]] + // CHECK-SAME: , ![[LOC_DI:[0-9]+]] debug_value %0 : $Int, let, name "x", argno 1, loc "simple.swift":3:4, scope 2 %1 = tuple () return %1 : $() diff --git a/test/DebugInfo/debug_variable_varinfo_loc.sil b/test/DebugInfo/debug_variable_varinfo_loc.sil index da6bcfdcefae7..ec729ddacf72c 100644 --- a/test/DebugInfo/debug_variable_varinfo_loc.sil +++ b/test/DebugInfo/debug_variable_varinfo_loc.sil @@ -10,9 +10,9 @@ sil_scope 2 { loc "simple.swift":1:2 parent @test_debug_value : $@convention(thi // CHECK-SAME: !dbg ![[FUNC_DI:[0-9]+]] sil hidden @test_debug_value : $@convention(thin) (Builtin.Int64) -> () { bb0(%0 : $Builtin.Int64): - // CHECK: @llvm.dbg.declare(metadata ptr - // CHECK-SAME: metadata ![[VAR_DI:[0-9]+]] - // CHECK-SAME: ), !dbg ![[LOC_DI:[0-9]+]] + // CHECK: #dbg_declare(ptr + // CHECK-SAME: ![[VAR_DI:[0-9]+]] + // CHECK-SAME: , ![[LOC_DI:[0-9]+]] debug_value %0 : $Builtin.Int64, var, name "x", loc "simple.swift":1:16, scope 2 %zero = integer_literal $Builtin.Int64, 0 debug_value %zero : $Builtin.Int64, var, (name "x", loc "simple.swift":1:16, scope 2), loc "simple.swift":3:4, scope 2 diff --git a/test/DebugInfo/doubleinlines.swift b/test/DebugInfo/doubleinlines.swift index 85bd3acd9b865..79f338ca265be 100644 --- a/test/DebugInfo/doubleinlines.swift +++ b/test/DebugInfo/doubleinlines.swift @@ -11,7 +11,7 @@ func callCondFail(arg: Builtin.Int1, msg: Builtin.RawPointer) { } // CHECK: define hidden swiftcc void @"$s13DoubleInlines12callCondFail3arg3msgyBi1__BptF"{{.*}} !dbg ![[FUNC:.*]] { -// CHECK: tail call void asm sideeffect "", "n"(i32 0) #3, !dbg ![[SCOPEONE:.*]] +// CHECK: tail call void asm sideeffect "", "n"(i32 0) #{{[0-9]+}}, !dbg ![[SCOPEONE:.*]] // CHECK: tail call void @llvm.trap(), !dbg ![[LOCTRAP:.*]] // CHECK: ![[FUNCSCOPEOTHER:.*]] = distinct !DISubprogram(name: "condFail",{{.*}} diff --git a/test/DebugInfo/dynamic_layout.swift b/test/DebugInfo/dynamic_layout.swift index dafd0bce55cde..e0b7839698664 100644 --- a/test/DebugInfo/dynamic_layout.swift +++ b/test/DebugInfo/dynamic_layout.swift @@ -10,11 +10,11 @@ class Class { // Verify that the mangling of the type U is correct. // CHECK: define {{.*}}3foo // CHECK: %[[U1:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[U1]], - // CHECK-SAME: metadata ![[U:[0-9]+]] + // CHECK: #dbg_declare(ptr %[[U1]], + // CHECK-SAME: ![[U:[0-9]+]] // CHECK: %[[T2:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[T2]], - // CHECK-SAME: metadata ![[T:[0-9]+]] + // CHECK: #dbg_declare(ptr %[[T2]], + // CHECK-SAME: ![[T:[0-9]+]] // CHECK: ![[U]] = !DILocalVariable(name: "$\CF\84_1_0" // CHECK: ![[T]] = !DILocalVariable(name: "$\CF\84_0_0" func foo (_ y : U) -> (T,U) { diff --git a/test/DebugInfo/generic_arg.swift b/test/DebugInfo/generic_arg.swift index 00acddb3fc2e1..e14aeb9724e5c 100644 --- a/test/DebugInfo/generic_arg.swift +++ b/test/DebugInfo/generic_arg.swift @@ -3,11 +3,11 @@ import StdlibUnittest func foo(_ x: T) -> () { // CHECK: define {{.*}} @"$s11generic_arg3fooyyxlF" // CHECK: %[[T:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[T]], - // CHECK-SAME: metadata ![[T1:.*]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr %[[T]], + // CHECK-SAME: ![[T1:.*]], !DIExpression() // CHECK: %[[X:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[X]], - // CHECK-SAME: metadata ![[X1:.*]], metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare(ptr %[[X]], + // CHECK-SAME: ![[X1:.*]], !DIExpression(DW_OP_deref) // CHECK: store ptr %T, ptr %[[T]], // CHECK: store ptr %0, ptr %[[X]], // CHECK-DAG: ![[T1]] = !DILocalVariable(name: "$\CF\84_0_0",{{.*}}flags: DIFlagArtificial) diff --git a/test/DebugInfo/generic_arg2.swift b/test/DebugInfo/generic_arg2.swift index 8876a76a38496..5a965b4cdfbd4 100644 --- a/test/DebugInfo/generic_arg2.swift +++ b/test/DebugInfo/generic_arg2.swift @@ -1,9 +1,9 @@ // RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s // CHECK: define hidden swiftcc void @"$s12generic_arg25ClassC3foo{{.*}}, ptr %U -// CHECK: call void @llvm.dbg.declare(metadata ptr %y.debug, metadata ![[U:.*]], metadata !DIExpression(DW_OP_deref)) +// CHECK: #dbg_declare(ptr %y.debug, ![[U:.*]], !DIExpression(DW_OP_deref) // Make sure there is no conflicting dbg.value for this variable.x -// CHECK-NOT: dbg.value{{.*}}metadata ![[U]] +// CHECK-NOT: #dbg_value{{.*}}![[U]] class Class { // CHECK: ![[U]] = !DILocalVariable(name: "y", arg: 2{{.*}} line: [[@LINE+1]], func foo(_ x: T, y: U) {} diff --git a/test/DebugInfo/generic_arg3.swift b/test/DebugInfo/generic_arg3.swift index 2844bcedf4201..f2da7f7673226 100644 --- a/test/DebugInfo/generic_arg3.swift +++ b/test/DebugInfo/generic_arg3.swift @@ -5,7 +5,7 @@ func apply(_ T : Type, fn: (Type) -> Type) -> Type { return fn(T) } public func f(_ value : Type) { // CHECK: define {{.*}}$s12generic_arg31fyyxlFxxXEfU_ - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA:.*]], metadata ![[ARG:.*]], metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare(ptr %[[ALLOCA:.*]], ![[ARG:.*]], !DIExpression(DW_OP_deref) // CHECK: store ptr %1, ptr %[[ALLOCA]], align // No deref here. // CHECK-DAG: ![[TY:.*]] = !DICompositeType({{.*}}name: "$sxD", file diff --git a/test/DebugInfo/generic_arg4.swift b/test/DebugInfo/generic_arg4.swift index 707209f0513c2..fb3dcefd16e69 100644 --- a/test/DebugInfo/generic_arg4.swift +++ b/test/DebugInfo/generic_arg4.swift @@ -4,9 +4,9 @@ public struct Q { let x: T } // CHECK: define {{.*}}$s12generic_arg43fooyySayAA1QVyxGGlF -// CHECK: call void @llvm.dbg.declare -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA:[^,]+]], -// CHECK-SAME: metadata ![[ARG:.*]], metadata !DIExpression()) +// CHECK: #dbg_declare +// CHECK: #dbg_declare(ptr %[[ALLOCA:[^,]+]], +// CHECK-SAME: ![[ARG:.*]], !DIExpression() // CHECK: store ptr %0, ptr %[[ALLOCA]], align // No deref here: the array argument is passed by value. // CHECK: ![[DITY:.*]] = !DICompositeType({{.*}}name: "$sSay12generic_arg41QVyxGGD" diff --git a/test/DebugInfo/generic_arg5.swift b/test/DebugInfo/generic_arg5.swift index 9cc609045998f..d6e78a694d5e5 100644 --- a/test/DebugInfo/generic_arg5.swift +++ b/test/DebugInfo/generic_arg5.swift @@ -7,10 +7,10 @@ public struct S public func foo(_ values : [S]) { // CHECK: define {{.*}}$s12generic_arg53fooyySayAA1SVyxGGlFAESgAEXEfU_ - // CHECK: call void @llvm.dbg.declare - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA:[^,]+]], - // CHECK-SAME: metadata ![[ARG:[0-9]+]], - // CHECK-SAME: metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare + // CHECK: #dbg_declare(ptr %[[ALLOCA:[^,]+]], + // CHECK-SAME: ![[ARG:[0-9]+]], + // CHECK-SAME: !DIExpression(DW_OP_deref) // CHECK: store ptr %1, ptr %[[ALLOCA]], align // CHECK: ![[TYP:[0-9]+]] = !DICompositeType({{.*}}, name: "$s12generic_arg51SVyxGD" // The argument is a by-ref struct and thus needs to be dereferenced. diff --git a/test/DebugInfo/generic_enum_closure.swift b/test/DebugInfo/generic_enum_closure.swift index e95c1463b3926..de1aeca896490 100644 --- a/test/DebugInfo/generic_enum_closure.swift +++ b/test/DebugInfo/generic_enum_closure.swift @@ -8,11 +8,10 @@ struct CErrorOr // CHECK: define hidden {{.*}}void @"$s20generic_enum_closure8CErrorOrV1xACyxGAA14__CurrentErrnoV_tcfC" // CHECK-NOT: define // This is a SIL-level debug_value_addr instruction. - // CHECK: call void @llvm.dbg.declare + // CHECK: #dbg_declare // Self is in a dynamic alloca, hence the shadow copy. - // CHECK: call void @llvm.dbg.declare( - // CHECK-SAME: metadata ptr %[[SHADOW:.*]], metadata ![[SELF:.*]], meta - // CHECK-SAME: !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare( + // CHECK-SAME: ptr %[[SHADOW:.*]], ![[SELF:.*]], !DIExpression(DW_OP_deref) // CHECK-DAG: store ptr %[[DYN:.*]], ptr %[[SHADOW]] // CHECK-DAG: %[[DYN]] = alloca i8, i{{32|64}} % // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, type: ![[TY_CONTAINER:.*]]) diff --git a/test/DebugInfo/guard-let.swift b/test/DebugInfo/guard-let.swift index 6ac87a636b981..5b5cf832b5d4c 100644 --- a/test/DebugInfo/guard-let.swift +++ b/test/DebugInfo/guard-let.swift @@ -21,11 +21,11 @@ public func f(_ i : Int?) { // CHECK1-LABEL: define {{.*}}@"$s4main1fyySiSgF" // CHECK1: %[[alloca:.*]] = alloca %TSiSg - // CHECK1: @llvm.dbg.declare(metadata ptr %i.debug + // CHECK1: #dbg_declare(ptr %i.debug // CHECK1: call void @llvm.memset{{.*}}(ptr align {{(4|8)}} %[[alloca]], // CHECK1-SAME: i8 0, i64 {{(5|9)}}, i1 false){{$}} - // CHECK1: @llvm.dbg.declare(metadata ptr %val.debug, - // CHECK1-SAME: !dbg ![[DBG0:.*]] + // CHECK1: #dbg_declare(ptr %val.debug, !{{.*}}, !DIExpression{{.*}}, + // CHECK1-SAME: ![[DBG0:.*]]) // CHECK1-LABEL: define {{.*}}@"$s4main1gyySSSgF" // CHECK1: ![[F:.*]] = distinct !DISubprogram(name: "f", // CHECK1: ![[BLK:.*]] = distinct !DILexicalBlock(scope: ![[F]], @@ -38,9 +38,9 @@ public func g(_ s : String?) { // CHECK2: define {{.*}}@"$s4main1gyySSSgF" // CHECK2: %[[alloca:.*]] = alloca %TSSSg - // CHECK2: @llvm.dbg.declare(metadata ptr + // CHECK2: #dbg_declare(ptr // CHECK2: %val.debug = alloca %TSS - // CHECK2: @llvm.dbg.declare(metadata ptr + // CHECK2: #dbg_declare(ptr // CHECK2: call void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[alloca]], i8 0 // CHECK2: ![[G:.*]] = distinct !DISubprogram(name: "g" guard let val = s else { return } @@ -51,9 +51,9 @@ public func h(_ s : String?) { // CHECK3: define {{.*}}@"$s4main1hyySSSgF" // CHECK3: %s.debug = alloca %TSSSg - // CHECK3: @llvm.dbg.declare(metadata ptr + // CHECK3: #dbg_declare(ptr // CHECK3: %[[alloca:.*]] = alloca %TSS - // CHECK3: @llvm.dbg.declare(metadata ptr + // CHECK3: #dbg_declare(ptr // CHECK3: call void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[alloca]], i8 0 // CHECK3: ![[G:.*]] = distinct !DISubprogram(name: "h" guard let s = s else { return } diff --git a/test/DebugInfo/inlined-generics-basic.swift b/test/DebugInfo/inlined-generics-basic.swift index 44ea5e9bcd083..83db5691e8622 100644 --- a/test/DebugInfo/inlined-generics-basic.swift +++ b/test/DebugInfo/inlined-generics-basic.swift @@ -50,11 +50,11 @@ public class C { // SIL: debug_value %0 : $*S, let, name "s", argno 1, expr op_deref, {{.*}} scope [[F]] // SIL: function_ref {{.*}}yes{{.*}} scope [[F1G1]] // SIL: function_ref {{.*}}use{{.*}} scope [[F1G3H]] - // IR: dbg.value(metadata ptr %[[ARG_S]], metadata ![[MD_1_0:[0-9]+]] + // IR: #dbg_value(ptr %[[ARG_S]], ![[MD_1_0:[0-9]+]] // IR: %[[RS_PAIR:.*]] = alloca i8, i{{.*}} % - // IR: dbg.value(metadata ptr %[[ARG_0]], metadata ![[S:[0-9]+]] - // IR: dbg.value(metadata ptr %[[ARG_0]], metadata ![[GS_T:[0-9]+]] - // IR: dbg.value(metadata ptr %[[ARG_0]], metadata ![[GS_U:[0-9]+]] + // IR: #dbg_value(ptr %[[ARG_0]], ![[S:[0-9]+]] + // IR: #dbg_value(ptr %[[ARG_0]], ![[GS_T:[0-9]+]] + // IR: #dbg_value(ptr %[[ARG_0]], ![[GS_U:[0-9]+]] // IR: call {{.*}}3use #sourceLocation(file: "f.swift", line: 2) g(s) @@ -63,26 +63,26 @@ public class C { // ref_element_addr in that removed block is left with a single // debug_value use, so they are both deleted. This means we have // no debug value for "t" in the call to `g(r)`. - // dbg.value({{.*}}, metadata ![[GR_T:[0-9]+]] + // dbg_value({{.*}}, ![[GR_T:[0-9]+]] - // IR: dbg.value({{.*}}, metadata ![[GR_U:[0-9]+]] + // IR: #dbg_value({{.*}}, ![[GR_U:[0-9]+]], !DIExp // IR: call {{.*}}3use #sourceLocation(file: "f.swift", line: 3) g(r) - // IR: dbg.value(metadata ptr %[[RS_PAIR]], metadata ![[GRS_T:[0-9]+]], - // IR: dbg.value(metadata ptr %[[RS_PAIR]], metadata ![[GRS_U:[0-9]+]], + // IR: #dbg_value(ptr %[[RS_PAIR]], ![[GRS_T:[0-9]+]], + // IR: #dbg_value(ptr %[[RS_PAIR]], ![[GRS_U:[0-9]+]], // IR: call {{.*}}3use #sourceLocation(file: "f.swift", line: 4) g((r, s)) - // Note to maintainers: the relative order of the constant dbg.values here + // Note to maintainers: the relative order of the constant dbg_values here // seem to flip back and forth. - // IR: dbg.value(metadata i{{.*}} 0, metadata ![[GI_U:[0-9]+]] - // IR: dbg.value(metadata i{{.*}} 0, metadata ![[GI_T:[0-9]+]] + // IR: #dbg_value(i{{.*}} 0, ![[GI_U:[0-9]+]] + // IR: #dbg_value(i{{.*}} 0, ![[GI_T:[0-9]+]] // IR: call {{.*}}3use{{.*}}(i{{.*}} 0) #sourceLocation(file: "f.swift", line: 5) g(Int(0)) - // IR: dbg.value(metadata i1 false, metadata ![[GB_U:[0-9]+]] - // IR: dbg.value(metadata i1 false, metadata ![[GB_T:[0-9]+]] + // IR: #dbg_value(i1 false, ![[GB_U:[0-9]+]] + // IR: #dbg_value(i1 false, ![[GB_T:[0-9]+]] // IR: call {{.*}}3use{{.*}}(i1 false) #sourceLocation(file: "f.swift", line: 6) g(false) diff --git a/test/DebugInfo/inlined-generics.swift b/test/DebugInfo/inlined-generics.swift index 3efba82d3428f..c48b0bd77ff25 100644 --- a/test/DebugInfo/inlined-generics.swift +++ b/test/DebugInfo/inlined-generics.swift @@ -12,8 +12,8 @@ func foo1(_ t: T, _ dt: T.DT1) -> T.DT1 { // CHECK: define {{.*}}@"$s4main4foo2yyxAA1PRzlF" public func foo2(_ s: S) { - // CHECK: call void @llvm.dbg.value(metadata ptr %S, - // CHECK-SAME: metadata ![[META:[0-9]+]] + // CHECK: #dbg_value(ptr %S, + // CHECK-SAME: ![[META:[0-9]+]] foo1(s, s.getDT()) // T should get substituted with S // CHECK: ![[META]] = !DILocalVariable(name: "$\CF\84_0_0" diff --git a/test/DebugInfo/inlinedAt.swift b/test/DebugInfo/inlinedAt.swift index a98548a493e1f..ee9debb02ddea 100644 --- a/test/DebugInfo/inlinedAt.swift +++ b/test/DebugInfo/inlinedAt.swift @@ -33,9 +33,9 @@ public func f(_ i : Int) -> Int { // 301 // CHECK: define {{.*}}@"$s9inlinedAt1fyS2iF"({{.*}}) // CHECK-NOT: ret -// CHECK: @llvm.dbg.value -// CHECK: @llvm.dbg.value -// CHECK: @llvm.dbg.value({{.*}}), !dbg ![[L1:.*]] +// CHECK: #dbg_value +// CHECK: #dbg_value +// CHECK: #dbg_value({{.*}}), ![[L1:.*]]) // CHECK: ![[F:.*]] = distinct !DISubprogram(name: "f", // CHECK: ![[G:.*]] = distinct !DISubprogram(name: "g", diff --git a/test/DebugInfo/inout.swift b/test/DebugInfo/inout.swift index 090c9654c2c2a..e947bcd3e1a24 100644 --- a/test/DebugInfo/inout.swift +++ b/test/DebugInfo/inout.swift @@ -10,13 +10,13 @@ typealias MyFloat = Float // CHECK: define hidden swiftcc void @"$s5inout13modifyFooHeap{{[_0-9a-zA-Z]*}}F" // CHECK: %[[ALLOCA:.*]] = alloca ptr -// CHECK: call void @llvm.dbg.declare(metadata -// CHECK-SAME: %[[ALLOCA]], metadata ![[A:[0-9]+]] +// CHECK: #dbg_declare( +// CHECK-SAME: %[[ALLOCA]], ![[A:[0-9]+]] // Closure with promoted capture. // PROMO-CHECK: define {{.*}}@"$s5inout13modifyFooHeapyys5Int64Vz_SftFADyXEfU_" -// PROMO-CHECK: call void @llvm.dbg.declare(metadata ptr % -// PROMO-CHECK-SAME: metadata ![[A1:[0-9]+]], metadata !DIExpression(DW_OP_deref)) +// PROMO-CHECK: #dbg_declare(ptr % +// PROMO-CHECK-SAME: ![[A1:[0-9]+]], !DIExpression(DW_OP_deref) // PROMO-CHECK: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "$ss5Int64VD" // PROMO-CHECK: ![[A1]] = !DILocalVariable(name: "a", arg: 1,{{.*}} type: ![[INT]] @@ -36,8 +36,8 @@ func modifyFooHeap(_ a: inout Int64, // Inout reference type. // FOO-CHECK: define {{.*}}@"$s5inout9modifyFooyys5Int64Vz_SftF" -// FOO-CHECK: call void @llvm.dbg.declare(metadata ptr % -// FOO-CHECK-SAME: metadata ![[U:[0-9]+]], metadata !DIExpression(DW_OP_deref)) +// FOO-CHECK: #dbg_declare(ptr % +// FOO-CHECK-SAME: ![[U:[0-9]+]], !DIExpression(DW_OP_deref) func modifyFoo(_ u: inout Int64, // FOO-CHECK-DAG: !DILocalVariable(name: "v", arg: 2{{.*}} line: [[@LINE+3]],{{.*}} type: ![[LET_MYFLOAT:[0-9]+]] // FOO-CHECK-DAG: [[U]] = !DILocalVariable(name: "u", arg: 1,{{.*}} line: [[@LINE-2]],{{.*}} type: ![[RINT:[0-9]+]] diff --git a/test/DebugInfo/irgen_undef.sil b/test/DebugInfo/irgen_undef.sil index bab8950c1cfeb..8e1feeacb3c3f 100644 --- a/test/DebugInfo/irgen_undef.sil +++ b/test/DebugInfo/irgen_undef.sil @@ -7,7 +7,7 @@ import Builtin // CHECK-LABEL: define {{.*}} @just_undef sil @just_undef : $@convention(thin) (Builtin.Int64) -> (Builtin.Int64) { bb0(%0 : $Builtin.Int64): -// CHECK: call void @llvm.dbg.value(metadata i64 undef, metadata ![[JUST_UNDEF_VAR:[0-9]+]], metadata !DIExpression()) +// CHECK: #dbg_value(i64 undef, ![[JUST_UNDEF_VAR:[0-9]+]], !DIExpression() debug_value undef : $Builtin.Int64, var, name "optimizedout" return %0 : $Builtin.Int64 } @@ -15,12 +15,12 @@ return %0 : $Builtin.Int64 // CHECK-LABEL: define {{.*}} @arithmetic sil @arithmetic : $@convention(thin) (Builtin.Int64) -> (Builtin.Int64) { bb0(%0 : $Builtin.Int64): -// CHECK: call void @llvm.dbg.value(metadata i64 %0, metadata ![[CURRENT_VAR:[0-9]+]], metadata !DIExpression()) +// CHECK: #dbg_value(i64 %0, ![[CURRENT_VAR:[0-9]+]], !DIExpression() debug_value %0 : $Builtin.Int64, var, name "current", type $Int64, expr op_fragment:#Int64._value // FIXME: It should work with the fragment, as it should be noop. -// CHECK: call void @llvm.dbg.value(metadata i64 %0, metadata ![[PREVIOUS_VAR:[0-9]+]], metadata !DIExpression(DW_OP_consts, 1, DW_OP_minus, DW_OP_stack_value)) +// CHECK: #dbg_value(i64 %0, ![[PREVIOUS_VAR:[0-9]+]], !DIExpression(DW_OP_consts, 1, DW_OP_minus, DW_OP_stack_value) debug_value %0 : $Builtin.Int64, var, name "previous", type $Int64, expr op_consts:1:op_minus //:op_fragment:#Int64._value -// CHECK: call void @llvm.dbg.value(metadata i64 %0, metadata ![[NEXT_VAR:[0-9]+]], metadata !DIExpression(DW_OP_constu, 12, DW_OP_plus, DW_OP_stack_value)) +// CHECK: #dbg_value(i64 %0, ![[NEXT_VAR:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 12, DW_OP_stack_value) debug_value %0 : $Builtin.Int64, var, name "next", type $Int64, expr op_constu:12:op_plus //:op_fragment:#Int64._value return %0 : $Builtin.Int64 } @@ -28,11 +28,11 @@ return %0 : $Builtin.Int64 // CHECK-LABEL: define {{.*}} @constant sil @constant : $@convention(thin) (Builtin.Int64) -> (Builtin.Int64) { bb0(%0 : $Builtin.Int64): -// CHECK: call void @llvm.dbg.value(metadata i64 42, metadata ![[CONST_VAR:[0-9]+]], metadata !DIExpression(DW_OP_stack_value)) +// CHECK: #dbg_value(i64 42, ![[CONST_VAR:[0-9]+]], !DIExpression(DW_OP_stack_value) debug_value undef : $Builtin.Int64, var, name "const", expr op_consts:42 -// CHECK: call void @llvm.dbg.value(metadata i64 3645, metadata ![[CONSTINT_VAR:[0-9]+]], metadata !DIExpression(DW_OP_stack_value)) +// CHECK: #dbg_value(i64 3645, ![[CONSTINT_VAR:[0-9]+]], !DIExpression(DW_OP_stack_value) debug_value undef : $Builtin.Int64, var, name "constint", type $Int64, expr op_constu:3645:op_fragment:#Int64._value -// CHECK: call void @llvm.dbg.value(metadata i64 6, metadata ![[CONSTUPLE_VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)) +// CHECK: #dbg_value(i64 6, ![[CONSTUPLE_VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 64) debug_value undef : $Builtin.Int64, var, name "constuple", type $(Int64, Int64), expr op_consts:6:op_tuple_fragment:$(Int64, Int64):0:op_fragment:#Int64._value return %0 : $Builtin.Int64 diff --git a/test/DebugInfo/irgen_void_tuple.sil b/test/DebugInfo/irgen_void_tuple.sil index adc58b619202d..f079b83350071 100644 --- a/test/DebugInfo/irgen_void_tuple.sil +++ b/test/DebugInfo/irgen_void_tuple.sil @@ -8,7 +8,7 @@ import Swift sil hidden @couple_of_voids : $@convention(thin) () -> () { bb0: %3 = tuple () - // CHECK-NOT: call void @llvm.dbg.value + // CHECK-NOT: #dbg_value debug_value %3 : $(), let, (name "success", loc "void.swift":3:1), type $*((), ()), expr op_tuple_fragment:$((), ()):0 return %3 : $() } // end sil function 'couple_of_voids' @@ -17,8 +17,8 @@ bb0: sil hidden @one_existing : $@convention(thin) () -> Builtin.Int64 { bb0: %1 = integer_literal $Builtin.Int64, 0 - // CHECK: call void @llvm.dbg.value - // CHECK-SAME: metadata ![[RESULT_VAR:[0-9]+]] + // CHECK: #dbg_value + // CHECK-SAME: ![[RESULT_VAR:[0-9]+]] debug_value %1 : $Builtin.Int64, let, (name "result", loc "void.swift":3:1), type $*(Builtin.Int64, ()), expr op_tuple_fragment:$(Builtin.Int64, ()):0 return %1 : $Builtin.Int64 } // end sil function 'one_existing' @@ -27,7 +27,7 @@ bb0: sil hidden @one_empty : $@convention(thin) () -> () { bb0: %3 = tuple () - // CHECK-NOT: call void @llvm.dbg.value + // CHECK-NOT: #dbg_value debug_value %3 : $(), let, (name "failure", loc "void.swift":3:1), type $*(Builtin.Int64, ()), expr op_tuple_fragment:$(Builtin.Int64, ()):1 return %3 : $() } // end sil function 'one_empty' diff --git a/test/DebugInfo/iuo_arg.swift b/test/DebugInfo/iuo_arg.swift index 701e1138a94d2..250196c18b8db 100644 --- a/test/DebugInfo/iuo_arg.swift +++ b/test/DebugInfo/iuo_arg.swift @@ -17,7 +17,7 @@ class MyClass { func filterImage(_ image: UIImage!, _ doSomething:Bool) -> UIImage { // Test that image is in an alloca, but not an indirect location. - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA:.*]], metadata ![[IMAGE:.*]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr %[[ALLOCA:.*]], ![[IMAGE:.*]], !DIExpression() // CHECK: store {{(i32|i64)}} %0, ptr %[[ALLOCA]], align // CHECK: ![[IMAGE]] = !DILocalVariable(name: "image", arg: 1 // CHECK-NOT: flags: diff --git a/test/DebugInfo/let.swift b/test/DebugInfo/let.swift index 7527526cc4e76..d368f782e113a 100644 --- a/test/DebugInfo/let.swift +++ b/test/DebugInfo/let.swift @@ -5,7 +5,7 @@ class DeepThought { } func foo() -> Int64 { - // CHECK: call void @llvm.dbg.declare(metadata ptr {{.*}}, metadata ![[A:.*]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr {{.*}}, ![[A:.*]], !DIExpression() // CHECK-DAG: !DILocalVariable(name: "machine",{{.*}}line: [[@LINE+1]], type: !{{[0-9]+}}) let machine = DeepThought() // CHECK-DAG: !DILocalVariable(name: "a", {{.*}}line: [[@LINE+1]], diff --git a/test/DebugInfo/letclause.swift b/test/DebugInfo/letclause.swift index 164650b498302..cd8fda1d925ed 100644 --- a/test/DebugInfo/letclause.swift +++ b/test/DebugInfo/letclause.swift @@ -6,8 +6,8 @@ func peek() -> Symbol? { return Symbol() } func foo() { // CHECK: define {{.*}}foo -// CHECK: call void @llvm.dbg.value(metadata i{{.*}} 0, -// CHECK-SAME: metadata ![[S:.*]], metadata !DIExpression()) +// CHECK: #dbg_value(i{{.*}} 0, +// CHECK-SAME: ![[S:.*]], !DIExpression() // CHECK: ![[S]] = !DILocalVariable(name: "s" // CHECK-SAME: line: [[@LINE+1]], while let s = peek() { diff --git a/test/DebugInfo/letstring.swift b/test/DebugInfo/letstring.swift index 2002a262589a0..65d0bd72a1abd 100644 --- a/test/DebugInfo/letstring.swift +++ b/test/DebugInfo/letstring.swift @@ -13,13 +13,13 @@ class AppDelegate { // CHECK: define hidden {{.*}}i1 {{.*}}11AppDelegateC1f func f() -> Bool { // Test for -O0 shadow copies. - // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[SELF:.*]], metadata !DIExpression()) - // CHECK-NOT: call void @llvm.dbg.value - // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[A:.*]], metadata !DIExpression()) + // CHECK: #dbg_declare({{.*}}, ![[SELF:.*]], !DIExpression() + // CHECK-NOT: #dbg_value + // CHECK: #dbg_declare({{.*}}, ![[A:.*]], !DIExpression() let a = "let" - // CHECK-NOT: call void @llvm.dbg.value - // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[B:.*]], metadata !DIExpression()) - // CHECK-NOT: call void @llvm.dbg.value + // CHECK-NOT: #dbg_value + // CHECK: #dbg_declare({{.*}}, ![[B:.*]], !DIExpression() + // CHECK-NOT: #dbg_value // CHECK: ret // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", arg: 1{{.*}} line: [[@LINE-10]], // CHECK-DAG: ![[A]] = !DILocalVariable(name: "a",{{.*}} line: [[@LINE-6]], diff --git a/test/DebugInfo/linetable-codeview.swift b/test/DebugInfo/linetable-codeview.swift index 2fd2bc86d30dc..60769af93c254 100644 --- a/test/DebugInfo/linetable-codeview.swift +++ b/test/DebugInfo/linetable-codeview.swift @@ -54,7 +54,7 @@ func foo() { // func myLoop() { // CHECK: define {{.*}} @"$s4main6myLoopyyF" - // CHECK: call void @llvm.dbg.declare(metadata ptr %index.debug, {{.*}}), !dbg ![[FORLOOP:[0-9]+]] + // CHECK: #dbg_declare(ptr %index.debug, {{.*}}, ![[FORLOOP:[0-9]+]] // CHECK: phi i64 [ %{{.[0-9]+}}, %{{.[0-9]+}} ], !dbg ![[FORLOOP]] // CHECK: call {{.*}} @"$s4main8markUsedyyxlF"{{.*}}, !dbg ![[FORBODY:[0-9]+]] // CHECK: ret void @@ -70,8 +70,8 @@ func foo() { // func foo() // CHECK: define {{.*}} @"$s4main3fooyyF" // CHECK: %[[MYARRAY:.*]] = alloca - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[MYARRAY]], - // CHECK-SAME: !dbg ![[ARRAY:[0-9]+]] + // CHECK: #dbg_declare(ptr %[[MYARRAY]], !{{.*}}, !DIExpression + // CHECK-SAME: ![[ARRAY:[0-9]+]] // CHECK: call swiftcc { {{.*}} } @"${{.*}}_allocateUninitializedArray{{.*}}" // CHECK-SAME: !dbg ![[ARRAY_ALLOC:[0-9]+]] // CHECK: ret void diff --git a/test/DebugInfo/move_function_dbginfo.swift b/test/DebugInfo/move_function_dbginfo.swift index 1c4cbcf40942a..db2e42e06d487 100644 --- a/test/DebugInfo/move_function_dbginfo.swift +++ b/test/DebugInfo/move_function_dbginfo.swift @@ -5,7 +5,7 @@ // This test checks that: // -// 1. At the IR level, we insert the appropriate llvm.dbg.addr, llvm.dbg.value. +// 1. At the IR level, we insert the appropriate #dbg_addr, #dbg_value. // // 2. At the Dwarf that we have proper locations with PC validity ranges where // the value isn't valid. @@ -38,15 +38,15 @@ public var falseValue: Bool { false } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo17copyableValueTestyyF"() // // In contrast, we should have a dbg.declare for m since we aren't -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, metadata ![[M_COPYABLE_VALUE_TEST:[0-9]*]], +// CHECK: #dbg_declare(ptr %m.debug, ![[M_COPYABLE_VALUE_TEST:[0-9]*]], // -// We should have a llvm.dbg.value for k since we moved it. -// CHECK: call void @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_COPYABLE_VALUE_METADATA:[0-9]*]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// We should have a #dbg_value for k since we moved it. +// CHECK: #dbg_value(ptr %k.debug, ![[K_COPYABLE_VALUE_METADATA:[0-9]*]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // -// Our undef should be an llvm.dbg.value. Importantly though its metadata +// Our undef should be an #dbg_value. Importantly though its metadata // should be for k since that is the variable that we are telling the debugger // is no longer defined. -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VALUE_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VALUE_METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK-NOT: br label // // CHECK: ret void @@ -85,15 +85,15 @@ public func copyableValueTest() { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo15copyableArgTestyyAA5KlassCnF"(ptr %0) // // In contrast, we should have a dbg.declare for m since we aren't -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, metadata ![[M_COPYABLE_VALUE_TEST:[0-9]*]], +// CHECK: #dbg_declare(ptr %m.debug, ![[M_COPYABLE_VALUE_TEST:[0-9]*]], // -// We should have a llvm.dbg.value for k since we moved it. -// CHECK: call void @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_COPYABLE_VALUE_METADATA:[0-9]*]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// We should have a #dbg_value for k since we moved it. +// CHECK: #dbg_value(ptr %k.debug, ![[K_COPYABLE_VALUE_METADATA:[0-9]*]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // -// Our undef should be an llvm.dbg.value. Importantly though its metadata +// Our undef should be an #dbg_value. Importantly though its metadata // should be for k since that is the variable that we are telling the debugger // is no longer defined. -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VALUE_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VALUE_METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK-NOT: br label // // CHECK: ret void @@ -127,11 +127,11 @@ public func copyableArgTest(_ k: __owned Klass) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo15copyableVarTestyyF"() -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_METADATA]], !DIExpression(), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -170,11 +170,11 @@ public func copyableVarTest() { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo18copyableVarArgTestyyAA5KlassCzF"( -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -211,8 +211,8 @@ public func copyableVarArgTest(_ k: inout Klass) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo20addressOnlyValueTestyyxAA1PRzlF"(ptr noalias %0, ptr %T, ptr %T.P) -// CHECK: @llvm.dbg.value(metadata ptr %{{.*}}, metadata ![[K_ADDR_LET_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDR_LET_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{.*}}, ![[K_ADDR_LET_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDR_LET_METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -258,10 +258,10 @@ public func addressOnlyValueTest(_ x: T) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo23addressOnlyValueArgTestyyxnAA1PRzlF"( -// CHECK: @llvm.dbg.declare(metadata ptr %T1, -// CHECK: @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_ADDR_LET_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDR_LET_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_declare(ptr %T1, +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr %k.debug, ![[K_ADDR_LET_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDR_LET_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -299,10 +299,10 @@ public func addressOnlyValueArgTest(_ k: __owned T) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo18addressOnlyVarTestyyxAA1PRzlF"(ptr noalias %0, ptr %T, ptr %T.P) -// CHECK: @llvm.dbg.value(metadata ptr %{{.*}}, metadata ![[K_ADDRONLY_VAR_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr %{{.*}}, ![[K_ADDRONLY_VAR_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // CHECK-NEXT: br -// CHECK: @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] -// CHECK: @llvm.dbg.value(metadata ptr %{{.*}}, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRONLY_VAR_METADATA]], !DIExpression(), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{.*}}, ![[K_ADDRONLY_VAR_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -345,9 +345,9 @@ public func addressOnlyVarTest(_ x: T) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo21addressOnlyVarArgTestyyxz_xtAA1PRzlF"( -// CHECK: call void @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_ADDRONLY_VAR_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] -// CHECK: @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %k.debug, ![[K_ADDRONLY_VAR_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRONLY_VAR_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %k.debug, ![[K_ADDRONLY_VAR_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } // @@ -392,12 +392,12 @@ public func addressOnlyVarArgTest(_ k: inout T, _ x: T) { /////////////////////// // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo23copyableValueCCFlowTestyyF"( -// CHECK: call void @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_COPYABLE_LET_CCFLOW_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %k.debug, ![[K_COPYABLE_LET_CCFLOW_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // // CHECK: br i1 {{%[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_LET_CCFLOW_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_LET_CCFLOW_METADATA]], !DIExpression(), ![[ADDR_LOC]] public func copyableValueCCFlowTest() { let k = Klass() k.doSomething() @@ -408,12 +408,12 @@ public func copyableValueCCFlowTest() { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo26copyableValueArgCCFlowTestyyAA5KlassCnF"( -// CHECK: call void @llvm.dbg.value(metadata ptr %k.debug, metadata ![[K_COPYABLE_LET_CCFLOW_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %k.debug, ![[K_COPYABLE_LET_CCFLOW_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // // CHECK: br i1 {{%[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_LET_CCFLOW_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_LET_CCFLOW_METADATA]], !DIExpression(), ![[ADDR_LOC]] public func copyableValueArgCCFlowTest(_ k: __owned Klass) { k.doSomething() if trueValue { @@ -423,13 +423,13 @@ public func copyableValueArgCCFlowTest(_ k: __owned Klass) { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo037copyableVarTestCCFlowReinitOutOfBlockF0yyF"( -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK: br label %[[CONT_BB:[0-9]+]], // // CHECK: [[RHS]]: @@ -437,7 +437,7 @@ public func copyableValueArgCCFlowTest(_ k: __owned Klass) { // // CHECK: [[CONT_BB]]: // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } public func copyableVarTestCCFlowReinitOutOfBlockTest() { @@ -452,20 +452,20 @@ public func copyableVarTestCCFlowReinitOutOfBlockTest() { } // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo040copyableVarArgTestCCFlowReinitOutOfBlockG0yyAA5KlassCzF"( -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: br label %[[CONT_BB:[0-9]+]], // // CHECK: [[RHS]]: // CHECK: br label %[[CONT_BB]], // // CHECK: [[CONT_BB]]: -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } public func copyableVarArgTestCCFlowReinitOutOfBlockTest(_ k: inout Klass) { @@ -480,15 +480,15 @@ public func copyableVarArgTestCCFlowReinitOutOfBlockTest(_ k: inout Klass) { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo034copyableVarTestCCFlowReinitInBlockF0yyF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // @@ -511,15 +511,15 @@ public func copyableVarTestCCFlowReinitInBlockTest() { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo037copyableVarArgTestCCFlowReinitInBlockG0yyAA5KlassCzF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.declare(metadata ptr %m.debug, -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_declare(ptr %m.debug, +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // @@ -541,12 +541,12 @@ public func copyableVarArgTestCCFlowReinitInBlockTest(_ k: inout Klass) { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo040addressOnlyVarTestCCFlowReinitOutOfBlockG0yyxmAA1PRzlF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // // CHECK: [[RHS]]: @@ -554,7 +554,7 @@ public func copyableVarArgTestCCFlowReinitInBlockTest(_ k: inout Klass) { // // CHECK: [[CONT_BB]]: // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } public func addressOnlyVarTestCCFlowReinitOutOfBlockTest(_ x: T.Type) { @@ -570,12 +570,12 @@ public func addressOnlyVarTestCCFlowReinitOutOfBlockTest(_ x: T.Type) { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo043addressOnlyVarArgTestCCFlowReinitOutOfBlockH0yyAA1P_pz_xmtAaCRzlF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // // CHECK: [[RHS]]: @@ -583,7 +583,7 @@ public func addressOnlyVarTestCCFlowReinitOutOfBlockTest(_ x: T.Type) { // // CHECK: [[CONT_BB]]: // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: ret void // CHECK-NEXT: } public func addressOnlyVarArgTestCCFlowReinitOutOfBlockTest(_ k: inout (any P), _ x: T.Type) { @@ -598,14 +598,14 @@ public func addressOnlyVarArgTestCCFlowReinitOutOfBlockTest(_ k: inout (a // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo037addressOnlyVarTestCCFlowReinitInBlockG0yyxmAA1PRzlF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // @@ -628,14 +628,14 @@ public func addressOnlyVarTestCCFlowReinitInBlockTest(_ x: T.Type) { // CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo040addressOnlyVarArgTestCCFlowReinitInBlockH0yyAA1P_pz_xmtAaCRzlF"( // CHECK: entry: -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR:%.*]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr [[VAR:%.*]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // // CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]], // // CHECK: [[LHS]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // TODO: Should this be a deref like the original? -// CHECK: call void @llvm.dbg.value(metadata ptr [[VAR]], metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr [[VAR]], ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], !DIExpression(DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // // CHECK: br label %[[CONT_BB:[a-z\.0-9]+]], // @@ -656,7 +656,7 @@ public func addressOnlyVarArgTestCCFlowReinitInBlockTest(_ k: inout (any } ////////////////////////// -// Late Metadata Checks // +// Late Checks // ////////////////////////// // CHECK-DAG: ![[K_COPYABLE_VALUE_METADATA]] = !DILocalVariable(name: "k", diff --git a/test/DebugInfo/move_function_dbginfo_async.swift b/test/DebugInfo/move_function_dbginfo_async.swift index 9648955b8ebdc..b2f9f315da74b 100644 --- a/test/DebugInfo/move_function_dbginfo_async.swift +++ b/test/DebugInfo/move_function_dbginfo_async.swift @@ -5,7 +5,7 @@ // This test checks that: // -// 1. At the IR level, we insert the appropriate llvm.dbg.value. +// 1. At the IR level, we insert the appropriate #dbg_value. // // 2. At the Dwarf that we have proper locations with PC validity ranges where // the value isn't valid. @@ -45,20 +45,20 @@ public func forceSplit5() async {} // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalF"(ptr swiftasync %0, ptr noalias %1, ptr %T) // CHECK: entry: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[SIMPLE_TEST_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalFTQ0_"(ptr swiftasync %0) // CHECK: entryresume.0: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[SIMPLE_TEST_METADATA_2:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_2:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalFTY1_"(ptr swiftasync %0) // CHECK: entryresume.1: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[SIMPLE_TEST_METADATA_3:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[SIMPLE_TEST_METADATA_3]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_3:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[SIMPLE_TEST_METADATA_3]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void @@ -90,22 +90,22 @@ public func letSimpleTest(_ msg: __owned T) async { } // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalF"(ptr swiftasync %0, ptr %1, ptr noalias %2, ptr %T) -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"(ptr swiftasync %{{[0-9]+}}) // CHECK-NEXT: ret void // CHECK-NEXT: } // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTQ0_"(ptr swiftasync %0) // CHECK: entryresume.0: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_", i64 0, i64 0) // CHECK-NEXT: ret void // CHECK-NEXT: } // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_"(ptr swiftasync %0) // CHECK: entryresume.1: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"(ptr swiftasync // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -115,9 +115,9 @@ public func letSimpleTest(_ msg: __owned T) async { // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY3_"(ptr swiftasync %0) // CHECK: entryresume.3: -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"( // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -202,24 +202,24 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaF"(ptr swiftasync %0) // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY0_"(ptr swiftasync %0) -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref)) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref) // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTQ1_"(ptr swiftasync %0) -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref)) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref) // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY2_"(ptr swiftasync %0) -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTQ3_"(ptr swiftasync %0) -// CHECK: call void @llvm.dbg.value(metadata ptr undef, +// CHECK: #dbg_value(ptr undef, // -// We should see first a llvm.dbg.value to undef the value until we reinit. Then -// we should see a llvm.dbg.value to reinit. +// We should see first a #dbg_value to undef the value until we reinit. Then +// we should see a #dbg_value to reinit. // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY4_"(ptr swiftasync %0) -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref), ![[ADDR_LOC]] // We are not an argument, so no problem here. // @@ -300,23 +300,23 @@ public func varSimpleTestVar() async { //////////////////////////////////// // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalF"( -// CHECK: call void @llvm.dbg.value( +// CHECK: #dbg_value( // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit1yyYaF"( // CHECK-NEXT: ret void // CHECK-NEXT: } // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ0_"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTY1_", i64 0, i64 0) // CHECK-NEXT: ret void // CHECK-NEXT: } // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTY1_"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]*]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]*]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // CHECK: br i1 %{{[0-9]}}, label %[[LHS_BLOCK:[a-zA-Z\.0-9]*]], label %[[RHS_BLOCK:[a-zA-Z\.0-9]*]], // // CHECK: [[LHS_BLOCK]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit2yyYaF"( // CHECK-NEXT: ret void // @@ -330,23 +330,23 @@ public func varSimpleTestVar() async { // _move. // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ2_"( -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA:[0-9]*]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]*]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-NEXT: ret void // // This is the false branch. // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ3_"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[msg_var:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref)) -// CHECK-NEXT: call void @llvm.dbg.value(metadata ptr undef, metadata ![[msg_var]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[msg_var:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) +// CHECK-NEXT: #dbg_value(ptr undef, ![[msg_var]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-NEXT: ret void, // CHECK-NEXT: } // // This is the continuation block // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ4_"( -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata !{{.*}}, metadata !DIExpression(DW_OP_deref)), +// CHECK: #dbg_value(ptr undef, !{{.*}}, !DIExpression(DW_OP_deref), // RUN: %llvm-dwarfdump -c --name='$s3out20letArgCCFlowTrueTestyyxnYalF' %t/out.o | %FileCheck -check-prefix=DWARF17 %s // DWARF17: DW_TAG_subprogram @@ -440,49 +440,49 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // SIL: } // end sil function '$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlF' // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlF"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit1yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ0_"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY1_"( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: br i1 %{{[0-9]+}}, label %[[LHS_BLOCK:[a-zA-Z0-9]+]], label %[[RHS_BLOCK:[a-zA-Z0-9]+]] // CHECK: [[LHS_BLOCK]]: -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit2yyYaF"( // CHECK: [[RHS_BLOCK]]: // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit3yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ2_"( -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_deref)), +// CHECK: #dbg_value(ptr undef, !{{[0-9]+}}, !DIExpression(DW_OP_deref), // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY3_", i64 0, i64 0) // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY3_"( -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ4_"( -// CHECK-NOT: @llvm.dbg.value -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK-NOT: #dbg_value +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY5_", // CHECK: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY5_"( -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]+]] -// CHECK: call void @llvm.dbg.value(metadata ptr undef, metadata ![[METADATA]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC]] -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata ![[METADATA]], metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), !dbg ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ6_"( -// CHECK-NOT: @llvm.dbg.value( -// CHECK: call void @llvm.dbg.value(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref)), -// CHECK-NOT: @llvm.dbg.value( +// CHECK-NOT: #dbg_value( +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), +// CHECK-NOT: #dbg_value( // CHECK: musttail call swifttailcc void %{{[0-9]+}}(ptr swiftasync // CHECK-NEXT: ret void, // CHECK-NEXT: } diff --git a/test/DebugInfo/nostorage.swift b/test/DebugInfo/nostorage.swift index 9b3741cc53238..88e1ec719b81d 100644 --- a/test/DebugInfo/nostorage.swift +++ b/test/DebugInfo/nostorage.swift @@ -8,8 +8,8 @@ func used(_ t: T) {} public class Foo { func foo() { { [weak self] in - // CHECK1: call void @llvm.dbg.value(metadata i{{.*}} 0, - // CHECK1-SAME: metadata ![[TYPE:.*]], metadata + // CHECK1: #dbg_value(i{{.*}} 0, + // CHECK1-SAME: ![[TYPE:.*]], !DIExpression // CHECK1: ![[TYPE]] = !DILocalVariable(name: "type", // CHECK1-SAME: line: [[@LINE+6]], // CHECK1-SAME: type: ![[LET_METAFOO:[0-9]+]] @@ -28,8 +28,8 @@ struct AStruct {} // CHECK2: define{{.*}}app public func app() { // No members? No storage! - // CHECK2: call void @llvm.dbg.value(metadata ptr undef, - // CHECK2-SAME: metadata ![[AT:.*]], metadata + // CHECK2: #dbg_value(ptr undef, + // CHECK2-SAME: ![[AT:.*]], !DIExpression // CHECK2: ![[AT]] = !DILocalVariable(name: "at",{{.*}}line: [[@LINE+1]] var at = AStruct() diff --git a/test/DebugInfo/patternmatching.swift b/test/DebugInfo/patternmatching.swift index 5474412cd215d..ccfc45fb79a55 100644 --- a/test/DebugInfo/patternmatching.swift +++ b/test/DebugInfo/patternmatching.swift @@ -49,43 +49,43 @@ func classifyPoint2(_ p: (Double, Double)) { // Test the scopes for the switch at line 20. -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[P:[0-9]+]], +// CHECK-SCOPES: #dbg_{{.*}}![[P:[0-9]+]], -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X1:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X1LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X1:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X1LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y1:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y1LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y1:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y1LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X2:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X2LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X2:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X2LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y2:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y2LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y2:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y2LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X3:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X3LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X3:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X3LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y3:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y3LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y3:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y3LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X4:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X4LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X4:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X4LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y4:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y4LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y4:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y4LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X5:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X5LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X5:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X5LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y5:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y5LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y5:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y5LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[X6:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[X6LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[X6:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[X6LOC:[0-9]+]] -// CHECK-SCOPES: call void @llvm.dbg{{.*}}metadata ![[Y6:[0-9]+]], -// CHECK-SCOPES-SAME: !dbg ![[Y6LOC:[0-9]+]] +// CHECK-SCOPES: #dbg_{{.*}}![[Y6:[0-9]+]], !DIExpression +// CHECK-SCOPES-SAME: , ![[Y6LOC:[0-9]+]] // Verify that variables end up in separate appropriate scopes. diff --git a/test/DebugInfo/patternvars.swift b/test/DebugInfo/patternvars.swift index 5814867a12bff..dc9b554346397 100644 --- a/test/DebugInfo/patternvars.swift +++ b/test/DebugInfo/patternvars.swift @@ -37,18 +37,18 @@ public func mangle(s: [UnicodeScalar]) -> [UnicodeScalar] { // CHECK: define {{.*}}@"$s11patternvars6mangle1sSayAA13UnicodeScalarVGAF_tFA2EXEfU_" // CHECK: %[[VAL:[0-9]+]] = call swiftcc i32 @"$s11patternvars13UnicodeScalarV5values6UInt32Vvg"( // CHECK: {{[0-9]+}}: -// CHECK-NOT: call void @llvm.dbg.value +// CHECK-NOT: #dbg_value // CHECK-NOT: call void asm sideeffect "", "r" // CHECK: {{[0-9]+}}: -// CHECK-NOT: call void @llvm.dbg.value +// CHECK-NOT: #dbg_value // CHECK-NOT: call void asm sideeffect "", "r" // CHECK: {{[0-9]+}}: -// CHECK-NOT: call void @llvm.dbg.value +// CHECK-NOT: #dbg_value // CHECK-NOT: call void asm sideeffect "", "r" // CHECK: {{[0-9]+}}: -// CHECK-NOT: call void @llvm.dbg.value +// CHECK-NOT: #dbg_value // CHECK-NOT: call void asm sideeffect "", "r" diff --git a/test/DebugInfo/property-setter-implicit-tuple.swift b/test/DebugInfo/property-setter-implicit-tuple.swift index b2e67d612ed3b..7e8734f287596 100644 --- a/test/DebugInfo/property-setter-implicit-tuple.swift +++ b/test/DebugInfo/property-setter-implicit-tuple.swift @@ -12,7 +12,7 @@ struct UInt128 { } // CHECK-LABEL: define {{.+}} @"$s4main7UInt128V10componentss6UInt64V3low_AF4hightvs" set { - // CHECK: call void @llvm.dbg.declare(metadata ptr {{.+}}, metadata ![[NEW_VALUE:[0-9]+]] + // CHECK: #dbg_declare(ptr {{.+}}, ![[NEW_VALUE:[0-9]+]], !DIExpression (self.low, self.high) = (newValue.high, newValue.low) } } diff --git a/test/DebugInfo/protocol-extension.swift b/test/DebugInfo/protocol-extension.swift index aace6d8336245..329f225929f12 100644 --- a/test/DebugInfo/protocol-extension.swift +++ b/test/DebugInfo/protocol-extension.swift @@ -9,8 +9,8 @@ public extension P { public func f() -> Int32 { // CHECK-NEXT: entry: // CHECK-NEXT: %[[ALLOCA:.*]] = alloca ptr, - // CHECK-NEXT: @llvm.dbg.declare(metadata ptr %[[ALLOCA]], - // CHECK-SAME: metadata ![[SELFMETA:.*]], metadata !DIExpression()) + // CHECK-NEXT: #dbg_declare(ptr %[[ALLOCA]], + // CHECK-SAME: ![[SELFMETA:.*]], !DIExpression() return v } } diff --git a/test/DebugInfo/protocol.swift b/test/DebugInfo/protocol.swift index 2b8ba746cb522..3810ee4703338 100644 --- a/test/DebugInfo/protocol.swift +++ b/test/DebugInfo/protocol.swift @@ -23,7 +23,7 @@ class Point : PointUtils { public func main() -> Int64 { var pt = Point(_x: 2.5, _y: 4.25) // CHECK: [[LOC2D:%[a-zA-Z0-9]+]] = alloca %T8protocol10PointUtilsP, align {{(4|8)}} -// CHECK: call void @llvm.dbg.declare(metadata {{.*}} [[LOC2D]], metadata ![[LOC:.*]], metadata !DIExpression()) +// CHECK: #dbg_declare({{.*}} [[LOC2D]], ![[LOC:.*]], !DIExpression() var loc2d : PointUtils = pt var distance = loc2d.distanceFromOrigin() diff --git a/test/DebugInfo/protocolarg.swift b/test/DebugInfo/protocolarg.swift index 999def8e3680b..b0254f3e7533b 100644 --- a/test/DebugInfo/protocolarg.swift +++ b/test/DebugInfo/protocolarg.swift @@ -8,11 +8,11 @@ public protocol IGiveOutInts { } // CHECK: define {{.*}}@"$s11protocolarg16printSomeNumbersyyAA12IGiveOutInts_pF" -// CHECK: @llvm.dbg.declare(metadata ptr % -// CHECK-SAME: metadata ![[ARG:[0-9]+]], -// CHECK-SAME: metadata !DIExpression(DW_OP_deref)) -// CHECK: @llvm.dbg.declare(metadata ptr % -// CHECK-SAME: metadata ![[VAR:.*]], metadata !DIExpression()) +// CHECK: #dbg_declare(ptr % +// CHECK-SAME: ![[ARG:[0-9]+]], +// CHECK-SAME: !DIExpression(DW_OP_deref) +// CHECK: #dbg_declare(ptr % +// CHECK-SAME: ![[VAR:.*]], !DIExpression() public func printSomeNumbers(_ gen: IGiveOutInts) { var gen = gen diff --git a/test/DebugInfo/returnlocation.swift b/test/DebugInfo/returnlocation.swift index 30c483c4d3056..18a761f55dbba 100644 --- a/test/DebugInfo/returnlocation.swift +++ b/test/DebugInfo/returnlocation.swift @@ -11,7 +11,7 @@ import Foundation // RUN: %FileCheck %s --check-prefix=CHECK_NONE < %t.ll // CHECK_NONE: define{{( protected)?}} {{.*}}void {{.*}}none public func none(_ a: inout Int64) { - // CHECK_NONE: call void @llvm.dbg{{.*}}, !dbg + // CHECK_NONE: #dbg_{{.*}} // CHECK_NONE: store i64{{.*}}, !dbg ![[NONE_INIT:.*]] a -= 2 // CHECK_NONE: ret {{.*}}, !dbg ![[NONE_RET:.*]] diff --git a/test/DebugInfo/self-nostorage.swift b/test/DebugInfo/self-nostorage.swift index 44d7ab3b21308..9bd02dc419244 100644 --- a/test/DebugInfo/self-nostorage.swift +++ b/test/DebugInfo/self-nostorage.swift @@ -3,8 +3,8 @@ public struct S { func f() { // CHECK: define {{.*}}$s4main1SV1fyyF - // CHECK: call void @llvm.dbg.value(metadata i{{.*}} 0, - // CHECK-SAME: metadata ![[SELF:[0-9]+]] + // CHECK: #dbg_value(i{{.*}} 0, + // CHECK-SAME: ![[SELF:[0-9]+]] // CHECK: ![[SELF]] = !DILocalVariable(name: "self", arg: 1, } } diff --git a/test/DebugInfo/self.swift b/test/DebugInfo/self.swift index 3cd5cae576a5f..effa14e113f49 100644 --- a/test/DebugInfo/self.swift +++ b/test/DebugInfo/self.swift @@ -16,8 +16,8 @@ public func f() { // CHECK: define {{.*}} @"$s4self11stuffStructVACycfC"( // CHECK-NEXT: entry: // CHECK: %[[ALLOCA:.*]] = alloca %T4self11stuffStructV, align {{(4|8)}} -// CHECK: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], -// CHECK-SAME: metadata ![[SELF:.*]], metadata !DIExpression()), !dbg +// CHECK: #dbg_declare(ptr %[[ALLOCA]], +// CHECK-SAME: ![[SELF:.*]], !DIExpression(), ! // CHECK: ![[STUFFSTRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "stuffStruct", scope:{{.*}}identifier // CHECK: ![[SELF]] = !DILocalVariable(name: "self", scope // CHECK-SAME: type: ![[STUFFSTRUCT]] diff --git a/test/DebugInfo/shadow_copies.swift b/test/DebugInfo/shadow_copies.swift index c3e9bdd4dfaed..f34c285221f1f 100644 --- a/test/DebugInfo/shadow_copies.swift +++ b/test/DebugInfo/shadow_copies.swift @@ -46,8 +46,8 @@ class ClassC // CHECK-NOT: alloca // NOCOPY-NOT: alloca - // CHECK: call void @llvm.dbg.value(metadata i{{(64|32)}} 10 - // NOCOPY: call void @llvm.dbg.value(metadata i{{(64|32)}} 10 + // CHECK: #dbg_value(i{{(64|32)}} 10 + // NOCOPY: #dbg_value(i{{(64|32)}} 10 let x = 10 use(x) diff --git a/test/DebugInfo/shadowcopy-linetable.swift b/test/DebugInfo/shadowcopy-linetable.swift index 777cf88248a77..a71f6b02e423b 100644 --- a/test/DebugInfo/shadowcopy-linetable.swift +++ b/test/DebugInfo/shadowcopy-linetable.swift @@ -8,7 +8,7 @@ func foo(_ x: inout Int64) { // not. // CHECK: define hidden swiftcc void @"$s4main3fooyys5Int64VzF" // CHECK: %[[X:.*]] = alloca ptr, align {{(4|8)}} - // CHECK-NEXT: call void @llvm.dbg.declare + // CHECK-NEXT: #dbg_declare // CHECK-NEXT: call void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[X]], i8 0 // CHECK: store ptr %0, ptr %[[X]], align {{(4|8)}} // CHECK-SAME: !dbg ![[LOC0:.*]] diff --git a/test/DebugInfo/sil_combine.sil b/test/DebugInfo/sil_combine.sil index 93de18ebadd14..c75078413e622 100644 --- a/test/DebugInfo/sil_combine.sil +++ b/test/DebugInfo/sil_combine.sil @@ -17,8 +17,8 @@ bb0(%0 : $Builtin.RawPointer): %addr1 = index_addr %addr : $*UInt8, %offset1 : $Builtin.Word // CHECK: debug_value %[[ADDR]] : $*UInt8, let, name "hello" // CHECK-SAME: expr op_constu:3:op_plus:op_deref - // CHECK-IR: call void @llvm.dbg.value(metadata ptr %0, metadata ![[DBG_VAR:[0-9]+]], - // CHECK-IR-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus, DW_OP_deref) + // CHECK-IR: #dbg_value(ptr %0, ![[DBG_VAR:[0-9]+]], + // CHECK-IR-SAME: !DIExpression(DW_OP_plus_uconst, 3, DW_OP_deref) debug_value %addr1 : $*UInt8, let, name "hello", expr op_deref %addr2 = index_addr %addr1 : $*UInt8, %offset2 : $Builtin.Word %ptr = address_to_pointer %addr2 : $*UInt8 to $Builtin.RawPointer diff --git a/test/DebugInfo/sroa_mem2reg.sil b/test/DebugInfo/sroa_mem2reg.sil index 2d114bb39b8c7..b856ad8e2d07c 100644 --- a/test/DebugInfo/sroa_mem2reg.sil +++ b/test/DebugInfo/sroa_mem2reg.sil @@ -59,17 +59,17 @@ bb0(%0 : $Int64, %1 : $Int64): // Make sure the struct fields' SSA values are properly connected to the source variables via op_fragment // CHECK-MEM2REG: debug_value %[[FIELD_X]] : $Int64, var, (name "my_struct", loc "sroa.swift":8:9), type $MyStruct, expr op_fragment:#MyStruct.x // CHECK-MEM2REG: debug_value %[[FIELD_Y]] : $Int64, var, (name "my_struct", loc "sroa.swift":8:9), type $MyStruct, expr op_fragment:#MyStruct.y - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %0 - // CHECK-IR-SAME: metadata ![[STRUCT_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %0 + // CHECK-IR-SAME: ![[STRUCT_MD:[0-9]+]] // CHECK-IR-SAME: !DIExpression(DW_OP_LLVM_fragment, 0, 64) - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %1 - // CHECK-IR-SAME: metadata ![[STRUCT_MD]] + // CHECK-IR: #dbg_value(i64 %1 + // CHECK-IR-SAME: ![[STRUCT_MD]] // CHECK-IR-SAME: !DIExpression(DW_OP_LLVM_fragment, 64, 64) // Make sure function arguments' SSA values are also properly connected to the source variables // CHECK-MEM2REG: debug_value %0 : $Int64, var, (name "my_struct", loc "sroa.swift":8:9), type $MyStruct, expr op_fragment:#MyStruct.x // CHECK-MEM2REG: debug_value %1 : $Int64, var, (name "my_struct", loc "sroa.swift":8:9), type $MyStruct, expr op_fragment:#MyStruct.y - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %0, metadata ![[ARG1_MD:[0-9]+]] - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %1, metadata ![[ARG2_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %0, ![[ARG1_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %1, ![[ARG2_MD:[0-9]+]] dealloc_stack %4 : $*MyStruct, loc "sroa.swift":8:9, scope 2 return %0 : $Int64, loc "sroa.swift":11:5, scope 2 } // end sil function 'foo' diff --git a/test/DebugInfo/sroa_mem2reg_tuple.sil b/test/DebugInfo/sroa_mem2reg_tuple.sil index e5926ccfbd1a8..6a57fd5af2693 100644 --- a/test/DebugInfo/sroa_mem2reg_tuple.sil +++ b/test/DebugInfo/sroa_mem2reg_tuple.sil @@ -49,15 +49,15 @@ bb0(%0 : $Int64, %1 : $Int64): %18 = tuple_element_addr %4 : $*(x: Int64, y: Int64), 1, loc "sroa.swift":4:12, scope 3 store %1 to %18 : $*Int64, loc "sroa.swift":4:12, scope 3 - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %0 - // CHECK-IR-SAME: metadata ![[MY_TUP_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %0 + // CHECK-IR-SAME: ![[MY_TUP_MD:[0-9]+]] // CHECK-IR-SAME: !DIExpression(DW_OP_LLVM_fragment, 0, 64) - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %1 - // CHECK-IR-SAME: metadata ![[MY_TUP_MD]] + // CHECK-IR: #dbg_value(i64 %1 + // CHECK-IR-SAME: ![[MY_TUP_MD]] // CHECK-IR-SAME: !DIExpression(DW_OP_LLVM_fragment, 64, 64) - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %0, metadata ![[ARG1_MD:[0-9]+]] - // CHECK-IR: call void @llvm.dbg.value(metadata i64 %1, metadata ![[ARG2_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %0, ![[ARG1_MD:[0-9]+]] + // CHECK-IR: #dbg_value(i64 %1, ![[ARG2_MD:[0-9]+]] dealloc_stack %4 : $*(x: Int64, y: Int64), loc "sroa.swift":2:7, scope 3 return %0 : $Int64, loc "sroa.swift":5:3, scope 3 diff --git a/test/DebugInfo/struct_resilience.swift b/test/DebugInfo/struct_resilience.swift index 40b558ea96fa4..cb61989359983 100644 --- a/test/DebugInfo/struct_resilience.swift +++ b/test/DebugInfo/struct_resilience.swift @@ -22,9 +22,9 @@ public func f() { let s1 = Size(w: 1, h: 2) takesSize(s1) // CHECK: %[[ADDR:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[ADDR]], - // CHECK-SAME: metadata ![[V1:[0-9]+]], - // CHECK-SAME: metadata !DIExpression(DW_OP_deref)) + // CHECK: #dbg_declare(ptr %[[ADDR]], + // CHECK-SAME: ![[V1:[0-9]+]], + // CHECK-SAME: !DIExpression(DW_OP_deref) // CHECK: %[[S1:.*]] = alloca i8, // CHECK: store ptr %[[S1]], ptr %[[ADDR]] } diff --git a/test/DebugInfo/structs.swift b/test/DebugInfo/structs.swift index 4a951f9c21df9..7082f1754ab5c 100644 --- a/test/DebugInfo/structs.swift +++ b/test/DebugInfo/structs.swift @@ -12,7 +12,7 @@ func test(_ x : A) { } // CHECK: define hidden {{.*}}void @"$s7structs4test{{[_0-9a-zA-Z]*}}F" // CHECK: [[X_DBG:%.*]] = alloca -// CHECK: call void @llvm.dbg.declare(metadata ptr [[X_DBG]], metadata [[X_MD:!.*]], metadata +// CHECK: #dbg_declare(ptr [[X_DBG]], [[X_MD:!.*]], !DIExpression // A class is represented by a pointer, so B's total size should be PTRSIZE. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "B",{{.*}}size: [[PTRSIZE]] diff --git a/test/DebugInfo/typearg.swift b/test/DebugInfo/typearg.swift index 1d9e640049dc6..ecd0f86f2ff44 100644 --- a/test/DebugInfo/typearg.swift +++ b/test/DebugInfo/typearg.swift @@ -8,7 +8,7 @@ class AClass : AProtocol { } // CHECK: define hidden {{.*}}void @{{.*}}aFunction -// CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[TYPEARG:.*]], metadata !DIExpression()), +// CHECK: #dbg_declare(ptr %{{.*}}, ![[TYPEARG:.*]], !DIExpression(), // CHECK: ![[TYPEARG]] = !DILocalVariable(name: "$\CF\84_0_0" // CHECK-SAME: type: ![[SWIFTMETATYPE:[^,)]+]] // CHECK-SAME: flags: DIFlagArtificial diff --git a/test/DebugInfo/uninitialized.swift b/test/DebugInfo/uninitialized.swift index 3664dfbb4bcfd..77df41a31e0ae 100644 --- a/test/DebugInfo/uninitialized.swift +++ b/test/DebugInfo/uninitialized.swift @@ -7,7 +7,7 @@ class MyClass {} public func f() { var object: MyClass // CHECK: %[[OBJ:.*]] = alloca ptr, align - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[OBJ]], + // CHECK: #dbg_declare(ptr %[[OBJ]], // CHECK: void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[OBJ]], i8 0, // CHECK-SAME: ){{$}} // OPT-NOT: @llvm.memset @@ -19,7 +19,7 @@ public func f() { public func g() { var dict: Dictionary // CHECK: %[[DICT:.*]] = alloca - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[DICT]], + // CHECK: #dbg_declare(ptr %[[DICT]], // CHECK: void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[DICT]], i8 0, // CHECK-SAME: ){{$}} // OPT-NOT: @llvm.memset diff --git a/test/DebugInfo/value-update.sil b/test/DebugInfo/value-update.sil index c1975d34c03af..e67484d41adea 100644 --- a/test/DebugInfo/value-update.sil +++ b/test/DebugInfo/value-update.sil @@ -12,7 +12,7 @@ bb0: %1 = integer_literal $Builtin.Int64, 23 %2 = struct $Int (%1 : $Builtin.Int64) debug_value %2 : $Int, var, name "v" - // CHECK: call void @llvm.dbg.value(metadata i64 23, + // CHECK: #dbg_value(i64 23, // function_ref StdlibUnittest._blackHole (A) -> () %5 = function_ref @_TF14StdlibUnittest10_blackHoleurFxT_ : $@convention(thin) <τ_0_0> (@in τ_0_0) -> () // user: %8 %6 = tuple () @@ -20,7 +20,7 @@ bb0: %8 = apply %5<()>(%7) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> () dealloc_stack %7 : $*() // id: %9 - // CHECK: call void @llvm.dbg.value(metadata i64 42, + // CHECK: #dbg_value(i64 42, %9 = integer_literal $Builtin.Int64, 42 // user: %10 %10 = struct $Int (%9 : $Builtin.Int64) // user: %11 debug_value %10 : $Int, var, name "v" diff --git a/test/DebugInfo/variables.swift b/test/DebugInfo/variables.swift index fe23ee2970d4a..8ee35fd4917aa 100644 --- a/test/DebugInfo/variables.swift +++ b/test/DebugInfo/variables.swift @@ -46,7 +46,7 @@ var unused: Int32 = -1 // Stack variables. func foo(_ dt: Float) -> Float { - // CHECK-DAG: call void @llvm.dbg.declare + // CHECK-DAG: #dbg_declare // CHECK-DAG: !DILocalVariable(name: "f" let f: Float = 9.78 diff --git a/test/DebugInfo/variadic-generics-count.swift b/test/DebugInfo/variadic-generics-count.swift index 45cddba6b6410..839f06a127dad 100644 --- a/test/DebugInfo/variadic-generics-count.swift +++ b/test/DebugInfo/variadic-generics-count.swift @@ -4,7 +4,7 @@ public func f1(ts: repeat each T) { // CHECK: define {{.*}} @"$s1a2f12tsyxxQp_tRvzlF"(ptr {{.*}}, i{{32|64}} [[COUNT1_1:.*]], ptr {{.*}}) // CHECK-DAG: store i{{32|64}} [[COUNT1_1]], ptr %[[COUNT1_1_A:.*]], align - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT1_1_A]], metadata ![[COUNT1_1_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT1_1_A]], ![[COUNT1_1_VAR:[0-9]+]], !DIExpression() // CHECK-LABEL: ret void } @@ -12,22 +12,22 @@ public func f2(us: repeat each U, vs: repeat each V) { // CHECK: define {{.*}} @"$s1a2f22us2vsyxxQp_q_q_QptRvzRv_r0_lF"(ptr {{.*}}, ptr {{.*}}, i{{32|64}} [[COUNT2_1:.*]], i{{32|64}} [[COUNT2_2:.*]], ptr {{.*}}, ptr {{.*}}) // CHECK-DAG: store i{{32|64}} [[COUNT2_1]], ptr %[[COUNT2_1_A:.*]], align // CHECK-DAG: store i{{32|64}} [[COUNT2_2]], ptr %[[COUNT2_2_A:.*]], align - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT2_1_A]], metadata ![[COUNT2_1_VAR:[0-9]+]], metadata !DIExpression()) - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT2_2_A]], metadata ![[COUNT2_2_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT2_1_A]], ![[COUNT2_1_VAR:[0-9]+]], !DIExpression() + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT2_2_A]], ![[COUNT2_2_VAR:[0-9]+]], !DIExpression() // CHECK-LABEL: ret void } public func f3(ts: repeat each T, more_ts: repeat each T) { // CHECK: define {{.*}} @"$s1a2f32ts05more_B0yxxQp_xxQptRvzlF"(ptr {{.*}}, ptr {{.*}}, i{{32|64}} [[COUNT3_1:.*]], ptr {{.*}}) // CHECK-DAG: store i{{32|64}} [[COUNT3_1]], ptr %[[COUNT3_1_A:.*]], align - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT3_1_A]], metadata ![[COUNT3_1_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT3_1_A]], ![[COUNT3_1_VAR:[0-9]+]], !DIExpression() // CHECK-LABEL: ret void } public func f4(us: repeat (each U, each V)) { // CHECK: define {{.*}} @"$s1a2f42usyx_q_txQp_tRvzRv_q_Rhzr0_lF"(ptr {{.*}}, i{{32|64}} [[COUNT4_1:.*]], ptr {{.*}}, ptr {{.*}}) // CHECK-DAG: store i{{32|64}} [[COUNT4_1]], ptr %[[COUNT4_1_A:.*]], align - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT4_1_A]], metadata ![[COUNT4_1_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT4_1_A]], ![[COUNT4_1_VAR:[0-9]+]], !DIExpression() // CHECK-LABEL: ret void } @@ -42,7 +42,7 @@ public struct S { public func f6(s: S) { // CHECK: define {{.*}} @"$s1a2f61syAA1SVyxxQp_QPG_tRvzlF"(ptr {{.*}}, i{{32|64}} [[COUNT6_1:.*]], ptr {{.*}}) // CHECK-DAG: store i{{32|64}} [[COUNT6_1]], ptr %[[COUNT6_1_A:.*]], align - // CHECK-DAG: call void @llvm.dbg.declare({{.*}}[[COUNT6_1_A]], metadata ![[COUNT6_1_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK-DAG: #dbg_declare({{.*}}[[COUNT6_1_A]], ![[COUNT6_1_VAR:[0-9]+]], !DIExpression() } // CHECK-LABEL: !DICompileUnit diff --git a/test/DebugInfo/variadic-generics.swift b/test/DebugInfo/variadic-generics.swift index 802c8273a4743..779a5bcbb1a0f 100644 --- a/test/DebugInfo/variadic-generics.swift +++ b/test/DebugInfo/variadic-generics.swift @@ -6,9 +6,9 @@ public func foo(args: repeat each T) { // CHECK-SAME: ptr {{.*}} %[[ARG_0:.*]], i{{.*}} %{{.*}}, // CHECK-SAME: ptr %[[TYPE_PACK_ARG:.*]]) // CHECK: %[[TYPE_PACK_ALLOCA:.*]] = alloca ptr - // CHECK: call void @llvm.dbg.declare(metadata ptr %[[TYPE_PACK_ALLOCA]], metadata ![[TYPE_PACK_VAR:[0-9]+]], metadata !DIExpression()) + // CHECK: #dbg_declare(ptr %[[TYPE_PACK_ALLOCA]], ![[TYPE_PACK_VAR:[0-9]+]], !DIExpression() // CHECK: %[[ARGS_ALLOCA:.*]] = alloca ptr - // CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARGS_ALLOCA]], metadata ![[ARGS_VAR:[0-9]+]], metadata !DIExpression(DW_OP_deref)) + // CHECK-DAG: #dbg_declare(ptr %[[ARGS_ALLOCA]], ![[ARGS_VAR:[0-9]+]], !DIExpression(DW_OP_deref) // CHECK-DAG: %[[TYPE_PACK_ARG_INT:[^,]+]] = ptrtoint ptr %[[TYPE_PACK_ARG]] to [[INT]] // CHECK-DAG: %[[TYPE_PACK_ARG_MASKED_INT:[^,]+]] = and [[INT]] %[[TYPE_PACK_ARG_INT]], -2 // CHECK-DAG: %[[TYPE_PACK_ARG_MASKED:[^,]+]] = inttoptr [[INT]] %[[TYPE_PACK_ARG_MASKED_INT]] to ptr diff --git a/test/DebugInfo/weak-self-capture.swift b/test/DebugInfo/weak-self-capture.swift index 676a1482e3a6f..600ddbff0bb54 100644 --- a/test/DebugInfo/weak-self-capture.swift +++ b/test/DebugInfo/weak-self-capture.swift @@ -16,4 +16,4 @@ public class ClosureMaker { } // CHECK: define {{.*}} @"$s4main12ClosureMakerC03getB0SiycyFSiycfU_" -// CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}} !DIExpression(DW_OP_deref)), +// CHECK: #dbg_declare(ptr %{{.*}} !DIExpression(DW_OP_deref) diff --git a/test/IRGen/debug_fragment_merge.sil b/test/IRGen/debug_fragment_merge.sil index 3bf615891fc20..9f29af07aacb8 100644 --- a/test/IRGen/debug_fragment_merge.sil +++ b/test/IRGen/debug_fragment_merge.sil @@ -5,10 +5,10 @@ // arithmethic on the bounds of each fragment. // REQUIRES: CPU=arm64 || CPU=x86_64 || CPU=arm64e -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} !dbg ![[LOC1:[0-9]+]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} !dbg ![[LOC1]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} !dbg ![[LOC1]] -// CHECK-DAG: llvm.dbg.value{{.*}} metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} !dbg ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 192, 64), ![[LOC1:[0-9]+]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 64), ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64), ![[LOC1]] +// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 64), ![[LOC1]] sil_stage canonical From 38bd7f436e104735f5a5e2b619ed86fd2f1c745d Mon Sep 17 00:00:00 2001 From: Dario Rexin Date: Tue, 23 Jul 2024 11:23:32 -0700 Subject: [PATCH 064/110] [Tests] Fix IRGen tests for new LLVM version rdar://132124067 LLVM code gen has changed, so we need to adjust the expected output in our tests accordingly --- test/IRGen/assume.sil | 2 +- test/IRGen/builtin_freeze.swift | 2 + test/IRGen/has_symbol.swift | 129 ++++++++++++------ test/IRGen/has_symbol_async.swift | 24 ++-- test/IRGen/has_symbol_clang.swift | 3 +- test/IRGen/has_symbol_objc.swift | 3 +- .../package_bypass_resilience_class.swift | 4 +- test/IRGen/static_initializer.sil | 2 +- test/IRGen/undef.sil | 6 +- test/IRGen/weak_import_native_hoist.swift | 3 +- 10 files changed, 117 insertions(+), 61 deletions(-) diff --git a/test/IRGen/assume.sil b/test/IRGen/assume.sil index 9ecdf58d96930..b8ff6230edd15 100644 --- a/test/IRGen/assume.sil +++ b/test/IRGen/assume.sil @@ -4,7 +4,7 @@ sil_stage canonical import Swift import Builtin -// CHECK-LABEL: define{{.*}} swiftcc i64 @test_assume(i64 %0) +// CHECK-LABEL: define{{.*}} swiftcc{{.*}} i64 @test_assume(i64 %0) // CHECK: [[COND:%.*]] = icmp sgt i64 %0, -1 // CHECK: tail call void @llvm.assume(i1 [[COND]]) // CHECK: [[RES:%.*]] = lshr i64 %0, 6 diff --git a/test/IRGen/builtin_freeze.swift b/test/IRGen/builtin_freeze.swift index 8efc01616730e..94a8a8d4129cf 100644 --- a/test/IRGen/builtin_freeze.swift +++ b/test/IRGen/builtin_freeze.swift @@ -18,10 +18,12 @@ func yuck() -> Int32 { // CHECK: poison } +// CHECK: define{{.*}} swiftcc{{.*}} i32 @"$s14builtin_freeze3yums5Int32VyF"() func yum() -> Int32 { fptosiWithFreeze(0x1.0p32) // CHECK-NOT: poison } +// CHECK: } func fptosi(_ x: SIMD2) -> SIMD2 { let maybePoison = Builtin.fptosi_Vec2xFPIEEE32_Vec2xInt32(x._storage._value) diff --git a/test/IRGen/has_symbol.swift b/test/IRGen/has_symbol.swift index 2a9025953b2a2..0638965ee31eb 100644 --- a/test/IRGen/has_symbol.swift +++ b/test/IRGen/has_symbol.swift @@ -43,59 +43,85 @@ public func testGlobalFunctions() { // --- function(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper8function4withySi_tFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper8function4withySi_tF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper8function4withySi_tF", null +// CHECK: ret i1 [[RES]] // --- throwingFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper12throwingFuncyyKFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper12throwingFuncyyKF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper12throwingFuncyyKF", null +// CHECK: ret i1 [[RES]] // --- genericFunc(_:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper11genericFuncyyxAA1PRzlFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper11genericFuncyyxAA1PRzlF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper11genericFuncyyxAA1PRzlF", null +// CHECK: ret i1 [[RES]] // --- funcWithOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper20funcWithOpaqueResultQryFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- cdeclFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9cdeclFuncyyFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9cdeclFuncyyF", ptr null), icmp ne (ptr @cdecl_func, ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper9cdeclFuncyyF", null +// CHECK: [[V1:%.*]] = icmp ne ptr @cdecl_func, null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- forwardDeclaredFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper19forwardDeclaredFuncyyFTwS"() -// CHECK: ret i1 icmp ne (ptr @forward_declared_func, ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @forward_declared_func, null +// CHECK: ret i1 [[RES]] // --- dynamicFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper11dynamicFuncyyFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", ptr null) -// CHECK: ret i1 %1 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper11dynamicFuncyyF", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", null +// CHECK: [[RES:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: ret i1 [[RES]] // --- replacementFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper15replacementFuncyyFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyFTX", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper15replacementFuncyyF", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper15replacementFuncyyFTX", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- dynamicFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", ptr null) -// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) -// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) -// CHECK: %4 = and i1 %3, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", ptr null) -// CHECK: %5 = and i1 %4, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", ptr null) -// CHECK: %6 = and i1 %5, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", ptr null) -// CHECK: ret i1 %6 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", null +// CHECK: [[V4:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: [[V5:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", null +// CHECK: [[V6:%.*]] = and i1 [[V4]], [[V5]] +// CHECK: [[V7:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", null +// CHECK: [[V8:%.*]] = and i1 [[V6]], [[V7]] +// CHECK: [[V9:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", null +// CHECK: [[V10:%.*]] = and i1 [[V8]], [[V9]] +// CHECK: [[V11:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", null +// CHECK: [[V12:%.*]] = and i1 [[V10]], [[V11]] +// CHECK: [[V13:%.*]] = icmp ne ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", null +// CHECK: [[RES:%.*]] = and i1 [[V12]], [[V13]] +// CHECK: ret i1 [[RES]] // --- replacementFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) -// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", ptr null) -// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", ptr null) -// CHECK: ret i1 %3 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", null +// CHECK: [[V4:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: [[V5:%.*]] = icmp ne ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", null +// CHECK: [[V6:%.*]] = and i1 [[V4]], [[V5]] +// CHECK: [[V7:%.*]] = icmp ne ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", null +// CHECK: [[RES:%.*]] = and i1 [[V6]], [[V7]] +// CHECK: ret i1 [[RES]] public func testVars() { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper6globalSivpTwS"() @@ -104,7 +130,8 @@ public func testVars() { // --- global --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper6globalSivpTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper6globalSivg", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper6globalSivg", null +// CHECK: ret i1 [[RES]] public func testClass(_ c: C) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1CCACycfcTwS"() @@ -116,13 +143,17 @@ public func testClass(_ c: C) { // --- C.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CCACycfcTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CCACycfC", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1CCACycfc", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1CCACycfC", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- C.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CC6method4withySi_tFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] public func testStruct(_ s: S) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() @@ -134,14 +165,19 @@ public func testStruct(_ s: S) { // --- S.member --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivpMV", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivg", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivs", ptr null) -// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivM", ptr null) -// CHECK: ret i1 %2 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SV6memberSivpMV", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SV6memberSivg", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SV6memberSivs", null +// CHECK: [[V4:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: [[V5:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SV6memberSivM", null +// CHECK: [[RES:%.*]] = and i1 [[V4]], [[V5]] +// CHECK: ret i1 [[RES]] // --- S.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6method4withySi_tFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper1SV6method4withySi_tF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SV6method4withySi_tF", null +// CHECK: ret i1 [[RES]] public func testEnum(_ e: E) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1EO9basicCaseyA2CmFTwS"() @@ -153,11 +189,13 @@ public func testEnum(_ e: E) { // --- E.basicCase --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1EO9basicCaseyA2CmFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper1EO9basicCaseyA2CmFWC", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper1EO9basicCaseyA2CmFWC", null +// CHECK: ret i1 [[RES]] // --- E.payloadCase(_:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1EO11payloadCaseyAcA1SVcACmFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper1EO11payloadCaseyAcA1SVcACmFWC", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper1EO11payloadCaseyAcA1SVcACmFWC", null +// CHECK: ret i1 [[RES]] public func testOpaqueParameter(_ p: T) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1PP11requirementyyFTwS"() @@ -169,11 +207,13 @@ public func testOpaqueParameter(_ p: T) { // --- P.requirement() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1PP11requirementyyFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper1PP11requirementyyF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper1PP11requirementyyF", null +// CHECK: ret i1 [[RES]] // --- P.requirementWithDefaultImpl() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1PP26requirementWithDefaultImplyyFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper1PP26requirementWithDefaultImplyyF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper1PP26requirementWithDefaultImplyyF", null +// CHECK: ret i1 [[RES]] public func testExistentialParameter(_ p: any P) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1PP11requirementyyFTwS"() @@ -190,6 +230,9 @@ public func testMetatypes() { // --- S.self --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SVTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SVMn", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SVN", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SVMa", ptr null) -// CHECK: ret i1 %1 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SVMn", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SVN", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper1SVMa", null +// CHECK: [[RES:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: ret i1 [[RES]] diff --git a/test/IRGen/has_symbol_async.swift b/test/IRGen/has_symbol_async.swift index cb39dd5cefa3d..42a72cf417ec9 100644 --- a/test/IRGen/has_symbol_async.swift +++ b/test/IRGen/has_symbol_async.swift @@ -17,12 +17,15 @@ public func testGlobalFunctions() { // --- asyncFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9asyncFuncyyYaFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper9asyncFuncyyYaF", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- isolatedFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper12isolatedFuncyyFTwS"() -// CHECK: ret i1 icmp ne (ptr @"$s17has_symbol_helper12isolatedFuncyyF", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"$s17has_symbol_helper12isolatedFuncyyF", null +// CHECK: ret i1 [[RES]] public func testActor(_ a: A) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1ACACycfcTwS"() @@ -36,11 +39,16 @@ public func testActor(_ a: A) { // --- A.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1ACACycfcTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null) -// CHECK: ret i1 %0 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1ACACycfc", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1ACACycfC", null +// CHECK: [[RES:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: ret i1 [[RES]] // --- A.asyncMethod() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1AC11asyncMethodyyYaFTwS"() -// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null) -// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null) -// CHECK: ret i1 %1 +// CHECK: [[V0:%.*]] = icmp ne ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", null +// CHECK: [[V1:%.*]] = icmp ne ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", null +// CHECK: [[V2:%.*]] = and i1 [[V0]], [[V1]] +// CHECK: [[V3:%.*]] = icmp ne ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", null +// CHECK: [[RES:%.*]] = and i1 [[V2]], [[V3]] +// CHECK: ret i1 [[RES]] diff --git a/test/IRGen/has_symbol_clang.swift b/test/IRGen/has_symbol_clang.swift index 1c75f01710641..ea5a91657f228 100644 --- a/test/IRGen/has_symbol_clang.swift +++ b/test/IRGen/has_symbol_clang.swift @@ -12,4 +12,5 @@ public func testClangDecls() { // --- clangFunc(_:) --- // CHECK: define linkonce_odr hidden i1 @"$sSo9clangFuncyys5Int32VFTwS"() #1{{( comdat)?}} { -// CHECK: ret i1 icmp ne (ptr @clangFunc, ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @clangFunc, null +// CHECK: ret i1 [[RES]] diff --git a/test/IRGen/has_symbol_objc.swift b/test/IRGen/has_symbol_objc.swift index 1161522489c06..e4eb05a3d3731 100644 --- a/test/IRGen/has_symbol_objc.swift +++ b/test/IRGen/has_symbol_objc.swift @@ -11,4 +11,5 @@ public func testClassTypes() { } // CHECK: define linkonce_odr hidden i1 @"$sSo9ObjCClassCTwS"() -// CHECK: ret i1 icmp ne (ptr @"OBJC_CLASS_$_ObjCClass", ptr null) +// CHECK: [[RES:%.*]] = icmp ne ptr @"OBJC_CLASS_$_ObjCClass", null +// CHECK: ret i1 [[RES]] diff --git a/test/IRGen/package_bypass_resilience_class.swift b/test/IRGen/package_bypass_resilience_class.swift index 1f74d656ea863..9496cfe063e82 100644 --- a/test/IRGen/package_bypass_resilience_class.swift +++ b/test/IRGen/package_bypass_resilience_class.swift @@ -58,7 +58,7 @@ package class Foo { // CHECK-COMMON-DAG: define linkonce_odr hidden swiftcc void @"$s4Core3FooC02myB0AA3PubCSgvpACTk" // variable initialization expression of Core.Foo.myFoo - // CHECK-OPT-DAG: define {{(dllexport |protected )?}}swiftcc {{i32|i64}} @"$s4Core3FooC02myB0AA3PubCSgvpfi"() #0 { + // CHECK-OPT-DAG: define {{(dllexport |protected )?}}swiftcc{{.*}} {{i32|i64}} @"$s4Core3FooC02myB0AA3PubCSgvpfi"() #0 { // Core.Foo.myFoo.getter // CHECK-RES-DAG: define hidden {{.*}}swiftcc {{i32|i64}} @"$s4Core3FooC02myB0AA3PubCSgvg"(ptr swiftself %0) @@ -107,7 +107,7 @@ package class Foo { final package class Bar { - // CHECK-OPT-DAG: define {{(dllexport |protected )?}}swiftcc {{i32|i64}} @"$s4Core3BarC02myB0AA3PubCSgvpfi"() + // CHECK-OPT-DAG: define {{(dllexport |protected )?}}swiftcc{{.*}} {{i32|i64}} @"$s4Core3BarC02myB0AA3PubCSgvpfi"() // CHECK-COMMON-DAG: define {{(dllexport |protected )?}}swiftcc {{i32|i64}} @"$s4Core3BarC02myB0AA3PubCSgvg"(ptr swiftself %0) // CHECK-COMMON-DAG: define {{(dllexport |protected )?}}swiftcc void @"$s4Core3BarC02myB0AA3PubCSgvs"({{i32|i64}} %0, ptr swiftself %1) // CHECK-COMMON-DAG: define {{(dllexport |protected )?}}swiftcc { ptr, ptr } @"$s4Core3BarC02myB0AA3PubCSgvM" diff --git a/test/IRGen/static_initializer.sil b/test/IRGen/static_initializer.sil index a35813f1b033a..525189df1c95a 100644 --- a/test/IRGen/static_initializer.sil +++ b/test/IRGen/static_initializer.sil @@ -213,7 +213,7 @@ sil @return_static_array : $@convention(thin) () -> TestArray { bb0: // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$s18static_initializer16TestArrayStorageCMa"(i64 0) // CHECK: [[MD:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 - // CHECK: [[O:%[0-9a-z]+]] = call ptr @swift_initStaticObject(ptr [[MD]], ptr getelementptr inbounds (%T18static_initializer16TestArrayStorageC_tailelems0c, ptr @static_array, i32 0, i32 1)) + // CHECK: [[O:%[0-9a-z]+]] = call ptr @swift_initStaticObject(ptr [[MD]], ptr getelementptr{{.*}} (%T18static_initializer16TestArrayStorageC_tailelems0c, ptr @static_array, i32 0, i32 1)) // CHECK: ret ptr [[O]] %0 = global_value @static_array : $TestArrayStorage %1 = struct $TestArray (%0 : $TestArrayStorage) diff --git a/test/IRGen/undef.sil b/test/IRGen/undef.sil index cf0d074d19e86..3224302f890bc 100644 --- a/test/IRGen/undef.sil +++ b/test/IRGen/undef.sil @@ -6,9 +6,9 @@ import Builtin // CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @undefined() {{.*}} { // CHECK: entry: -// CHECK: store i64 undef, ptr poison, align 8 -// CHECK: store i8 undef, ptr poison, align 8 -// CHECK: store ptr undef, ptr poison, align 8 +// CHECK: store i64 undef, ptr undef, align 8 +// CHECK: store i8 undef, ptr undef, align 8 +// CHECK: store ptr undef, ptr undef, align 8 // CHECK: ret void // CHECK: } sil @undefined : $() -> () { diff --git a/test/IRGen/weak_import_native_hoist.swift b/test/IRGen/weak_import_native_hoist.swift index 7ef141b12ebbf..aadb1bcbdbd2c 100644 --- a/test/IRGen/weak_import_native_hoist.swift +++ b/test/IRGen/weak_import_native_hoist.swift @@ -69,7 +69,8 @@ public func test_not_hoist_weakly_linked4() { // CHECK: br i1 [[IS_STRONG]], label %[[BB0:[0-9]+]], label %[[BB1:[0-9]+]] // // CHECK: [[BB1]]: -// CHECK: br i1 icmp eq ({{.*}} ptrtoint (ptr @"$s31weak_import_native_hoist_helper1EO0A0yA2CmFWC" to {{.*}}), {{.*}} 0), label %[[BB2:[0-9]+]], label %[[BB3:[0-9]+]] +// CHECK: [[V0:%.*]] = icmp eq {{.*}} ptrtoint (ptr @"$s31weak_import_native_hoist_helper1EO0A0yA2CmFWC" to {{.*}}), 0 +// CHECK: br i1 [[V0]], label %[[BB2:[0-9]+]], label %[[BB3:[0-9]+]] // // CHECK: [[BB3]]: // CHECK: [[WEAK_CASE:%.*]] = load i32, ptr @"$s31weak_import_native_hoist_helper1EO0A0yA2CmFWC" From 14413d9d90e3df0aea39e684a2f6cd358ab08579 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 23 Jul 2024 18:38:34 +0100 Subject: [PATCH 065/110] [cxx-interop][rebranch] Print `inline` instead of `static inline` for template specializations This fixes a number of test failures in reverse C++ interop. Clang's behavior was changed in https://github.com/llvm/llvm-project/pull/93873, and it no longer accepts the C++ headers that Swift generates. rdar://132283247 --- lib/PrintAsClang/PrintClangValueType.cpp | 10 ++++---- .../PrintSwiftToClangCoreScaffold.cpp | 2 +- .../bridge-cxx-struct-back-to-cxx.swift | 8 +++---- .../SwiftToCxx/class/swift-class-in-cxx.swift | 2 +- .../swift-impl-defs-in-cxx-darwin64bit.swift | 6 ++--- .../core/swift-impl-defs-in-cxx.swift | 24 +++++++++---------- .../generics/generic-enum-in-cxx.swift | 4 ++-- .../generics/generic-struct-in-cxx.swift | 6 ++--- .../generics/generic-type-traits-fwd.swift | 4 ++-- .../structs/resilient-struct-in-cxx.swift | 6 ++--- .../structs/swift-struct-in-cxx.swift | 4 ++-- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/PrintAsClang/PrintClangValueType.cpp b/lib/PrintAsClang/PrintClangValueType.cpp index 35ae2ede67ed1..93c2af4990536 100644 --- a/lib/PrintAsClang/PrintClangValueType.cpp +++ b/lib/PrintAsClang/PrintClangValueType.cpp @@ -586,7 +586,7 @@ void ClangValueTypePrinter::printTypePrecedingGenericTraits( if (printer.printNominalTypeOutsideMemberDeclTemplateSpecifiers(typeDecl)) os << "template<>\n"; - os << "static inline const constexpr bool isUsableInGenericContext<"; + os << "inline const constexpr bool isUsableInGenericContext<"; printer.printNominalTypeReference(typeDecl, /*moduleContext=*/nullptr); os << "> = "; @@ -635,7 +635,7 @@ void ClangValueTypePrinter::printTypeGenericTraits( if (typeDecl->hasClangNode()) { // FIXME: share the code. os << "template<>\n"; - os << "static inline const constexpr bool isUsableInGenericContext<"; + os << "inline const constexpr bool isUsableInGenericContext<"; printer.printClangTypeReference(typeDecl->getClangDecl()); os << "> = true;\n"; } @@ -670,7 +670,7 @@ void ClangValueTypePrinter::printTypeGenericTraits( if (typeDecl->hasClangNode()) { os << "template<>\n"; - os << "static inline const constexpr bool isSwiftBridgedCxxRecord<"; + os << "inline const constexpr bool isSwiftBridgedCxxRecord<"; printer.printClangTypeReference(typeDecl->getClangDecl()); os << "> = true;\n"; } @@ -679,7 +679,7 @@ void ClangValueTypePrinter::printTypeGenericTraits( assert(NTD && "not a nominal type?"); if (printer.printNominalTypeOutsideMemberDeclTemplateSpecifiers(NTD)) os << "template<>\n"; - os << "static inline const constexpr bool isValueType<"; + os << "inline const constexpr bool isValueType<"; printer.printBaseName(typeDecl->getModuleContext()); os << "::"; printer.printNominalTypeReference(NTD, moduleContext); @@ -690,7 +690,7 @@ void ClangValueTypePrinter::printTypeGenericTraits( assert(!isa(typeDecl) && !typeDecl->hasClangNode()); if (printer.printNominalTypeOutsideMemberDeclTemplateSpecifiers(NTD)) os << "template<>\n"; - os << "static inline const constexpr bool isOpaqueLayout<"; + os << "inline const constexpr bool isOpaqueLayout<"; printer.printNominalTypeReference(NTD, /*moduleContext=*/nullptr); os << "> = true;\n"; diff --git a/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp b/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp index bff4da1eadeda..2781a528f9a6a 100644 --- a/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp +++ b/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp @@ -202,7 +202,7 @@ void printPrimitiveGenericTypeTraits(raw_ostream &os, ASTContext &astContext, } os << "template<>\n"; - os << "static inline const constexpr bool isUsableInGenericContext<" + os << "inline const constexpr bool isUsableInGenericContext<" << typeInfo.name << "> = true;\n\n"; os << "template<>\nstruct TypeMetadataTrait<" << typeInfo.name << "> {\n" diff --git a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift index 6f1106a64d7e6..4d100fd7f1127 100644 --- a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift +++ b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift @@ -217,7 +217,7 @@ public struct Strct { // CHECK-NEXT: #pragma clang diagnostic push // CHECK-NEXT: #pragma clang diagnostic ignored "-Wc++17-extensions" // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { // CHECK-NEXT: static SWIFT_INLINE_PRIVATE_HELPER void * _Nonnull getTypeMetadata() { @@ -226,7 +226,7 @@ public struct Strct { // CHECK-NEXT: }; // CHECK-NEXT: namespace _impl{ // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isSwiftBridgedCxxRecord = true; +// CHECK-NEXT: inline const constexpr bool isSwiftBridgedCxxRecord = true; // CHECK-NEXT: } // namespace // CHECK-NEXT: #pragma clang diagnostic pop // CHECK-NEXT: } // namespace swift @@ -256,7 +256,7 @@ public struct Strct { // CHECK-NEXT: #pragma clang diagnostic push // CHECK-NEXT: #pragma clang diagnostic ignored "-Wc++17-extensions" // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { // CHECK-NEXT: static SWIFT_INLINE_PRIVATE_HELPER void * _Nonnull getTypeMetadata() { @@ -265,7 +265,7 @@ public struct Strct { // CHECK-NEXT: }; // CHECK-NEXT: namespace _impl{ // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isSwiftBridgedCxxRecord = true; +// CHECK-NEXT: inline const constexpr bool isSwiftBridgedCxxRecord = true; // CHECK-NEXT: } // namespace // CHECK-NEXT: #pragma clang diagnostic pop // CHECK-NEXT: } // namespace swift diff --git a/test/Interop/SwiftToCxx/class/swift-class-in-cxx.swift b/test/Interop/SwiftToCxx/class/swift-class-in-cxx.swift index 2a774b7fc6c11..8c3da43fd2a51 100644 --- a/test/Interop/SwiftToCxx/class/swift-class-in-cxx.swift +++ b/test/Interop/SwiftToCxx/class/swift-class-in-cxx.swift @@ -38,7 +38,7 @@ public final class ClassWithIntField { // CHECK-NEXT: #pragma clang diagnostic push // CHECK-NEXT: #pragma clang diagnostic ignored "-Wc++17-extensions" // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-NEXT: #pragma clang diagnostic pop // CHECK-NEXT: } // namespace swift diff --git a/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx-darwin64bit.swift b/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx-darwin64bit.swift index 749edab999137..2c9d5ca1cb5ac 100644 --- a/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx-darwin64bit.swift +++ b/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx-darwin64bit.swift @@ -40,7 +40,7 @@ // CHECK-NEXT: } // CHECK-NEXT: #endif -// CHECK: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -50,7 +50,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -60,7 +60,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { diff --git a/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift b/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift index d98a9b28d6022..ccb816392298e 100644 --- a/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift +++ b/test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift @@ -104,7 +104,7 @@ // CHECK-NEXT: #pragma clang diagnostic push // CHECK-NEXT: #pragma clang diagnostic ignored "-Wc++17-extensions" // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -114,7 +114,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -124,7 +124,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -134,7 +134,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -144,7 +144,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -154,7 +154,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -164,7 +164,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -174,7 +174,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -184,7 +184,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -194,7 +194,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -204,7 +204,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { @@ -214,7 +214,7 @@ // CHECK-NEXT: }; // CHECK-EMPTY: // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-EMPTY: // CHECK-NEXT: template<> // CHECK-NEXT: struct TypeMetadataTrait { diff --git a/test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift b/test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift index 7d057144d275b..de656a4257a17 100644 --- a/test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift +++ b/test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift @@ -102,7 +102,7 @@ public func inoutConcreteOpt(_ x: inout GenericOpt) { // CHECK-NEXT: #endif // CHECK-NEXT: class SWIFT_SYMBOL("s:8Generics17GenericCustomTypeO") GenericCustomType; -// CHECK: static inline const constexpr bool isOpaqueLayout> = true; +// CHECK: inline const constexpr bool isOpaqueLayout> = true; // CHECK: template @@ -116,7 +116,7 @@ public func inoutConcreteOpt(_ x: inout GenericOpt) { // CHECK-NEXT: #ifdef __cpp_concepts // CHECK-NEXT: requires swift::isUsableInGenericContext // CHECK-NEXT: #endif -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext> = isUsableInGenericContext; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext> = isUsableInGenericContext; // CHECK: template // CHECK-NEXT: #ifdef __cpp_concepts diff --git a/test/Interop/SwiftToCxx/generics/generic-struct-in-cxx.swift b/test/Interop/SwiftToCxx/generics/generic-struct-in-cxx.swift index c324d615e54db..6864d15c59ba9 100644 --- a/test/Interop/SwiftToCxx/generics/generic-struct-in-cxx.swift +++ b/test/Interop/SwiftToCxx/generics/generic-struct-in-cxx.swift @@ -210,7 +210,7 @@ public func inoutConcretePair(_ x: UInt16, _ y: inout GenericPair && swift::isUsableInGenericContext // CHECK-NEXT: #endif // __cpp_concepts -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext> = isUsableInGenericContext && isUsableInGenericContext; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext> = isUsableInGenericContext && isUsableInGenericContext; // CHECK: template // CHECK-NEXT: #ifdef __cpp_concepts @@ -284,12 +284,12 @@ public func inoutConcretePair(_ x: UInt16, _ y: inout GenericPair && swift::isUsableInGenericContext // CHECK-NEXT: #endif // __cpp_concepts -// CHECK-NEXT: static inline const constexpr bool isValueType> = true; +// CHECK-NEXT: inline const constexpr bool isValueType> = true; // CHECK-NEXT: template // CHECK-NEXT: #ifdef __cpp_concepts // CHECK-NEXT: requires swift::isUsableInGenericContext && swift::isUsableInGenericContext // CHECK-NEXT: #endif // __cpp_concepts -// CHECK-NEXT: static inline const constexpr bool isOpaqueLayout> = true; +// CHECK-NEXT: inline const constexpr bool isOpaqueLayout> = true; // CHECK-NEXT: template // CHECK-NEXT: #ifdef __cpp_concepts // CHECK-NEXT: requires swift::isUsableInGenericContext && swift::isUsableInGenericContext diff --git a/test/Interop/SwiftToCxx/generics/generic-type-traits-fwd.swift b/test/Interop/SwiftToCxx/generics/generic-type-traits-fwd.swift index 664d9f9cbc516..ceef8e709d4e4 100644 --- a/test/Interop/SwiftToCxx/generics/generic-type-traits-fwd.swift +++ b/test/Interop/SwiftToCxx/generics/generic-type-traits-fwd.swift @@ -31,10 +31,10 @@ public struct LaterGeneric { // CHECK: class SWIFT_SYMBOL("s:8Generics12LaterGenericV") LaterGeneric; // CHECK: class SWIFT_SYMBOL("s:8Generics16ComesFirstStructV") ComesFirstStruct; -// CHECK: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK: inline const constexpr bool isUsableInGenericContext = true; // CHECK: class SWIFT_SYMBOL("s:8Generics14ComesFirstEnumO") ComesFirstEnum; -// CHECK: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK: inline const constexpr bool isUsableInGenericContext = true; // CHECK: class SWIFT_SYMBOL("s:8Generics14ComesFirstEnumO") ComesFirstEnum final { // CHECK: LaterGeneric returnsLaterOpt() const SWIFT_SYMBOL("s:8Generics14ComesFirstEnumO15returnsLaterOptAA0F7GenericVyACGyF"); diff --git a/test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift b/test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift index 02e9f0c17e2f1..2233524dbfab6 100644 --- a/test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift +++ b/test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift @@ -30,7 +30,7 @@ public struct FirstSmallStruct { // CHECK: class SWIFT_SYMBOL("s:7Structs16FirstSmallStructV") FirstSmallStruct; // CHECK: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK: class SWIFT_SYMBOL("s:7Structs16FirstSmallStructV") FirstSmallStruct final { // CHECK-NEXT: public: @@ -91,9 +91,9 @@ public struct FirstSmallStruct { // CHECK-NEXT: }; // CHECK-NEXT: namespace _impl{ // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isValueType = true; +// CHECK-NEXT: inline const constexpr bool isValueType = true; // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isOpaqueLayout = true; +// CHECK-NEXT: inline const constexpr bool isOpaqueLayout = true; // CHECK-NEXT: template<> // CHECK-NEXT: struct implClassFor { using type = Structs::_impl::_impl_FirstSmallStruct; }; // CHECK-NEXT: } // namespace diff --git a/test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift b/test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift index 1081a75c970ef..9e0e95ede0e6b 100644 --- a/test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift +++ b/test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift @@ -16,7 +16,7 @@ // CHECK-NEXT: #pragma clang diagnostic push // CHECK-NEXT: #pragma clang diagnostic ignored "-Wc++17-extensions" // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = true; +// CHECK-NEXT: inline const constexpr bool isUsableInGenericContext = true; // CHECK-NEXT: #pragma clang diagnostic pop // CHECK-NEXT: } // namespace swift @@ -112,7 +112,7 @@ // CHECK-NEXT: }; // CHECK-NEXT: namespace _impl{ // CHECK-NEXT: template<> -// CHECK-NEXT: static inline const constexpr bool isValueType = true; +// CHECK-NEXT: inline const constexpr bool isValueType = true; // CHECK-NEXT: template<> // CHECK-NEXT: struct implClassFor { using type = Structs::_impl::_impl_StructWithIntField; }; // CHECK-NEXT: } // namespace From d2184688aae95c86d2873efe3cefc4a51f64a8a4 Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Wed, 24 Jul 2024 13:07:13 -0700 Subject: [PATCH 066/110] Fix ClangImporter/const_and_pure.swift In the rebranch compiler, `void` functions cannot be const or pure. Fixes rdar://127262449. --- test/ClangImporter/Inputs/const_and_pure.h | 6 +++--- test/ClangImporter/const_and_pure.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/ClangImporter/Inputs/const_and_pure.h b/test/ClangImporter/Inputs/const_and_pure.h index 6b6426e84e7e0..1d42477d0ac7b 100644 --- a/test/ClangImporter/Inputs/const_and_pure.h +++ b/test/ClangImporter/Inputs/const_and_pure.h @@ -1,7 +1,7 @@ -__attribute__((const)) void const_function(); +__attribute__((const)) int const_function(); -__attribute__((pure)) void pure_function(); +__attribute__((pure)) int pure_function(); -void normal_function(); +int normal_function(); diff --git a/test/ClangImporter/const_and_pure.swift b/test/ClangImporter/const_and_pure.swift index cc9abdfae5a25..a6fbe1d6c0834 100644 --- a/test/ClangImporter/const_and_pure.swift +++ b/test/ClangImporter/const_and_pure.swift @@ -1,15 +1,15 @@ // RUN: %target-swift-frontend -emit-sil %s -enable-objc-interop -import-objc-header %S/Inputs/const_and_pure.h | %FileCheck %s func testit() { - const_function() + _ = const_function() - pure_function() + _ = pure_function() - normal_function() + _ = normal_function() } -// CHECK: sil [readnone] [clang const_function] @const_function : $@convention(c) () -> () -// CHECK: sil [readonly] [clang pure_function] @pure_function : $@convention(c) () -> () -// CHECK: sil [clang normal_function] @normal_function : $@convention(c) () -> () +// CHECK: sil [readnone] [clang const_function] @const_function : $@convention(c) () -> Int32 +// CHECK: sil [readonly] [clang pure_function] @pure_function : $@convention(c) () -> Int32 +// CHECK: sil [clang normal_function] @normal_function : $@convention(c) () -> Int32 From 893a30ebbb6ef3cdf4316092bdd290e62c5b4f92 Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Wed, 24 Jul 2024 13:40:39 -0700 Subject: [PATCH 067/110] Update availability attribute printing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new clang implements “P2361 Unevaluated string literals”, which means it rejects numeric escapes in string literals in attributes (most notably for Swift, availability attributes). Update PrintAsClang to follow these new rules when it prints availability attributes. In the case of control characters which cannot be otherwise represented, this means Swift will print a hex code for the user to read. Fixes rdar://127263671. --- lib/PrintAsClang/DeclAndTypePrinter.cpp | 36 ++++++++++++++++++++----- test/PrintAsObjC/availability.swift | 4 +-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/PrintAsClang/DeclAndTypePrinter.cpp b/lib/PrintAsClang/DeclAndTypePrinter.cpp index 20fd971e99ff0..e5d3809969747 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -274,8 +274,11 @@ class DeclAndTypePrinter::Implementation /// Prints an encoded string, escaped properly for C. void printEncodedString(raw_ostream &os, StringRef str, bool includeQuotes = true) { - // NB: We don't use raw_ostream::write_escaped() because it does hex escapes - // for non-ASCII chars. + // Per "P2361 Unevaluated string literals", we should generally print + // either raw Unicode characters or letter-based escape sequences for + // string literals in e.g. availability attributes. In particular, we + // must not use hex escapes. When we don't have an escape for a particular + // control character, we'll print its hex value in "{U+NNNN}" format. llvm::SmallString<128> Buf; StringRef decodedStr = Lexer::getEncodedStringSegment(str, Buf); @@ -283,23 +286,42 @@ class DeclAndTypePrinter::Implementation if (includeQuotes) os << '"'; for (unsigned char c : decodedStr) { switch (c) { + // Note: We aren't bothering to escape single quote or question mark + // even though we could. + case '"': + os << '\\' << '"'; + break; case '\\': os << '\\' << '\\'; break; - case '\t': - os << '\\' << 't'; + case '\a': + os << '\\' << 'a'; + break; + case '\b': + os << '\\' << 'b'; + break; + case '\f': + os << '\\' << 'f'; break; case '\n': os << '\\' << 'n'; break; - case '"': - os << '\\' << '"'; + case '\r': + os << '\\' << 'r'; break; + case '\t': + os << '\\' << 't'; + break; + case '\v': + os << '\\' << 'v'; + break; + default: if (c < 0x20 || c == 0x7F) { - os << '\\' << 'x'; + os << "{U+00"; os << llvm::hexdigit((c >> 4) & 0xF); os << llvm::hexdigit((c >> 0) & 0xF); + os << "}"; } else { os << c; } diff --git a/test/PrintAsObjC/availability.swift b/test/PrintAsObjC/availability.swift index 9545f8fbf5d72..0c2a8e507eb7e 100644 --- a/test/PrintAsObjC/availability.swift +++ b/test/PrintAsObjC/availability.swift @@ -16,7 +16,7 @@ // CHECK-NEXT: - (void)alwaysDeprecatedTwo SWIFT_DEPRECATED_MSG("it's old"); // CHECK-NEXT: - (void)alwaysDeprecatedThree SWIFT_DEPRECATED_MSG("", "qux"); // CHECK-NEXT: - (void)alwaysDeprecatedFour SWIFT_DEPRECATED_MSG("use something else", "quux"); -// CHECK-NEXT: - (void)escapeMessage SWIFT_DEPRECATED_MSG("one\ntwo\tthree\x0Dfour\\ \"five\""); +// CHECK-NEXT: - (void)escapeMessage SWIFT_DEPRECATED_MSG("one\ntwo\tthree\rfour\\ \"five\"{U+0000}six"); // CHECK-NEXT: - (void)unicodeMessage SWIFT_DEPRECATED_MSG("über"); // CHECK-NEXT: - (void)singlePlatShorthand SWIFT_AVAILABILITY(macos,introduced=10.10); // CHECK-NEXT: - (void)multiPlatShorthand @@ -275,7 +275,7 @@ @available(*, deprecated, message: "use something else", renamed: "quux") @objc func alwaysDeprecatedFour() {} - @available(*, deprecated, message: "one\ntwo\tthree\rfour\\ \"five\"") + @available(*, deprecated, message: "one\ntwo\tthree\rfour\\ \"five\"\0six") @objc func escapeMessage() {} @available(*, deprecated, message: "über") @objc func unicodeMessage() {} From 6902b7e8fff458d668ede9e35cb816bcb1e23795 Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Wed, 24 Jul 2024 17:36:13 -0700 Subject: [PATCH 068/110] Fix ClangImporter/CoreGraphics_test.swift In rebranch, the IR for the function includes a new `range` attribute. Loosen the FileCheck pattern to accommodate it. Fixes rdar://127262497. --- test/ClangImporter/CoreGraphics_test.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ClangImporter/CoreGraphics_test.swift b/test/ClangImporter/CoreGraphics_test.swift index 7923f89978783..7ee411b724c62 100644 --- a/test/ClangImporter/CoreGraphics_test.swift +++ b/test/ClangImporter/CoreGraphics_test.swift @@ -11,7 +11,7 @@ func blackHole(_ value: T) -> Void // CHECK: [[SWITCHTABLE:@.*]] = private unnamed_addr constant [8 x i64] [i64 0, i64 12, i64 23, i64 34, i64 45, i64 55, i64 67, i64 71] -// CHECK-LABEL: define swiftcc i64 {{.*}}testEnums{{.*}} { +// CHECK-LABEL: define swiftcc{{.*}} i64 {{.*}}testEnums{{.*}} { public func testEnums(_ model: CGColorSpaceModel) -> Int { switch model { case .unknown : return 0 From 37ced22047c6c36bde166cc6bfe85ce679e9455a Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Tue, 23 Jul 2024 13:42:00 -0700 Subject: [PATCH 069/110] [immediate] Leak SwiftJIT to avoid unmapping metadata memory It's not safe to unmap memory that has been registered with the swift/objc runtimes. For now, avoid this by leaking the JIT object. In the future we should be able to detach the JIT from the allocated memory, or be more fine-grained about which memory needs to be preserved and which can be freed. rdar://128432487 --- lib/Immediate/Immediate.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Immediate/Immediate.cpp b/lib/Immediate/Immediate.cpp index f83b1b05df7d1..9ddf9511fe332 100644 --- a/lib/Immediate/Immediate.cpp +++ b/lib/Immediate/Immediate.cpp @@ -333,6 +333,11 @@ int swift::RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine, auto Result = (*JIT)->runMain(CmdLine); + // It is not safe to unmap memory that has been registered with the swift or + // objc runtime. Currently the best way to avoid that is to leak the JIT. + // FIXME: Replace with "detach" llvm/llvm-project#56714. + (void)JIT->release(); + if (!Result) { logError(Result.takeError()); return -1; From 5b4cd166471e3af8df3ca98e71ec7d6e89edc9da Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 29 Jul 2024 13:50:16 -0700 Subject: [PATCH 070/110] [rebranch] Add missing `llvm/IR/Module.h` include `llvm/IR/Module.h` was presumably being transitively included previously. --- lib/IRGen/GenConcurrency.cpp | 1 + lib/LLVMPasses/LLVMInlineTree.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/IRGen/GenConcurrency.cpp b/lib/IRGen/GenConcurrency.cpp index 56e122a4c7b19..87e2b0211ab4f 100644 --- a/lib/IRGen/GenConcurrency.cpp +++ b/lib/IRGen/GenConcurrency.cpp @@ -31,6 +31,7 @@ #include "swift/AST/ProtocolConformanceRef.h" #include "swift/ABI/MetadataValues.h" #include "swift/Basic/Assertions.h" +#include "llvm/IR/Module.h" using namespace swift; using namespace irgen; diff --git a/lib/LLVMPasses/LLVMInlineTree.cpp b/lib/LLVMPasses/LLVMInlineTree.cpp index 8276647652dfc..9336418626a0d 100644 --- a/lib/LLVMPasses/LLVMInlineTree.cpp +++ b/lib/LLVMPasses/LLVMInlineTree.cpp @@ -27,6 +27,7 @@ #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/CommandLine.h" From 5b2d9e96b35893605453e5c7a8e31a7ce0a21d72 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 29 Jul 2024 14:23:44 -0700 Subject: [PATCH 071/110] [AST] Rename `getOriginalNamespace` to `getFirstDecl` `getOriginalNamespace` was removed in LLVM upstream in e6ec7c8f74d1be778f4ddf794d0e2fb63b0dc3be. Use `getFirstDecl` instead. --- lib/AST/ASTPrinter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 133c15b2bf7ff..4f44f92b2cf27 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3430,7 +3430,7 @@ void PrintAST::visitEnumDecl(EnumDecl *decl) { dyn_cast_or_null(decl->getClangDecl())) { // Enum that correponds to the C++ namespace should only be printed once. if (!Printer.shouldPrintRedeclaredClangDecl( - namespaceDecl->getOriginalNamespace())) + namespaceDecl->getFirstDecl())) return; if (Options.SkipInlineCXXNamespace && namespaceDecl->isInline()) { From 64579adf2473ea7e42b373f7387d31ce900b6b09 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 29 Jul 2024 15:21:53 -0700 Subject: [PATCH 072/110] [SILOpt] Rename `GetUndefVal` to `GetPoisonVal` This function was renamed in upstream LLVM. --- lib/SILOptimizer/Utils/SILSSAUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SILOptimizer/Utils/SILSSAUpdater.cpp b/lib/SILOptimizer/Utils/SILSSAUpdater.cpp index caf63b1eea29f..70aa67223ce92 100644 --- a/lib/SILOptimizer/Utils/SILSSAUpdater.cpp +++ b/lib/SILOptimizer/Utils/SILSSAUpdater.cpp @@ -326,7 +326,7 @@ class SSAUpdaterTraits { llvm::copy(block->getPredecessorBlocks(), std::back_inserter(*predBlocks)); } - static SILValue GetUndefVal(SILBasicBlock *block, SILSSAUpdater *ssaUpdater) { + static SILValue GetPoisonVal(SILBasicBlock *block, SILSSAUpdater *ssaUpdater) { return SILUndef::get(block->getParent(), ssaUpdater->type); } From 5c4851592e4fae01bb1c46f9df824873a30460fc Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 29 Jul 2024 15:23:33 -0700 Subject: [PATCH 073/110] [Cleanup] Remove more `StringRef::equals` `StringRef::equals` has been removed upstream. --- lib/Parse/ParseVersion.cpp | 2 +- lib/Sema/TypeCheckAttr.cpp | 6 +++--- lib/Sema/TypeCheckConcurrency.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Parse/ParseVersion.cpp b/lib/Parse/ParseVersion.cpp index e9b4c7443040f..a89910a59e472 100644 --- a/lib/Parse/ParseVersion.cpp +++ b/lib/Parse/ParseVersion.cpp @@ -94,7 +94,7 @@ std::optional VersionParser::parseCompilerVersionString( // The second version component isn't used for comparison. if (i == 1) { - if (!SplitComponent.equals("*")) { + if (SplitComponent != "*") { if (Diags) { // Majors 600-1300 were used for Swift 1.0-5.5 (based on clang // versions), but then we reset the numbering based on Swift versions, diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 34673e8cedbd1..b8ce2bd659562 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -2442,7 +2442,7 @@ static bool allowSymbolLinkageMarkers(ASTContext &ctx, Decl *D) { if (macroDecl->getParentModule()->isStdlibModule() && macroDecl->getName().getBaseIdentifier() - .str().equals("_DebugDescriptionProperty")) + .str() == "_DebugDescriptionProperty") return true; return false; @@ -7366,11 +7366,11 @@ void AttributeChecker::visitUnsafeInheritExecutorAttr( if (!fn->isAsyncContext()) { diagnose(attr->getLocation(), diag::inherits_executor_without_async); } else if (fn->getBaseName().isSpecial() || - !fn->getParentModule()->getName().str().equals("_Concurrency") || + fn->getParentModule()->getName().str() != "_Concurrency" || !fn->getBaseIdentifier().str() .starts_with("_unsafeInheritExecutor_")) { bool inConcurrencyModule = D->getDeclContext()->getParentModule()->getName() - .str().equals("_Concurrency"); + .str() == "_Concurrency"; auto diag = fn->diagnose(diag::unsafe_inherits_executor_deprecated); diag.warnUntilSwiftVersion(6); diag.limitBehaviorIf(inConcurrencyModule, DiagnosticBehavior::Warning); diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 8a63d6adf27ea..78d2e58a64e24 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -2096,7 +2096,7 @@ void swift::replaceUnsafeInheritExecutorWithDefaultedIsolationParam( /// Whether this declaration context is in the _Concurrency module. static bool inConcurrencyModule(const DeclContext *dc) { - return dc->getParentModule()->getName().str().equals("_Concurrency"); + return dc->getParentModule()->getName().str() == "_Concurrency"; } void swift::introduceUnsafeInheritExecutorReplacements( From 0a6e5874e2f08d1351e0507dec4d2c1f98abe9ee Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Fri, 26 Jul 2024 14:25:30 -0700 Subject: [PATCH 074/110] Accommodate 64-bit clang serialization IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several serialization IDs that used to be 32 bits are being widened to 64. Modify SwiftLookupTable and its supporting types to accommodate this. The new design uses a 64-bit integer for the pointer, decl, macro, or identifier ID, plus a 32-bit integer for the submodule ID (this field is set to all ones to indicate a decl vs. a macro). An additional in-memory bool distinguishes pointer nodes from ID nodes. Advantages: • The main ID is now 64 bits wide, accommodating recent changes in clang. • We’re no longer stealing bits from clang (we *do* steal the max value of the submodule ID, though). • There’s no on-disk bit that, when set, will cause an ID to be interpreted as a pointer. • Design is robust against `clang::serialization::SubmoduleID` also becoming 64-bit (although this will waste space). Fixes rdar://131134424. --- lib/ClangImporter/SwiftLookupTable.cpp | 218 ++++++++++++------------- lib/ClangImporter/SwiftLookupTable.h | 204 ++++++++++++++++------- 2 files changed, 251 insertions(+), 171 deletions(-) diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index c7b564d8a6111..8f0ca1a128432 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -59,6 +59,8 @@ template } namespace { + using StoredSingleEntry = SwiftLookupTable::StoredSingleEntry; + class BaseNameToEntitiesTableReaderInfo; class GlobalsAsMembersTableReaderInfo; @@ -167,8 +169,9 @@ class SwiftLookupTableReader : public clang::ModuleFileExtensionReader { /// imported as members into the given context. /// /// \returns true if we found anything, false otherwise. - bool lookupGlobalsAsMembersInContext(SwiftLookupTable::StoredContext context, - SmallVectorImpl &entries); + bool lookupGlobalsAsMembersInContext( + SwiftLookupTable::StoredContext context, + SmallVectorImpl &entries); /// Retrieve the set of global declarations that are going to be imported as members under the given /// Swift base name. @@ -444,8 +447,9 @@ static bool isGlobalAsMember(SwiftLookupTable::SingleEntry entry, return decl->getDeclContext()->getRedeclContext()->isFileContext(); } -bool SwiftLookupTable::addLocalEntry(SingleEntry newEntry, - SmallVectorImpl &entries) { +bool SwiftLookupTable::addLocalEntry( + SingleEntry newEntry, + SmallVectorImpl &entries) { // Check whether this entry matches any existing entry. auto decl = newEntry.dyn_cast(); auto macro = newEntry.dyn_cast(); @@ -453,13 +457,13 @@ bool SwiftLookupTable::addLocalEntry(SingleEntry newEntry, for (auto &existingEntry : entries) { // If it matches an existing declaration, there's nothing to do. - if (decl && isDeclEntry(existingEntry) && + if (decl && existingEntry.isDeclEntry() && matchesExistingDecl(decl, mapStoredDecl(existingEntry))) return false; // If a textual macro matches an existing macro, just drop the new // definition. - if (macro && isMacroEntry(existingEntry)) { + if (macro && existingEntry.isMacroEntry()) { return false; } @@ -474,7 +478,7 @@ bool SwiftLookupTable::addLocalEntry(SingleEntry newEntry, // Note that the above assumes that macro definitions are processed in // reverse order, i.e. the first definition seen is the last in a // translation unit. - if (moduleMacro && isMacroEntry(existingEntry)) { + if (moduleMacro && existingEntry.isMacroEntry()) { SingleEntry decodedEntry = mapStoredMacro(existingEntry, /*assumeModule*/true); const auto *existingMacro = decodedEntry.get(); @@ -491,7 +495,7 @@ bool SwiftLookupTable::addLocalEntry(SingleEntry newEntry, // FIXME: What if there are /multiple/ old definitions we should be // dropping? What if one of the earlier early exits makes us miss // entries later in the list that would match this? - existingEntry = encodeEntry(moduleMacro); + existingEntry = StoredSingleEntry(moduleMacro); return false; } @@ -501,11 +505,11 @@ bool SwiftLookupTable::addLocalEntry(SingleEntry newEntry, // Add an entry to this context. if (decl) - entries.push_back(encodeEntry(decl)); + entries.push_back(StoredSingleEntry(decl)); else if (macro) - entries.push_back(encodeEntry(macro)); + entries.push_back(StoredSingleEntry(macro)); else - entries.push_back(encodeEntry(moduleMacro)); + entries.push_back(StoredSingleEntry(moduleMacro)); return true; } @@ -545,11 +549,11 @@ void SwiftLookupTable::addEntry(DeclName name, SingleEntry newEntry, FullTableEntry entry; entry.Context = context; if (decl) - entry.DeclsOrMacros.push_back(encodeEntry(decl)); + entry.DeclsOrMacros.push_back(StoredSingleEntry(decl)); else if (macro) - entry.DeclsOrMacros.push_back(encodeEntry(macro)); + entry.DeclsOrMacros.push_back(StoredSingleEntry(macro)); else - entry.DeclsOrMacros.push_back(encodeEntry(moduleMacro)); + entry.DeclsOrMacros.push_back(StoredSingleEntry(moduleMacro)); entries.push_back(entry); }; @@ -674,7 +678,7 @@ SwiftLookupTable::allGlobalsAsMembersInContext(StoredContext context) { if (!Reader) return result; // Lookup this base name in the module extension file. - SmallVector results; + SmallVector results; (void)Reader->lookupGlobalsAsMembersInContext(context, results); // Add an entry to the table so we don't look again. @@ -791,7 +795,7 @@ SwiftLookupTable::lookupObjCMembers(SerializedSwiftName baseName) { // Map each of the declarations. for (auto &stored : entry.DeclsOrMacros) { - assert(isDeclEntry(stored) && "Not a declaration?"); + assert(stored.isDeclEntry() && "Not a declaration?"); result.push_back(mapStoredDecl(stored)); } } @@ -820,7 +824,7 @@ SwiftLookupTable::lookupMemberOperators(SerializedSwiftName baseName) { // Map each of the declarations. for (auto &stored : entry.DeclsOrMacros) { - assert(isDeclEntry(stored) && "Not a declaration?"); + assert(stored.isDeclEntry() && "Not a declaration?"); result.push_back(mapStoredDecl(stored)); } } @@ -930,42 +934,24 @@ static void printStoredContext(SwiftLookupTable::StoredContext context, } } -static uint64_t getEncodedDeclID(uint64_t entry) { - assert(SwiftLookupTable::isSerializationIDEntry(entry)); - assert(SwiftLookupTable::isDeclEntry(entry)); - return entry >> 2; -} - -namespace { -struct LocalMacroIDs { - uint32_t moduleID; - uint32_t nameOrMacroID; -}; -} - -static LocalMacroIDs getEncodedModuleMacroIDs(uint64_t entry) { - assert(SwiftLookupTable::isSerializationIDEntry(entry)); - assert(SwiftLookupTable::isMacroEntry(entry)); - return {static_cast((entry & 0xFFFFFFFF) >> 2), - static_cast(entry >> 32)}; -} - /// Print a stored entry (Clang macro or declaration) for debugging purposes. -static void printStoredEntry(const SwiftLookupTable *table, uint64_t entry, +static void printStoredEntry(const SwiftLookupTable *table, + StoredSingleEntry &entry, llvm::raw_ostream &out) { - if (SwiftLookupTable::isSerializationIDEntry(entry)) { - if (SwiftLookupTable::isDeclEntry(entry)) { - llvm::errs() << "decl ID #" << getEncodedDeclID(entry); + if (entry.isSerializationIDEntry()) { + if (entry.isDeclEntry()) { + llvm::errs() << "decl ID #" << entry.getSerializationID(); } else { - LocalMacroIDs macroIDs = getEncodedModuleMacroIDs(entry); - if (macroIDs.moduleID == 0) { - llvm::errs() << "macro ID #" << macroIDs.nameOrMacroID; + auto moduleID = entry.getModuleID(); + if (moduleID == 0) { + llvm::errs() << "macro ID #" << entry.getSerializationID(); } else { - llvm::errs() << "macro with name ID #" << macroIDs.nameOrMacroID - << "in submodule #" << macroIDs.moduleID; + llvm::errs() << "macro with name ID #" + << entry.getSerializationID() << "in submodule #" + << moduleID; } } - } else if (SwiftLookupTable::isMacroEntry(entry)) { + } else if (entry.isMacroEntry()) { llvm::errs() << "Macro"; } else { auto decl = const_cast(table)->mapStoredDecl(entry); @@ -1008,7 +994,9 @@ void SwiftLookupTable::dump(raw_ostream &os) const { llvm::interleave( entry.DeclsOrMacros.begin(), entry.DeclsOrMacros.end(), - [this, &os](uint64_t entry) { printStoredEntry(this, entry, os); }, + [this, &os](StoredSingleEntry entry) { + printStoredEntry(this, entry, os); + }, [&os] { os << ", "; }); os << "\n"; } @@ -1050,7 +1038,9 @@ void SwiftLookupTable::dump(raw_ostream &os) const { const auto &entries = GlobalsAsMembersIndex.find(context)->second; llvm::interleave( entries.begin(), entries.end(), - [this, &os](uint64_t entry) { printStoredEntry(this, entry, os); }, + [this, &os](StoredSingleEntry entry) { + printStoredEntry(this, entry, os); + }, [&os] { os << ", "; }); os << "\n"; } @@ -1098,6 +1088,36 @@ namespace { using GlobalsAsMembersIndexRecordLayout = BCRecordLayout, BCBlob>; + constexpr size_t SizeOfEmittedStoredSingleEntry + = sizeof(StoredSingleEntry::SerializationID) + + sizeof(StoredSingleEntry::SubmoduleID); + + static void emitStoredSingleEntry(SwiftLookupTable::SingleEntry &mappedEntry, + clang::ASTWriter &astWriter, + endian::Writer &blobWriter) { + StoredSingleEntry ids; + + // Construct a StoredSingleEntry with the ID(s) for `mappedEntry`. + if (auto *decl = mappedEntry.dyn_cast()) { + ids = StoredSingleEntry::forSerializedDecl( + astWriter.getDeclID(decl).getRawValue()); + } else if (auto *macro = mappedEntry.dyn_cast()) { + ids = StoredSingleEntry::forSerializedMacro(astWriter.getMacroID(macro)); + } else { + auto *moduleMacro = mappedEntry.get(); + StoredSingleEntry::SerializationID nameID = + astWriter.getIdentifierRef(moduleMacro->getName()); + StoredSingleEntry::SubmoduleID submoduleID = + astWriter.getLocalOrImportedSubmoduleID(moduleMacro->getOwningModule()); + ids = StoredSingleEntry::forSerializedMacro(nameID, submoduleID); + } + + // Write it out. + auto idsData = ids.getData(); + blobWriter.write(idsData.first); + blobWriter.write(idsData.second); + } + /// Trait used to write the on-disk hash table for the base name -> entities /// mapping. class BaseNameToEntitiesTableWriterInfo { @@ -1149,7 +1169,8 @@ namespace { dataLength += sizeof(uint16_t); // Actual entries. - dataLength += (sizeof(uint64_t) * entry.DeclsOrMacros.size()); + dataLength += (SizeOfEmittedStoredSingleEntry + * entry.DeclsOrMacros.size()); } endian::Writer writer(out, llvm::endianness::little); @@ -1187,22 +1208,8 @@ namespace { // Write the declarations and macros. for (auto &entry : fullEntry.DeclsOrMacros) { - uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); - if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02; - } else if (auto *macro = mappedEntry.dyn_cast()) { - id = static_cast(Writer.getMacroID(macro)) << 32; - id |= 0x02 | 0x01; - } else { - auto *moduleMacro = mappedEntry.get(); - uint32_t nameID = Writer.getIdentifierRef(moduleMacro->getName()); - uint32_t submoduleID = Writer.getLocalOrImportedSubmoduleID( - moduleMacro->getOwningModule()); - id = (static_cast(nameID) << 32) | (submoduleID << 2); - id |= 0x02 | 0x01; - } - writer.write(id); + emitStoredSingleEntry(mappedEntry, Writer, writer); } } } @@ -1217,7 +1224,7 @@ namespace { public: using key_type = std::pair; using key_type_ref = key_type; - using data_type = SmallVector; + using data_type = SmallVector; using data_type_ref = data_type &; using hash_value_type = uint32_t; using offset_type = unsigned; @@ -1243,7 +1250,7 @@ namespace { // # of entries uint32_t dataLength = - sizeof(uint16_t) + sizeof(uint64_t) * data.size(); + sizeof(uint16_t) + SizeOfEmittedStoredSingleEntry * data.size(); assert(dataLength == static_cast(dataLength)); endian::Writer writer(out, llvm::endianness::little); @@ -1269,22 +1276,8 @@ namespace { // Actual entries. bool isModule = Writer.getLangOpts().isCompilingModule(); for (auto &entry : data) { - uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); - if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02; - } else if (auto *macro = mappedEntry.dyn_cast()) { - id = static_cast(Writer.getMacroID(macro)) << 32; - id |= 0x02 | 0x01; - } else { - auto *moduleMacro = mappedEntry.get(); - uint32_t nameID = Writer.getIdentifierRef(moduleMacro->getName()); - uint32_t submoduleID = Writer.getLocalOrImportedSubmoduleID( - moduleMacro->getOwningModule()); - id = (static_cast(nameID) << 32) | (submoduleID << 2); - id |= 0x02 | 0x01; - } - writer.write(id); + emitStoredSingleEntry(mappedEntry, Writer, writer); } } }; @@ -1402,6 +1395,14 @@ void SwiftLookupTableWriter::writeExtensionContents( } namespace { + StoredSingleEntry readNextStoredSingleEntry(const uint8_t *&data) { + std::pair ids; + ids.first = readNext(data); + ids.second = readNext(data); + return StoredSingleEntry(ids); + } + /// Used to deserialize the on-disk base name -> entities table. class BaseNameToEntitiesTableReaderInfo { public: @@ -1477,8 +1478,7 @@ namespace { // Read the declarations and macros. unsigned numDeclsOrMacros = readNext(data); while (numDeclsOrMacros--) { - auto id = readNext(data); - entry.DeclsOrMacros.push_back(id); + entry.DeclsOrMacros.push_back(readNextStoredSingleEntry(data)); } result.push_back(entry); @@ -1493,7 +1493,7 @@ namespace { public: using internal_key_type = SwiftLookupTable::StoredContext; using external_key_type = internal_key_type; - using data_type = SmallVector; + using data_type = SmallVector; using hash_value_type = uint32_t; using offset_type = unsigned; @@ -1536,8 +1536,7 @@ namespace { // Read all of the entries. while (numEntries--) { - auto id = readNext(data); - result.push_back(id); + result.push_back(readNextStoredSingleEntry(data)); } return result; @@ -1545,24 +1544,24 @@ namespace { }; } // end anonymous namespace -clang::NamedDecl *SwiftLookupTable::mapStoredDecl(uint64_t &entry) { - assert(isDeclEntry(entry) && "Not a declaration entry"); +clang::NamedDecl *SwiftLookupTable::mapStoredDecl(StoredSingleEntry &entry) { + assert(entry.isDeclEntry() && "Not a declaration entry"); // If we have an AST node here, just cast it. - if (isASTNodeEntry(entry)) { - return static_cast(getPointerFromEntry(entry)); + if (entry.isASTNodeEntry()) { + return static_cast(entry.getASTNode()); } // Otherwise, resolve the declaration. assert(Reader && "Cannot resolve the declaration without a reader"); - auto declID = getEncodedDeclID(entry); + auto declID = entry.getSerializationID(); auto localID = clang::LocalDeclID::get(Reader->getASTReader(), Reader->getModuleFile(), declID); auto decl = cast_or_null( Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), localID)); // Update the entry now that we've resolved the declaration. - entry = encodeEntry(decl); + entry = StoredSingleEntry(decl); return decl; } @@ -1571,31 +1570,30 @@ static bool isPCH(SwiftLookupTableReader &reader) { } SwiftLookupTable::SingleEntry -SwiftLookupTable::mapStoredMacro(uint64_t &entry, bool assumeModule) { - assert(isMacroEntry(entry) && "Not a macro entry"); +SwiftLookupTable::mapStoredMacro(StoredSingleEntry &entry, bool assumeModule) { + assert(entry.isMacroEntry() && "Not a macro entry"); // If we have an AST node here, just cast it. - if (isASTNodeEntry(entry)) { + if (entry.isASTNodeEntry()) { if (assumeModule || (Reader && !isPCH(*Reader))) - return static_cast(getPointerFromEntry(entry)); + return static_cast(entry.getASTNode()); else - return static_cast(getPointerFromEntry(entry)); + return static_cast(entry.getASTNode()); } // Otherwise, resolve the macro. assert(Reader && "Cannot resolve the macro without a reader"); clang::ASTReader &astReader = Reader->getASTReader(); - LocalMacroIDs macroIDs = getEncodedModuleMacroIDs(entry); - if (!assumeModule && macroIDs.moduleID == 0) { + if (!assumeModule && entry.getModuleID() == 0) { assert(isPCH(*Reader)); // Not a module, and the second key is actually a macroID. auto macro = astReader.getMacro(astReader.getGlobalMacroID(Reader->getModuleFile(), - macroIDs.nameOrMacroID)); + entry.getSerializationID())); // Update the entry now that we've resolved the macro. - entry = encodeEntry(macro); + entry = StoredSingleEntry(macro); return macro; } @@ -1604,9 +1602,9 @@ SwiftLookupTable::mapStoredMacro(uint64_t &entry, bool assumeModule) { assert(!isPCH(*Reader)); clang::IdentifierInfo *name = astReader.getLocalIdentifier(Reader->getModuleFile(), - macroIDs.nameOrMacroID); - auto submoduleID = astReader.getGlobalSubmoduleID(Reader->getModuleFile(), - macroIDs.moduleID); + entry.getSerializationID()); + auto submoduleID = astReader.getGlobalSubmoduleID(Reader->getModuleFile(), + entry.getModuleID()); clang::Module *submodule = astReader.getSubmodule(submoduleID); assert(submodule); @@ -1617,13 +1615,13 @@ SwiftLookupTable::mapStoredMacro(uint64_t &entry, bool assumeModule) { // This might still be NULL if the module has been imported but not made // visible. We need a better answer here. if (macro) - entry = encodeEntry(macro); + entry = StoredSingleEntry(macro); return macro; } -SwiftLookupTable::SingleEntry SwiftLookupTable::mapStored(uint64_t &entry, - bool assumeModule) { - if (isDeclEntry(entry)) +SwiftLookupTable::SingleEntry +SwiftLookupTable::mapStored(StoredSingleEntry &entry, bool assumeModule) { + if (entry.isDeclEntry()) return mapStoredDecl(entry); return mapStoredMacro(entry, assumeModule); } @@ -1805,7 +1803,7 @@ SwiftLookupTableReader::getGlobalsAsMembersContexts() { bool SwiftLookupTableReader::lookupGlobalsAsMembersInContext( SwiftLookupTable::StoredContext context, - SmallVectorImpl &entries) { + SmallVectorImpl &entries) { if (!GlobalsAsMembersIndex) return false; // Look for an entry with this context name. diff --git a/lib/ClangImporter/SwiftLookupTable.h b/lib/ClangImporter/SwiftLookupTable.h index a10fe9e30163e..4b1073a0d8c11 100644 --- a/lib/ClangImporter/SwiftLookupTable.h +++ b/lib/ClangImporter/SwiftLookupTable.h @@ -18,6 +18,7 @@ #define SWIFT_CLANGIMPORTER_SWIFTLOOKUPTABLE_H #include "swift/AST/Identifier.h" +#include "swift/Basic/Assertions.h" #include "swift/Basic/Debug.h" #include "swift/Basic/LLVM.h" #include "clang/AST/Decl.h" @@ -282,7 +283,7 @@ const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MAJOR = 1; /// Lookup table minor version number. /// /// When the format changes IN ANY WAY, this number should be incremented. -const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 18; // Unsafe C++ method renaming. +const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 19; // 64-bit clang serialization IDs /// A lookup table that maps Swift names to the set of Clang @@ -325,6 +326,137 @@ class SwiftLookupTable { /// ASTContext-independent. typedef std::pair StoredContext; + /// Much like \c SingleEntry , this type references either a named + /// declaration or a macro. However, it may reference it by either a direct + /// pointer to an AST node, or by one or more serialization IDs. + class StoredSingleEntry { + public: + using SerializationID = clang::serialization::DeclID; + using SubmoduleID = clang::serialization::SubmoduleID; + + static_assert(sizeof(SerializationID) >= sizeof(uintptr_t), + "pointer fits into SerializationID"); + static_assert(sizeof(SerializationID) >= + sizeof(clang::serialization::IdentifierID), + "IdentifierID fits into SerializationID"); + + private: + /// Either contains a pointer to an AST node or a serialization ID, + /// depending on the value of \c IsSerializationID . + SerializationID ASTNodeOrSerializationID; + + /// If this is equal to \c IS_DECL , this entry represents a declaration. + /// Otherwise it represents a macro, and the value is the associated module + /// ID. (Note that the associated module ID is often zero, meaning the ID + /// is unused but this \em is a macro.) + SubmoduleID IsDeclOrMacroModuleID; + + /// If \c true , \c ASTNodeOrSerializationID is a serialization ID; + /// otherwise, it is a pointer to an AST node. + bool IsSerializationID; + // Note: `IsSerializationID` is intentionally stored out of band so that it + // cannot be cleared by reading the wrong value from disk. If you bit-pack + // it, take care to force it to the right value when necessary. + + /// Sentinel used in \c IsDeclOrMacroModuleID to indicate that the entry is + /// for a decl. + static constexpr SubmoduleID IS_DECL = + std::numeric_limits::max(); + + StoredSingleEntry(void *astNode, SubmoduleID isDeclOrMacroModuleID) + : ASTNodeOrSerializationID(reinterpret_cast(astNode)), + IsDeclOrMacroModuleID(isDeclOrMacroModuleID), + IsSerializationID(false) + {} + + StoredSingleEntry(SerializationID serializationID, + SubmoduleID isDeclOrMacroModuleID) + : ASTNodeOrSerializationID(serializationID), + IsDeclOrMacroModuleID(isDeclOrMacroModuleID), + IsSerializationID(true) + {} + + public: + /// Whether the given entry is a declaration entry. + bool isDeclEntry() const { return IsDeclOrMacroModuleID == IS_DECL; } + + /// Whether the given entry is a macro entry. + bool isMacroEntry() const { return !isDeclEntry(); } + + /// Whether the given entry is a serialization ID. + bool isSerializationIDEntry() const { return IsSerializationID; } + + /// Whether the given entry is an AST node. + bool isASTNodeEntry() const { return !isSerializationIDEntry(); } + + /// Retrieve the pointer for an entry. + void *getASTNode() const { + ASSERT(isASTNodeEntry() && "Not an AST node entry"); + return reinterpret_cast( + static_cast(ASTNodeOrSerializationID)); + } + + /// Get the serialization ID out of the entry. + SerializationID getSerializationID() const { + ASSERT(isSerializationIDEntry()); + return ASTNodeOrSerializationID; + } + + /// Get the module ID out of the entry. Do not call on an entry representing a decl. + SubmoduleID getModuleID() const { + ASSERT(isSerializationIDEntry()); + ASSERT(isMacroEntry()); + return IsDeclOrMacroModuleID; + } + + /// Convert this entry to an on-disk representation. Do not call on an + /// entry backed by an AST node; these cannot be directly represented on + /// disk. + std::pair getData() const { + return { getSerializationID(), IsDeclOrMacroModuleID }; + } + + /// Encode an empty entry. + StoredSingleEntry() + : StoredSingleEntry(nullptr, IS_DECL) + {} + + /// Encode a Clang named declaration as an entry in the table. + StoredSingleEntry(clang::NamedDecl *decl) + : StoredSingleEntry(decl, IS_DECL) + {} + + /// Encode a Clang macro as an entry in the table. + StoredSingleEntry(clang::MacroInfo *macro) + : StoredSingleEntry(macro, 0) + {} + + /// Encode a Clang macro as an entry in the table. + StoredSingleEntry(clang::ModuleMacro *macro) + : StoredSingleEntry(macro, 0) + {} + + /// Encode a Clang decl as an entry in the table by its serialization ID. + static StoredSingleEntry + forSerializedDecl(SerializationID serializationID) { + return StoredSingleEntry(serializationID, IS_DECL); + } + + /// Encode a Clang macro as an entry in the table by its serialization ID + /// and, optionally, the serialization ID of the submodule it belongs to. + static StoredSingleEntry + forSerializedMacro(SerializationID serializationID, + SubmoduleID moduleID = 0) { + ASSERT(moduleID != IS_DECL && "oversized clang moduleID"); + return StoredSingleEntry(serializationID, moduleID); + } + + /// Convert the on-disk representation to an entry. + StoredSingleEntry(std::pair data) + : StoredSingleEntry(data.first, data.second) + {} + }; + /// An entry in the table of C entities indexed by full Swift name. struct FullTableEntry { /// The context in which the entities with the given name occur, e.g., @@ -334,63 +466,9 @@ class SwiftLookupTable { /// The set of Clang declarations and macros with this name and in /// this context. - /// - /// The low bit indicates whether we have a declaration or macro - /// (declaration = unset, macro = set) and the second lowest bit - /// indicates whether we have a serialization ID (set = DeclID or - /// {IdentifierID,SubmoduleID}, as appropriate) vs. a pointer (unset, - /// clang::NamedDecl *, clang::MacroInfo *, clang::ModuleMacro *). - /// In the ID case, the upper N-2 bits are the ID value; in the pointer - /// case, the lower two bits will always be clear due to the alignment of - /// the Clang pointers. - llvm::SmallVector DeclsOrMacros; + llvm::SmallVector DeclsOrMacros; }; - /// Whether the given entry is a macro entry. - static bool isMacroEntry(uint64_t entry) { return entry & 0x01; } - - /// Whether the given entry is a declaration entry. - static bool isDeclEntry(uint64_t entry) { return !isMacroEntry(entry); } - - /// Whether the given entry is a serialization ID. - static bool isSerializationIDEntry(uint64_t entry) { return (entry & 0x02); } - - /// Whether the given entry is an AST node. - static bool isASTNodeEntry(uint64_t entry) { - return !isSerializationIDEntry(entry); - } - - /// Retrieve the pointer for an entry. - static void *getPointerFromEntry(uint64_t entry) { - assert(isASTNodeEntry(entry) && "Not an AST node entry"); - const uint64_t mask = ~static_cast(0x03); - return reinterpret_cast(entry & mask); - } - - /// Encode a Clang named declaration as an entry in the table. - static uint64_t encodeEntry(clang::NamedDecl *decl) { - assert(decl); - auto bits = reinterpret_cast(decl); - assert((bits & 0x03) == 0 && "low bits set?"); - return bits; - } - - // Encode a Clang macro as an entry in the table. - static uint64_t encodeEntry(clang::MacroInfo *macro) { - assert(macro); - auto bits = reinterpret_cast(macro); - assert((bits & 0x03) == 0 && "low bits set?"); - return bits | 0x01; - } - - // Encode a Clang macro as an entry in the table. - static uint64_t encodeEntry(clang::ModuleMacro *macro) { - assert(macro); - auto bits = reinterpret_cast(macro); - assert((bits & 0x03) == 0 && "low bits set?"); - return bits | 0x01; - } - private: using TableType = llvm::DenseMap>; @@ -414,7 +492,8 @@ class SwiftLookupTable { /// /// The values use the same representation as /// FullTableEntry::DeclsOrMacros. - llvm::DenseMap> GlobalsAsMembersIndex; + llvm::DenseMap> + GlobalsAsMembersIndex; /// The reader responsible for lazily loading the contents of this table. SwiftLookupTableReader *Reader; @@ -437,19 +516,22 @@ class SwiftLookupTable { /// present. /// /// \returns true if the entry was added, false otherwise. - bool addLocalEntry(SingleEntry newEntry, SmallVectorImpl &entries); + bool addLocalEntry(SingleEntry newEntry, + SmallVectorImpl &entries); public: explicit SwiftLookupTable(SwiftLookupTableReader *reader) : Reader(reader) { } /// Maps a stored declaration entry to an actual Clang declaration. - clang::NamedDecl *mapStoredDecl(uint64_t &entry); + clang::NamedDecl *mapStoredDecl(StoredSingleEntry &entry); /// Maps a stored macro entry to an actual Clang macro. - SingleEntry mapStoredMacro(uint64_t &entry, bool assumeModule = false); + SingleEntry mapStoredMacro(StoredSingleEntry &entry, + bool assumeModule = false); /// Maps a stored entry to an actual Clang AST node. - SingleEntry mapStored(uint64_t &entry, bool assumeModule = false); + SingleEntry mapStored(StoredSingleEntry &entry, + bool assumeModule = false); /// Translate a Clang DeclContext into a context kind and name. static std::optional From cfbc007535eb9a8267f0f7034cdcedb8347600e6 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 31 Jul 2024 20:17:06 -0700 Subject: [PATCH 075/110] [rebranch] Do not serialize unstable hashes https://github.com/llvm/llvm-project/pull/96282 changed `get_execution_seed` to be non-deterministic. Use stable hashes instead. --- include/swift/Localization/LocalizationFormat.h | 4 ++-- lib/ClangImporter/SwiftLookupTable.cpp | 4 ++-- lib/ClangImporter/SwiftLookupTable.h | 2 +- lib/Serialization/ModuleFileCoreTableInfo.h | 4 ++-- lib/Serialization/ModuleFormat.h | 2 +- lib/Serialization/Serialization.cpp | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/swift/Localization/LocalizationFormat.h b/include/swift/Localization/LocalizationFormat.h index 23e38f0f49402..af5ad247ee72a 100644 --- a/include/swift/Localization/LocalizationFormat.h +++ b/include/swift/Localization/LocalizationFormat.h @@ -69,7 +69,7 @@ class LocalizationWriterInfo { using hash_value_type = uint32_t; using offset_type = uint32_t; - hash_value_type ComputeHash(key_type_ref key) { return llvm::hash_code(key); } + hash_value_type ComputeHash(key_type_ref key) { return key; } std::pair EmitKeyDataLength(llvm::raw_ostream &out, key_type_ref key, @@ -113,7 +113,7 @@ class LocalizationReaderInfo { } hash_value_type ComputeHash(internal_key_type key) { - return llvm::hash_code(key); + return key; } static std::pair diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index 8f0ca1a128432..5087bd05d35c1 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -1142,7 +1142,7 @@ namespace { } hash_value_type ComputeHash(key_type_ref key) { - return llvm::DenseMapInfo::getHashValue(key); + return static_cast(key.Kind) + llvm::djbHash(key.Name); } std::pair EmitKeyDataLength(raw_ostream &out, @@ -1421,7 +1421,7 @@ namespace { } hash_value_type ComputeHash(internal_key_type key) { - return llvm::DenseMapInfo::getHashValue(key); + return static_cast(key.Kind) + llvm::djbHash(key.Name); } static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { diff --git a/lib/ClangImporter/SwiftLookupTable.h b/lib/ClangImporter/SwiftLookupTable.h index 4b1073a0d8c11..8ddca2eb7750e 100644 --- a/lib/ClangImporter/SwiftLookupTable.h +++ b/lib/ClangImporter/SwiftLookupTable.h @@ -283,7 +283,7 @@ const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MAJOR = 1; /// Lookup table minor version number. /// /// When the format changes IN ANY WAY, this number should be incremented. -const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 19; // 64-bit clang serialization IDs +const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 20; // hash functions /// A lookup table that maps Swift names to the set of Clang diff --git a/lib/Serialization/ModuleFileCoreTableInfo.h b/lib/Serialization/ModuleFileCoreTableInfo.h index a48672d2666d3..2dc30c7e7d8cd 100644 --- a/lib/Serialization/ModuleFileCoreTableInfo.h +++ b/lib/Serialization/ModuleFileCoreTableInfo.h @@ -318,7 +318,7 @@ class ModuleFileSharedCore::DeclMembersTableInfo { } hash_value_type ComputeHash(internal_key_type key) { - return llvm::hash_value(key); + return key; } static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { @@ -557,7 +557,7 @@ class ModuleFileSharedCore::DeclFingerprintsTableInfo { internal_key_type GetInternalKey(external_key_type ID) { return ID; } hash_value_type ComputeHash(internal_key_type key) { - return llvm::hash_value(key); + return key; } static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { diff --git a/lib/Serialization/ModuleFormat.h b/lib/Serialization/ModuleFormat.h index 3328c83b469e2..7717d67fc249a 100644 --- a/lib/Serialization/ModuleFormat.h +++ b/lib/Serialization/ModuleFormat.h @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0; /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. /// Don't worry about adhering to the 80-column limit for this line. -const uint16_t SWIFTMODULE_VERSION_MINOR = 881; // Changes to LifetimeDependence +const uint16_t SWIFTMODULE_VERSION_MINOR = 882; // hash functions /// A standard hash seed used for all string hashes in a serialized module. /// diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index 4c56107531055..ae6cf4de81b31 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -414,7 +414,7 @@ namespace { using offset_type = unsigned; hash_value_type ComputeHash(key_type_ref key) { - return llvm::hash_value(static_cast(key)); + return static_cast(key); } std::pair EmitKeyDataLength(raw_ostream &out, @@ -459,7 +459,7 @@ namespace { using offset_type = unsigned; hash_value_type ComputeHash(key_type_ref key) { - return llvm::hash_value(static_cast(key)); + return static_cast(key); } std::pair From 13ab5768e6d43d2d3ce0de5859d604ccedb8ddbb Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 2 Aug 2024 11:37:37 -0700 Subject: [PATCH 076/110] [Cleanup] Remove last `equals` in unittests This was removed in upstream LLVM in preference for `==`. --- unittests/AST/ASTWalkerTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/AST/ASTWalkerTests.cpp b/unittests/AST/ASTWalkerTests.cpp index 587ff188eebc9..019080d589a4a 100644 --- a/unittests/AST/ASTWalkerTests.cpp +++ b/unittests/AST/ASTWalkerTests.cpp @@ -361,7 +361,7 @@ class WalkVerifier { if (component.getCheckpoint() == checkpoint) { auto arg = this->walkStr.str().slice(component.getArgumentStartIndex(), component.getArgumentEndIndex()); - if (arg.equals(argumentStr)) { + if (arg == argumentStr) { return index; } } From 2269b42d3d84929cd40310ab2d2f8787a16d8783 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 5 Aug 2024 19:53:15 -0700 Subject: [PATCH 077/110] [ClangImporter] Correct check to ignore macro The functionality of this function changed upstream in https://github.com/llvm/llvm-project/pull/97274 and it now returns the value of the character, rather than the character itself. --- lib/ClangImporter/ImportName.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index d8af0c8045de0..004a12cfe2940 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -2378,7 +2378,7 @@ static bool shouldIgnoreMacro(StringRef name, const clang::MacroInfo *macro, if (macro->isUsedForHeaderGuard() && macro->getNumTokens() == 1) { auto tok = macro->tokens()[0]; if (tok.is(clang::tok::numeric_constant) && tok.getLength() == 1 && - PP.getSpellingOfSingleCharacterNumericConstant(tok) == '1') + PP.getSpellingOfSingleCharacterNumericConstant(tok) == 1) return true; } From 3b332bf125e588fcbed44e190572e4ad133b40cc Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Tue, 6 Aug 2024 12:18:28 -0700 Subject: [PATCH 078/110] [IndexRecord] Fix an handled error in IndexRecord Fix an unhandled error when querying file system. Just properly ignore and continue if the file can't be read. --- lib/Index/IndexRecord.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Index/IndexRecord.cpp b/lib/Index/IndexRecord.cpp index 116d89da730a5..0b3b2f83cdae5 100644 --- a/lib/Index/IndexRecord.cpp +++ b/lib/Index/IndexRecord.cpp @@ -35,6 +35,7 @@ #include "clang/Index/IndexingAction.h" #include "clang/Lex/Preprocessor.h" #include "clang/Serialization/ASTReader.h" +#include "llvm/Support/Error.h" #include "llvm/Support/Path.h" using namespace swift; @@ -636,8 +637,11 @@ static void addModuleDependencies(ArrayRef imports, } auto F = fileMgr.getFileRef(modulePath); - if (!F) + if (!F) { + // Ignore error and continue. + llvm::consumeError(F.takeError()); break; + } // Use module real name for unit writer in case module aliasing // is used. For example, if a file being indexed has `import Foo` From db5fd1d08794c39810c3aebef3f5d4741107ff05 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 8 Aug 2024 11:41:36 -0700 Subject: [PATCH 079/110] [cxx-interop] Print `inline` instead of `static inline` for template specializations This was fixed in 14413d9d90e3df0aea39e684a2f6cd358ab08579 but then lost when a05b3051fa24262154f0ad03f614cfbef3529d33 was merged in. Bring it back. --- lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp b/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp index 0f50c1e23ab66..58caa18707be3 100644 --- a/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp +++ b/lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp @@ -200,7 +200,7 @@ void printPrimitiveGenericTypeTraits(raw_ostream &os, ASTContext &astContext, if (!isCForwardDefinition) { os << "template<>\n"; - os << "static inline const constexpr bool isUsableInGenericContext<" + os << "inline const constexpr bool isUsableInGenericContext<" << typeInfo.name << "> = true;\n\n"; } From df81d0a450d524ec24fa17f202514b72521ff72e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 8 Aug 2024 14:47:18 -0700 Subject: [PATCH 080/110] [Tests] XFAIL the remaining test failures on rebranch Only a few tests remaining. XFAIL so we can test the rest of the toolchain. --- test/ClangImporter/enum-renames.swift | 2 ++ test/Interop/Cxx/class/protocol-conformance-typechecker.swift | 4 +++- .../Cxx/operators/member-inline-module-interface.swift | 2 ++ test/Interop/Cxx/operators/member-inline.swift | 2 ++ validation-test/BuildSystem/generate_xcode.test | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/ClangImporter/enum-renames.swift b/test/ClangImporter/enum-renames.swift index 9557b7be6ec36..4f32b60eee022 100644 --- a/test/ClangImporter/enum-renames.swift +++ b/test/ClangImporter/enum-renames.swift @@ -1,3 +1,5 @@ +// REQUIRES: rdar127262612 + // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify import enums_using_attributes diff --git a/test/Interop/Cxx/class/protocol-conformance-typechecker.swift b/test/Interop/Cxx/class/protocol-conformance-typechecker.swift index 05372bb748a16..b422382e8bba1 100644 --- a/test/Interop/Cxx/class/protocol-conformance-typechecker.swift +++ b/test/Interop/Cxx/class/protocol-conformance-typechecker.swift @@ -1,3 +1,5 @@ +// REQUIRES: rdar133257179 + // Tests that a C++ class can conform to a Swift protocol. // RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-experimental-cxx-interop @@ -54,4 +56,4 @@ protocol HasOperatorCall { func callAsFunction(_ x: Int32) -> Int32 } -extension HasStaticOperatorCall : HasOperatorCall {} \ No newline at end of file +extension HasStaticOperatorCall : HasOperatorCall {} diff --git a/test/Interop/Cxx/operators/member-inline-module-interface.swift b/test/Interop/Cxx/operators/member-inline-module-interface.swift index d5d454def2ffc..3842baeae7448 100644 --- a/test/Interop/Cxx/operators/member-inline-module-interface.swift +++ b/test/Interop/Cxx/operators/member-inline-module-interface.swift @@ -1,3 +1,5 @@ +// REQUIRES: rdar133257179 + // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=swift-5.9 | %FileCheck %s // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=swift-6 | %FileCheck %s // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift | %FileCheck %s diff --git a/test/Interop/Cxx/operators/member-inline.swift b/test/Interop/Cxx/operators/member-inline.swift index 73540783ee53a..6724c7d1e2669 100644 --- a/test/Interop/Cxx/operators/member-inline.swift +++ b/test/Interop/Cxx/operators/member-inline.swift @@ -1,3 +1,5 @@ +// REQUIRES: rdar133257179 + // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=swift-5.9) // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=swift-6) // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=upcoming-swift) diff --git a/validation-test/BuildSystem/generate_xcode.test b/validation-test/BuildSystem/generate_xcode.test index ab234a60356a9..db4cb8c68f86a 100644 --- a/validation-test/BuildSystem/generate_xcode.test +++ b/validation-test/BuildSystem/generate_xcode.test @@ -1,3 +1,5 @@ +# REQUIRES: rdar133492917 + # RUN: %empty-directory(%t) # RUN: %empty-directory(%t/Xcode) From fd84e7273d33fb0fd61e33e592cfee5150dd7e44 Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Mon, 12 Aug 2024 17:47:26 -0700 Subject: [PATCH 081/110] Rename module.map -> module.modulemap in tests The legacy `module.map` spelling of module map files was deprecated by llvm/llvm-project#75142 and clang expects to remove support for them in the future. Switch all tests to use the supported spelling. Fixes rdar://128431478. --- test/ClangImporter/AllowErrors/invalid-pcm.swift | 4 ++-- test/ClangImporter/Inputs/custom-modules/module.modulemap | 4 ++-- .../custom-modules/more-custom-modules/module.modulemap | 2 +- .../{Base-module.map => Base.modulemap} | 0 test/ClangImporter/MixedSource/resolve-cross-language.swift | 2 +- test/Frontend/Inputs/vfs/vfsoverlay.yaml | 2 +- test/SourceKit/CursorInfo/cursor_generated_interface.swift | 4 ++-- test/SymbolGraph/Relationships/OptionalRequirementOf.swift | 2 +- test/stdlib/Inputs/ArrayBridge/module.modulemap | 2 +- test/stdlib/Inputs/FoundationBridge/module.modulemap | 2 +- test/stdlib/Inputs/Mirror/module.modulemap | 2 +- .../Inputs/EmptyStruct/{module.map => module.modulemap} | 0 .../Inputs/ObjCClasses/{module.map => module.modulemap} | 0 .../class-stubs-from-objc/{module.map => module.modulemap} | 0 .../Inputs/class-stubs-weak/{module.map => module.modulemap} | 0 validation-test/Runtime/class_stubs.m | 2 +- validation-test/Runtime/class_stubs_weak.m | 2 +- 17 files changed, 15 insertions(+), 15 deletions(-) rename test/ClangImporter/MixedSource/Inputs/resolve-cross-language/{Base-module.map => Base.modulemap} (100%) rename validation-test/Reflection/Inputs/EmptyStruct/{module.map => module.modulemap} (100%) rename validation-test/Reflection/Inputs/ObjCClasses/{module.map => module.modulemap} (100%) rename validation-test/Runtime/Inputs/class-stubs-from-objc/{module.map => module.modulemap} (100%) rename validation-test/Runtime/Inputs/class-stubs-weak/{module.map => module.modulemap} (100%) diff --git a/test/ClangImporter/AllowErrors/invalid-pcm.swift b/test/ClangImporter/AllowErrors/invalid-pcm.swift index aa0bda0dc455a..4cb36713cf8f6 100644 --- a/test/ClangImporter/AllowErrors/invalid-pcm.swift +++ b/test/ClangImporter/AllowErrors/invalid-pcm.swift @@ -1,10 +1,10 @@ // RUN: %empty-directory(%t) // RUN: split-file %s %t -// RUN: %target-swift-emit-pcm -module-name m -o %t/m.pcm -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/mods/module.map +// RUN: %target-swift-emit-pcm -module-name m -o %t/m.pcm -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/mods/module.modulemap // RUN: %target-swift-frontend -typecheck -verify -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -fmodule-file=%t/m.pcm %t/use.swift -//--- mods/module.map +//--- mods/module.modulemap module m { header "m.h" } diff --git a/test/ClangImporter/Inputs/custom-modules/module.modulemap b/test/ClangImporter/Inputs/custom-modules/module.modulemap index 0fc69e9669d13..adab562566082 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.modulemap +++ b/test/ClangImporter/Inputs/custom-modules/module.modulemap @@ -113,8 +113,8 @@ module ImportAsMember { } } -// FIXME: This probably ought to be in a module_private.map, but that causes -// hundreds of clang warnings. +// FIXME: This probably ought to be in a module.private.modulemap, but that +// causes hundreds of clang warnings. module ImportAsMember_Private { export * diff --git a/test/ClangImporter/Inputs/custom-modules/more-custom-modules/module.modulemap b/test/ClangImporter/Inputs/custom-modules/more-custom-modules/module.modulemap index 61147751392ba..ae72e111004c9 100644 --- a/test/ClangImporter/Inputs/custom-modules/more-custom-modules/module.modulemap +++ b/test/ClangImporter/Inputs/custom-modules/more-custom-modules/module.modulemap @@ -1,4 +1,4 @@ -// It is important that this test uses a second module.map file. +// It is important that this test uses a second module.modulemap file. module ImportsMissingHeaderIndirect { header "ImportsMissingHeaderIndirect.h" export * diff --git a/test/ClangImporter/MixedSource/Inputs/resolve-cross-language/Base-module.map b/test/ClangImporter/MixedSource/Inputs/resolve-cross-language/Base.modulemap similarity index 100% rename from test/ClangImporter/MixedSource/Inputs/resolve-cross-language/Base-module.map rename to test/ClangImporter/MixedSource/Inputs/resolve-cross-language/Base.modulemap diff --git a/test/ClangImporter/MixedSource/resolve-cross-language.swift b/test/ClangImporter/MixedSource/resolve-cross-language.swift index 2ecfc9d0b2acd..f64c280ad4820 100644 --- a/test/ClangImporter/MixedSource/resolve-cross-language.swift +++ b/test/ClangImporter/MixedSource/resolve-cross-language.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -emit-module -enable-objc-interop -emit-objc-header -o %t %S/Inputs/resolve-cross-language/Base.swift -disable-objc-attr-requires-foundation-module -// RUN: cp %S/Inputs/resolve-cross-language/Base-module.map %t/module.modulemap +// RUN: cp %S/Inputs/resolve-cross-language/Base.modulemap %t/module.modulemap // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -I %t -F %clang-importer-sdk-path/frameworks -F %S/Inputs/resolve-cross-language %s -verify import Base diff --git a/test/Frontend/Inputs/vfs/vfsoverlay.yaml b/test/Frontend/Inputs/vfs/vfsoverlay.yaml index 91f875194d09c..6ec13800b921d 100644 --- a/test/Frontend/Inputs/vfs/vfsoverlay.yaml +++ b/test/Frontend/Inputs/vfs/vfsoverlay.yaml @@ -5,7 +5,7 @@ { 'name': 'OUT_DIR', 'type': 'directory', 'contents': [ - { 'name': 'module.map', 'type': 'file', + { 'name': 'module.modulemap', 'type': 'file', 'external-contents': 'INPUT_DIR/vfs/a-modulemap' }, { 'name': 'VFSMappedModule.h', 'type': 'file', diff --git a/test/SourceKit/CursorInfo/cursor_generated_interface.swift b/test/SourceKit/CursorInfo/cursor_generated_interface.swift index 81826a37c43c8..9534fd96c3adc 100644 --- a/test/SourceKit/CursorInfo/cursor_generated_interface.swift +++ b/test/SourceKit/CursorInfo/cursor_generated_interface.swift @@ -46,7 +46,7 @@ public class ASwiftType { // CHECKA: key.modulename: "LibA" // CHECKA: key.decl_lang: source.lang.swift -//--- frameworks/LibA.framework/module.map +//--- frameworks/LibA.framework/Modules/module.modulemap framework module LibA { header "LibA.h" export * @@ -113,7 +113,7 @@ public class CType {} // CHECKD: key.modulename: "LibD" // CHECKD: key.decl_lang: source.lang.objc -//--- mods/module.map +//--- mods/module.modulemap module LibD { header "LibD.h" export * diff --git a/test/SymbolGraph/Relationships/OptionalRequirementOf.swift b/test/SymbolGraph/Relationships/OptionalRequirementOf.swift index bf5065cb318c9..51635655f70b2 100644 --- a/test/SymbolGraph/Relationships/OptionalRequirementOf.swift +++ b/test/SymbolGraph/Relationships/OptionalRequirementOf.swift @@ -22,7 +22,7 @@ public protocol SwiftProto { @objc optional func swiftReq() } -//--- frameworks/OptionalRequirementOf.framework/module.map +//--- frameworks/OptionalRequirementOf.framework/Modules/module.modulemap framework module OptionalRequirementOf { header "req.h" export * diff --git a/test/stdlib/Inputs/ArrayBridge/module.modulemap b/test/stdlib/Inputs/ArrayBridge/module.modulemap index 51561caad33c9..979752ed701ae 100644 --- a/test/stdlib/Inputs/ArrayBridge/module.modulemap +++ b/test/stdlib/Inputs/ArrayBridge/module.modulemap @@ -1,4 +1,4 @@ -//===--- module.map -------------------------------------------------------===// +//===--- module.modulemap -------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/test/stdlib/Inputs/FoundationBridge/module.modulemap b/test/stdlib/Inputs/FoundationBridge/module.modulemap index 775599c573865..12f818350e2b0 100644 --- a/test/stdlib/Inputs/FoundationBridge/module.modulemap +++ b/test/stdlib/Inputs/FoundationBridge/module.modulemap @@ -1,4 +1,4 @@ -//===--- module.map -------------------------------------------------------===// +//===--- module.modulemap -------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/test/stdlib/Inputs/Mirror/module.modulemap b/test/stdlib/Inputs/Mirror/module.modulemap index b2efa3bed9e2b..c002efd467913 100644 --- a/test/stdlib/Inputs/Mirror/module.modulemap +++ b/test/stdlib/Inputs/Mirror/module.modulemap @@ -1,4 +1,4 @@ -//===--- module.map -------------------------------------------------------===// +//===--- module.modulemap -------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/validation-test/Reflection/Inputs/EmptyStruct/module.map b/validation-test/Reflection/Inputs/EmptyStruct/module.modulemap similarity index 100% rename from validation-test/Reflection/Inputs/EmptyStruct/module.map rename to validation-test/Reflection/Inputs/EmptyStruct/module.modulemap diff --git a/validation-test/Reflection/Inputs/ObjCClasses/module.map b/validation-test/Reflection/Inputs/ObjCClasses/module.modulemap similarity index 100% rename from validation-test/Reflection/Inputs/ObjCClasses/module.map rename to validation-test/Reflection/Inputs/ObjCClasses/module.modulemap diff --git a/validation-test/Runtime/Inputs/class-stubs-from-objc/module.map b/validation-test/Runtime/Inputs/class-stubs-from-objc/module.modulemap similarity index 100% rename from validation-test/Runtime/Inputs/class-stubs-from-objc/module.map rename to validation-test/Runtime/Inputs/class-stubs-from-objc/module.modulemap diff --git a/validation-test/Runtime/Inputs/class-stubs-weak/module.map b/validation-test/Runtime/Inputs/class-stubs-weak/module.modulemap similarity index 100% rename from validation-test/Runtime/Inputs/class-stubs-weak/module.map rename to validation-test/Runtime/Inputs/class-stubs-weak/module.modulemap diff --git a/validation-test/Runtime/class_stubs.m b/validation-test/Runtime/class_stubs.m index 91ce61674a91c..a16f2813aafb3 100644 --- a/validation-test/Runtime/class_stubs.m +++ b/validation-test/Runtime/class_stubs.m @@ -4,7 +4,7 @@ // RUN: %empty-directory(%t) // RUN: %target-build-swift -emit-library -emit-module -o %t/libfirst.dylib -emit-objc-header-path %t/first.h %S/Inputs/class-stubs-from-objc/first.swift -Xlinker -install_name -Xlinker @executable_path/libfirst.dylib -enable-library-evolution // RUN: %target-build-swift -emit-library -o %t/libsecond.dylib -emit-objc-header-path %t/second.h -I %t %S/Inputs/class-stubs-from-objc/second.swift -Xlinker -install_name -Xlinker @executable_path/libsecond.dylib -lfirst -L %t -target %target-next-stable-abi-triple -// RUN: cp %S/Inputs/class-stubs-from-objc/module.map %t/ +// RUN: cp %S/Inputs/class-stubs-from-objc/module.modulemap %t/ // RUN: xcrun -sdk %sdk %clang %s -I %t -L %t -fmodules -fobjc-arc -o %t/main -lfirst -lsecond -target %target-next-stable-abi-triple // RUN: %target-codesign %t/main %t/libfirst.dylib %t/libsecond.dylib // RUN: %target-run %t/main %t/libfirst.dylib %t/libsecond.dylib diff --git a/validation-test/Runtime/class_stubs_weak.m b/validation-test/Runtime/class_stubs_weak.m index db4b7fe85238b..edb06cab8857a 100644 --- a/validation-test/Runtime/class_stubs_weak.m +++ b/validation-test/Runtime/class_stubs_weak.m @@ -4,7 +4,7 @@ // RUN: %empty-directory(%t) // RUN: %target-build-swift -emit-library -emit-module -o %t/libfirst.dylib -emit-objc-header-path %t/first.h %S/Inputs/class-stubs-weak/first.swift -Xlinker -install_name -Xlinker @executable_path/libfirst.dylib -enable-library-evolution // RUN: %target-build-swift -emit-library -o %t/libsecond.dylib -emit-objc-header-path %t/second.h -I %t %S/Inputs/class-stubs-weak/second.swift -Xlinker -install_name -Xlinker @executable_path/libsecond.dylib -lfirst -L %t -target %target-next-stable-abi-triple -DBEFORE -// RUN: cp %S/Inputs/class-stubs-weak/module.map %t/ +// RUN: cp %S/Inputs/class-stubs-weak/module.modulemap %t/ // Note: This is the just-built Clang, not the system Clang. // RUN: xcrun -sdk %sdk %clang %s -I %t -L %t -fmodules -fobjc-arc -o %t/main -lfirst -lsecond -target %target-triple From 28805171133952f807a8ae7f2beb81fa1772117f Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 13 Aug 2024 13:44:22 -0700 Subject: [PATCH 082/110] [DebugInfo] Don't emit debug info for async suspend/dispatch functions Those functions are effectively outlined functions with an alwaysinline attribute. By removing their debug info and relying on the inliner to propagate the call site location to the inlined instructions, we restore the "original" locations as if the function had never been outlined. This is technically relying on an implementation detail of the inliner, but it seems to be the simplest way of addressing this issue. --- lib/IRGen/GenFunc.cpp | 6 --- ...c-await-no-debug-info-outlined-funcs.swift | 43 +++++++++++++++++++ test/IRGen/async/get_async_continuation.sil | 3 +- 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift diff --git a/lib/IRGen/GenFunc.cpp b/lib/IRGen/GenFunc.cpp index 6b5b2a121a414..100669489ea7c 100644 --- a/lib/IRGen/GenFunc.cpp +++ b/lib/IRGen/GenFunc.cpp @@ -2899,9 +2899,6 @@ IRGenFunction::createAsyncDispatchFn(const FunctionPointer &fnPtr, dispatch->setDoesNotThrow(); dispatch->addFnAttr(llvm::Attribute::AlwaysInline); IRGenFunction dispatchIGF(IGM, dispatch); - // Don't emit debug info if we are generating a function for the prologue. - if (IGM.DebugInfo && Builder.getCurrentDebugLocation()) - IGM.DebugInfo->emitOutlinedFunction(dispatchIGF, dispatch, CurFn->getName()); auto &Builder = dispatchIGF.Builder; auto it = dispatchIGF.CurFn->arg_begin(), end = dispatchIGF.CurFn->arg_end(); llvm::Value *fnPtrArg = &*(it++); @@ -2987,9 +2984,6 @@ llvm::Function *IRGenFunction::createAsyncSuspendFn() { suspendFn->setDoesNotThrow(); suspendFn->addFnAttr(llvm::Attribute::AlwaysInline); IRGenFunction suspendIGF(IGM, suspendFn); - if (IGM.DebugInfo) - IGM.DebugInfo->emitOutlinedFunction(suspendIGF, suspendFn, - CurFn->getName()); auto &Builder = suspendIGF.Builder; llvm::Value *resumeFunction = suspendFn->getArg(0); diff --git a/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift b/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift new file mode 100644 index 0000000000000..d84ea6e983783 --- /dev/null +++ b/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift @@ -0,0 +1,43 @@ +// RUN: %target-swift-frontend %s -emit-irgen -g -o - \ +// RUN: -module-name M -disable-availability-checking \ +// RUN: -parse-as-library | %FileCheck %s --check-prefix=CHECK + +// REQUIRES: concurrency + +// Check that all the helper "outlined" functions do not have debug information. + +func ASYNC___1___() async -> Int { + return 42 +} + +func ASYNC___2___() async -> Int { + print("hello") + var x = await ASYNC___1___() + x += await ASYNC___1___() + return x +} + +// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___1___SiyYaF.0" +// CHECK-NOT: !dbg +// CHECK: ret void +// CHECK-NEXT: } + +// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.1" +// CHECK-NOT: !dbg +// CHECK: ret void +// CHECK-NEXT: } + +// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.0" +// CHECK-NOT: !dbg +// CHECK: ret void +// CHECK-NEXT: } + +// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.0.1" +// CHECK-NOT: !dbg +// CHECK: ret void +// CHECK-NEXT: } + +// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.0.2" +// CHECK-NOT: !dbg +// CHECK: ret void +// CHECK-NEXT: } diff --git a/test/IRGen/async/get_async_continuation.sil b/test/IRGen/async/get_async_continuation.sil index a132e11e375ba..211df650e4e97 100644 --- a/test/IRGen/async/get_async_continuation.sil +++ b/test/IRGen/async/get_async_continuation.sil @@ -69,11 +69,10 @@ bb0: // CHECK: {{musttail call swifttailcc|tail call swiftcc}} void @swift_continuation_await(ptr %0) // CHECK-NEXT: ret void -// CHECK: define {{.*}} void @async_continuation.0(ptr %0, ptr %1){{.*}}!dbg ![[DBG:[0-9]+]] +// CHECK: define {{.*}} void @async_continuation.0(ptr %0, ptr %1) // CHECK-NOT: define // CHECK: tail call swift{{(tail)?}}cc void %{{.*}}(ptr swiftasync %1) // CHECK-NEXT: ret void -// CHECK: ![[DBG]] = distinct !DISubprogram(linkageName: "async_continuation" sil @async_continuation : $@async () -> () { entry: From 35297b39a4cee50c590adfafe99d59c1f1f78f13 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 13 Aug 2024 13:43:35 -0700 Subject: [PATCH 083/110] [DebugInfo] Dont emit info for __swift_async_resume_project_context or __swift_async_resume_get_context Those functions are effectively outlined functions with an alwaysinline attribute. By removing their debug info and relying on the inliner to propagate the call site location to the inlined instructions, we restore the "original" locations as if the function had never been outlined. This is technically relying on an implementation detail of the inliner, but it seems to be the simplest way of addressing this issue. --- lib/IRGen/GenDecl.cpp | 2 +- lib/IRGen/GenFunc.cpp | 15 ++++++++------- lib/IRGen/IRGenFunction.h | 2 +- ...async-await-no-debug-info-outlined-funcs.swift | 10 ++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index d7b65ebbbf4a4..d9bf30adfebbb 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -3114,7 +3114,7 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) { // Index of swiftasync context | ((index of swiftself) << 8). arguments.push_back(IGM.getInt32(paramAttributeFlags)); arguments.push_back(currentResumeFn); - auto resumeProjFn = IGF.getOrCreateResumePrjFn(true /*forProlog*/); + auto resumeProjFn = IGF.getOrCreateResumePrjFn(); arguments.push_back( Builder.CreateBitOrPointerCast(resumeProjFn, IGM.Int8PtrTy)); auto dispatchFn = IGF.createAsyncDispatchFn( diff --git a/lib/IRGen/GenFunc.cpp b/lib/IRGen/GenFunc.cpp index 100669489ea7c..9449ed77b0c4a 100644 --- a/lib/IRGen/GenFunc.cpp +++ b/lib/IRGen/GenFunc.cpp @@ -2846,11 +2846,12 @@ IRGenFunction::emitAsyncResumeProjectContext(llvm::Value *calleeContext) { return callerContext; } -llvm::Function *IRGenFunction::getOrCreateResumePrjFn(bool forPrologue) { - // The prologue version lacks artificial debug info as this would cause - // verification errors when it gets inlined. - auto name = forPrologue ? "__swift_async_resume_project_context_prologue" - : "__swift_async_resume_project_context"; +llvm::Function *IRGenFunction::getOrCreateResumePrjFn() { + auto name = "__swift_async_resume_project_context"; + // This is effectively an outlined function with `alwaysinline`. Don't emit + // debug locations for those to avoid creating unnecessary inlined frames. + // Instead, rely on the inliner to propagate the call site debug location. + const bool skipDebugInfo = true; auto Fn = cast(IGM.getOrCreateHelperFunction( name, IGM.Int8PtrTy, {IGM.Int8PtrTy}, [&](IRGenFunction &IGF) { @@ -2860,7 +2861,7 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn(bool forPrologue) { auto callerContext = IGF.emitAsyncResumeProjectContext(addr); Builder.CreateRet(callerContext); }, - false /*isNoInline*/, forPrologue)); + false /*isNoInline*/, skipDebugInfo)); Fn->addFnAttr(llvm::Attribute::AlwaysInline); return Fn; } @@ -2955,7 +2956,7 @@ llvm::Function *IRGenFunction::getOrCreateResumeFromSuspensionFn() { auto &Builder = IGF.Builder; Builder.CreateRet(&*IGF.CurFn->arg_begin()); }, - false /*isNoInline*/)); + false /*isNoInline*/, true /*forPrologue*/)); fn->addFnAttr(llvm::Attribute::AlwaysInline); return fn; } diff --git a/lib/IRGen/IRGenFunction.h b/lib/IRGen/IRGenFunction.h index 869abd5bd330e..64e4e753bac0b 100644 --- a/lib/IRGen/IRGenFunction.h +++ b/lib/IRGen/IRGenFunction.h @@ -178,7 +178,7 @@ class IRGenFunction { bool restoreCurrentContext = true); llvm::Value *emitAsyncResumeProjectContext(llvm::Value *callerContextAddr); - llvm::Function *getOrCreateResumePrjFn(bool forPrologue = false); + llvm::Function *getOrCreateResumePrjFn(); llvm::Function *createAsyncDispatchFn(const FunctionPointer &fnPtr, ArrayRef args); llvm::Function *createAsyncDispatchFn(const FunctionPointer &fnPtr, diff --git a/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift b/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift index d84ea6e983783..2a267c909acc5 100644 --- a/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift +++ b/test/DebugInfo/async-await-no-debug-info-outlined-funcs.swift @@ -22,11 +22,21 @@ func ASYNC___2___() async -> Int { // CHECK: ret void // CHECK-NEXT: } +// CHECK-LABEL: define {{.*}} @__swift_async_resume_get_context +// CHECK-NOT: !dbg +// CHECK: ret ptr +// CHECK-NEXT: } + // CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.1" // CHECK-NOT: !dbg // CHECK: ret void // CHECK-NEXT: } +// CHECK-LABEL: define {{.*}} @__swift_async_resume_project_context +// CHECK-NOT: !dbg +// CHECK: ret ptr +// CHECK-NEXT: } + // CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.0" // CHECK-NOT: !dbg // CHECK: ret void From ed69cde535c5185573f57cac8b8a5868e427981d Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Thu, 15 Aug 2024 15:02:17 +0100 Subject: [PATCH 084/110] [StaticMirror] Add support for GLOB_DAT relocations. We need to support GLOB_DAT relocations to deal with indirect relative pointers that go via the GOT. rdar://133510292 --- lib/StaticMirror/ObjectFileContext.cpp | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/StaticMirror/ObjectFileContext.cpp b/lib/StaticMirror/ObjectFileContext.cpp index 060caaa27d265..397321d8254c1 100644 --- a/lib/StaticMirror/ObjectFileContext.cpp +++ b/lib/StaticMirror/ObjectFileContext.cpp @@ -114,6 +114,20 @@ void Image::scanMachO(const llvm::object::MachOObjectFile *O) { } } +// We only support these for AArch64, ARM and x86-64 at present +static uint32_t getELFGlobDatRelocationType(uint32_t machine) { + switch (machine) { + case llvm::ELF::EM_AARCH64: + return llvm::ELF::R_AARCH64_GLOB_DAT; + case llvm::ELF::EM_ARM: + return llvm::ELF::R_ARM_GLOB_DAT; + case llvm::ELF::EM_X86_64: + return llvm::ELF::R_X86_64_GLOB_DAT; + default: + return 0; + } +} + template void Image::scanELFType(const llvm::object::ELFObjectFile *O) { using namespace llvm::ELF; @@ -147,6 +161,7 @@ void Image::scanELFType(const llvm::object::ELFObjectFile *O) { auto machine = O->getELFFile().getHeader().e_machine; auto relativeRelocType = llvm::object::getELFRelativeRelocationType(machine); + auto globDatRelocType = getELFGlobDatRelocationType(machine); for (auto &S : static_cast(O) ->dynamic_relocation_sections()) { @@ -163,6 +178,28 @@ void Image::scanELFType(const llvm::object::ELFObjectFile *O) { continue; } + // `getRelocationResolver` doesn't handle GLOB_DAT relocations, so we + // also have to do that ourselves. + if (globDatRelocType && R.getType() == globDatRelocType) { + auto symbol = R.getSymbol(); + auto name = symbol->getName(); + if (!name) { + llvm::consumeError(name.takeError()); + continue; + } + + // On x86-64, this is just S, but on other architectures it is + // usually S + A. + uint64_t addend = 0; + if (isRela && machine != llvm::ELF::EM_X86_64) { + auto rela = O->getRela(R.getRawDataRefImpl()); + addend = rela->r_addend; + } + + DynamicRelocations.insert({R.getOffset(), {*name, addend}}); + continue; + } + if (!resolverSupports(R.getType())) continue; auto symbol = R.getSymbol(); From fc4f6480a86114e8696e700d132318a80261cc33 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Thu, 15 Aug 2024 16:31:17 +0100 Subject: [PATCH 085/110] [cxx-interop][rebranch] Do not crash for `static operator()` This fixes an assertion failure: ``` Assertion failed: (isInstance() && "No 'this' for static methods!"), function getThisType, file DeclCXX.cpp, line 2636. ``` Clang changed it's handling of member call expressions in https://github.com/llvm/llvm-project/commit/af4751738db89a142a8880c782d12d4201b222a8 causing the assertion to fail when synthesizing a forwarding function declaration for `static operator()`. rdar://133257179 --- lib/ClangImporter/SwiftDeclSynthesizer.cpp | 9 +++++++-- .../Cxx/class/protocol-conformance-typechecker.swift | 2 -- .../Cxx/operators/member-inline-module-interface.swift | 2 -- test/Interop/Cxx/operators/member-inline.swift | 2 -- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index b2fda3bb50c3a..ea172dd694b82 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -2137,6 +2137,11 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( thisExpr = conv.get(); } + auto memberExprTy = + (method->isStatic() && method->getOverloadedOperator() == + clang::OverloadedOperatorKind::OO_Call) + ? method->getType() + : clangCtx.BoundMemberTy; auto memberExpr = clangSema.BuildMemberExpr( thisExpr, /*isArrow=*/true, clang::SourceLocation(), clang::NestedNameSpecifierLoc(), clang::SourceLocation(), @@ -2144,7 +2149,7 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( clang::DeclAccessPair::make(const_cast(method), clang::AS_public), /*HadMultipleCandidates=*/false, method->getNameInfo(), - clangCtx.BoundMemberTy, clang::VK_PRValue, clang::OK_Ordinary); + memberExprTy, clang::VK_PRValue, clang::OK_Ordinary); llvm::SmallVector args; for (size_t i = 0; i < newMethod->getNumParams(); ++i) { auto *param = newMethod->getParamDecl(i); @@ -2155,7 +2160,7 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( clangCtx, param, false, type, clang::ExprValueKind::VK_LValue, clang::SourceLocation())); } - auto memberCall = clangSema.BuildCallToMemberFunction( + auto memberCall = clangSema.BuildCallExpr( nullptr, memberExpr, clang::SourceLocation(), args, clang::SourceLocation()); if (!memberCall.isUsable()) diff --git a/test/Interop/Cxx/class/protocol-conformance-typechecker.swift b/test/Interop/Cxx/class/protocol-conformance-typechecker.swift index b422382e8bba1..c12f77f26af85 100644 --- a/test/Interop/Cxx/class/protocol-conformance-typechecker.swift +++ b/test/Interop/Cxx/class/protocol-conformance-typechecker.swift @@ -1,5 +1,3 @@ -// REQUIRES: rdar133257179 - // Tests that a C++ class can conform to a Swift protocol. // RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-experimental-cxx-interop diff --git a/test/Interop/Cxx/operators/member-inline-module-interface.swift b/test/Interop/Cxx/operators/member-inline-module-interface.swift index 3842baeae7448..d5d454def2ffc 100644 --- a/test/Interop/Cxx/operators/member-inline-module-interface.swift +++ b/test/Interop/Cxx/operators/member-inline-module-interface.swift @@ -1,5 +1,3 @@ -// REQUIRES: rdar133257179 - // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=swift-5.9 | %FileCheck %s // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=swift-6 | %FileCheck %s // RUN: %target-swift-ide-test -print-module -module-to-print=MemberInline -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift | %FileCheck %s diff --git a/test/Interop/Cxx/operators/member-inline.swift b/test/Interop/Cxx/operators/member-inline.swift index 6724c7d1e2669..73540783ee53a 100644 --- a/test/Interop/Cxx/operators/member-inline.swift +++ b/test/Interop/Cxx/operators/member-inline.swift @@ -1,5 +1,3 @@ -// REQUIRES: rdar133257179 - // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=swift-5.9) // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=swift-6) // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -cxx-interoperability-mode=upcoming-swift) From ea5ed4888f80f3058705bb759db31590c79f417e Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 23 Aug 2024 12:26:42 -0700 Subject: [PATCH 086/110] [build-script] Remove python override Build script should just use what it is told to use. --- utils/build-script-impl | 3 --- 1 file changed, 3 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index a47a1b3331731..164684678c657 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -583,9 +583,6 @@ function set_build_options_for_host() { watchsimulator-* | \ xros-* | \ xrsimulator-*) - swift_cmake_options+=( - -DPython3_EXECUTABLE="$(xcrun -f python3)" - ) case ${host} in macosx-x86_64) SWIFT_HOST_TRIPLE="x86_64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}" From b2ea8897216e1d41b8641a7751766afc600f061a Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Thu, 5 Sep 2024 16:15:37 -0700 Subject: [PATCH 087/110] [ScanDependency] Use `-fsyntax-only` to scan clang module dependencies Use `-fsyntax-only` action to scan clang module dependencies instead of `-c` option. This fixes a non-deterministic output on windows from scan-dependency output because `-c` implies it needs a temporary object file in the cc1 arguments that makes the pcm compilation command different every run. This can also make the `-Xcc` commands for PCM compilation simpler and more likely to be deduplicated by build system. rdar://135319536 --- lib/ClangImporter/ClangModuleDependencyScanner.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/ClangImporter/ClangModuleDependencyScanner.cpp b/lib/ClangImporter/ClangModuleDependencyScanner.cpp index 514c0ca9ac22b..78084812e75a3 100644 --- a/lib/ClangImporter/ClangModuleDependencyScanner.cpp +++ b/lib/ClangImporter/ClangModuleDependencyScanner.cpp @@ -113,14 +113,10 @@ static std::vector getClangDepScanningInvocationArguments( commandLineArgs.erase(moduleFormatPos-1, moduleFormatPos+1); } - // HACK: No -fsyntax-only here? - { - auto syntaxOnlyPos = std::find(commandLineArgs.begin(), - commandLineArgs.end(), - "-fsyntax-only"); - assert(syntaxOnlyPos != commandLineArgs.end()); - *syntaxOnlyPos = "-c"; - } + // Use `-fsyntax-only` to do dependency scanning and assert if not there. + assert(std::find(commandLineArgs.begin(), commandLineArgs.end(), + "-fsyntax-only") != commandLineArgs.end() && + "missing -fsyntax-only option"); // The Clang modules produced by ClangImporter are always embedded in an // ObjectFilePCHContainer and contain -gmodules debug info. From d04c736c753624b1b7249f808da6f64431d981a2 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Thu, 5 Sep 2024 09:27:20 -0700 Subject: [PATCH 088/110] [rebranch] Fix test/IRGen/async/class_resilience.swift on Windows Less/no constant folding is happening. --- test/IRGen/async/class_resilience.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/IRGen/async/class_resilience.swift b/test/IRGen/async/class_resilience.swift index 77857cbf8e7ad..b4d0f46674fe0 100644 --- a/test/IRGen/async/class_resilience.swift +++ b/test/IRGen/async/class_resilience.swift @@ -43,10 +43,13 @@ open class MyBaseClass { // CHECK-LABEL: define {{(dllexport )?}}{{(protected )?}}swift{{(tail)?}}cc void @"$s16class_resilience14callsAwaitableyx010resilient_A09BaseClassCyxGYalF"(ptr noalias %0, ptr swiftasync %1{{.*}}) // CHECK-DIRECT: ptr @"$s15resilient_class9BaseClassC4waitxyYaFTjTu" -// CHECK-INDIRECT: [[LOAD:%[0-9]+]] = load ptr, ptr inttoptr (i64 and (i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1), i64 -2) to ptr), align {{4|8}} -// CHECK-INDIRECT-NEXT: select i1 icmp eq (i64 and (i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1), i64 1), i64 0), -// CHECK-INDIRECT-SAME: ptr inttoptr (i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1) to ptr), -// CHECK-INDIRECT-SAME: ptr [[LOAD]] + +// CHECK-INDIRECT:[[T0:%.*]] = and i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1), 1 +// CHECK-INDIRECT:[[T1:%.*]] = icmp eq i64 [[T0]], 0 +// CHECK-INDIRECT:[[T2:%.*]] = and i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1), -2 +// CHECK-INDIRECT:[[T3:%.*]] = inttoptr i64 [[T2]] to ptr +// CHECK-INDIRECT:[[T4:%.*]] = load ptr, ptr [[T3]] +// CHECK-INDIRECT:[[T5:%.*]] = select i1 [[T1]], ptr inttoptr (i64 add (i64 ptrtoint (ptr @"\01__imp_$s15resilient_class9BaseClassC4waitxyYaFTjTu" to i64), i64 1) to ptr), ptr [[T4]] // CHECK: ret void public func callsAwaitable(_ c: BaseClass) async -> T { return await c.wait() From 0acfda8f6c8eaa47b63ac822ca3657e9e6ab7294 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Fri, 6 Sep 2024 12:06:01 -0700 Subject: [PATCH 089/110] [rebranch] Fix test/IRGen/async/protocol_resilience.swift --- test/IRGen/async/protocol_resilience.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/IRGen/async/protocol_resilience.swift b/test/IRGen/async/protocol_resilience.swift index c91a7d61297cb..e9aeee6cfaa94 100644 --- a/test/IRGen/async/protocol_resilience.swift +++ b/test/IRGen/async/protocol_resilience.swift @@ -28,10 +28,12 @@ public protocol MyAwaitable { // CHECK-LABEL: define {{(dllexport )?}}{{(protected )?}}swift{{(tail)?}}cc void @"$s19protocol_resilience14callsAwaitabley6ResultQzxYa010resilient_A00D0RzlF"(ptr noalias %0, ptr swiftasync %1, ptr noalias %2, ptr %T, ptr %T.Awaitable) // CHECK-DIRECT: ptr @"$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" -// CHECK-INDIRECT: [[LOAD:%[0-9]+]] = load ptr, ptr inttoptr (i64 and (i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1), i64 -2) to ptr), align {{4|8}} -// CHECK-INDIRECT: select i1 icmp eq (i64 and (i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1), i64 1), i64 0), -// CHECK-INDIRECT-SAME: ptr inttoptr (i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1) to ptr), -// CHECK-INDIRECT-SAME: ptr [[LOAD]] +// CHECK-INDIRECT: [[TMP4:%.*]] = and i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1), 1 +// CHECK-INDIRECT: [[TMP5:%.*]] = icmp eq i64 [[TMP4]], 0 +// CHECK-INDIRECT: [[TMP6:%.*]] = and i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1), -2 +// CHECK-INDIRECT: [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr +// CHECK-INDIRECT: [[TMP8:%.*]] = load ptr, ptr [[TMP7]], align 8 +// CHECK-INDIRECT: select i1 [[TMP5]], ptr inttoptr (i64 add (i64 ptrtoint (ptr @"\01__imp_$s18resilient_protocol9AwaitableP4wait6ResultQzyYaFTjTu" to i64), i64 1) to ptr), ptr [[TMP8]] // CHECK: ret void public func callsAwaitable(_ t: T) async -> T.Result { return await t.wait() From 0e57d02e5dd5485295b2b2260404edee23297b94 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Mon, 9 Sep 2024 17:51:51 +0100 Subject: [PATCH 090/110] [cxx-interop][rebranch] Fix test on Windows rdar://135318900 --- test/Interop/Cxx/operators/member-out-of-line-irgen.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Interop/Cxx/operators/member-out-of-line-irgen.swift b/test/Interop/Cxx/operators/member-out-of-line-irgen.swift index a283f348f783a..7220507eb583e 100644 --- a/test/Interop/Cxx/operators/member-out-of-line-irgen.swift +++ b/test/Interop/Cxx/operators/member-out-of-line-irgen.swift @@ -8,4 +8,4 @@ public func add(_ lhs: inout LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> L // CHECK-SYSV: declare {{.*}}{{i32|i64}} [[NAME]](ptr {{.*}}, {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* .*byval\(%struct.LoadableIntWrapper\)}}{{.*}}) // CHECK-WIN: call void [[NAME:@"\?\?HLoadableIntWrapper@@QEBA\?AU0@U0@@Z"]](ptr %{{[0-9]+}}, ptr sret(%struct.LoadableIntWrapper) {{.*}}, i32 %{{[0-9]+}}) -// CHECK-WIN: declare dso_local void [[NAME]](ptr {{.*}}, ptr sret(%struct.LoadableIntWrapper) {{.*}}, i32) +// CHECK-WIN: declare dso_local void [[NAME]](ptr {{.*}}, ptr {{.*}} sret(%struct.LoadableIntWrapper) {{.*}}, i32) From 9bc2689ef157497ad2e60ee0db91b40946f749f0 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Tue, 10 Sep 2024 09:37:07 -0700 Subject: [PATCH 091/110] [rebranch][cxx-interop] fix MSVC testcase check line for indirect return --- .../method/methods-this-and-indirect-return-irgen-msvc.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-msvc.swift b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-msvc.swift index 29c8bf3528c75..0a15683aec064 100644 --- a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-msvc.swift +++ b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-msvc.swift @@ -15,5 +15,5 @@ public func use() -> CInt { // CHECK-x86_64: call void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr %[[instance]], ptr noalias sret(%TSo19NonTrivialInWrapperV) %[[result]], i32 42) // CHECK-aarch64: call void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr %[[instance]], ptr inreg noalias sret(%TSo19NonTrivialInWrapperV) %[[result]], i32 42) -// CHECK-x86_64: define {{.*}} void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr {{.*}} %{{.*}}, ptr noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, i32 noundef %{{.*}}) -// CHECK-aarch64: define {{.*}} void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr {{.*}} %{{.*}}, ptr inreg noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, i32 noundef %{{.*}}) +// CHECK-x86_64: define {{.*}} void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr {{.*}} %{{.*}}, ptr {{.*}} sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, i32 noundef %{{.*}}) +// CHECK-aarch64: define {{.*}} void @"?nonConstPassThroughAsWrapper@HasMethods@@QEAA?AUNonTrivialInWrapper@@H@Z"(ptr {{.*}} %{{.*}}, ptr {{.*}}inreg {{.*}} sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, i32 noundef %{{.*}}) From b14e8f0679c3b2d1ab3ca350db87551db5590562 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Tue, 10 Sep 2024 13:54:50 -0700 Subject: [PATCH 092/110] Fixup swift tests for DIExpression folding in Corosplit The support for DIExpression constant folding has been added to the Corosplit pass, this patch fixes up the swift tests that need to account for the changes in the DIExpressions. --- test/DebugInfo/async-args.swift | 4 +- test/DebugInfo/async-let-await.swift | 2 +- .../move_function_dbginfo_async.swift | 86 +++++++++---------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/test/DebugInfo/async-args.swift b/test/DebugInfo/async-args.swift index fe5b4f1d7c81f..5ee89f3bfe7b5 100644 --- a/test/DebugInfo/async-args.swift +++ b/test/DebugInfo/async-args.swift @@ -16,8 +16,8 @@ func withGenericArg(_ msg: T) async { await forceSplit() // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalFTQ0_"(ptr swiftasync %0) - // CHECK-DAG: #dbg_declare(ptr %0, ![[MSG_R:[0-9]+]], !DIExpression({{.*}}DW_OP_plus_uconst, [[OFFSET:[0-9]+]], DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref), - // CHECK-DAG: #dbg_declare(ptr %0, ![[TAU_R:[0-9]+]], !DIExpression({{.*}}DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]], DW_OP_plus_uconst, {{[0-9]+}}), + // CHECK-DAG: #dbg_declare(ptr %0, ![[MSG_R:[0-9]+]], !DIExpression({{.*}}DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref), + // CHECK-DAG: #dbg_declare(ptr %0, ![[TAU_R:[0-9]+]], !DIExpression({{.*}}DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}), use(msg) } // CHECK-LABEL: {{^define }} diff --git a/test/DebugInfo/async-let-await.swift b/test/DebugInfo/async-let-await.swift index 8746820b7f6e5..2577a84b9ca86 100644 --- a/test/DebugInfo/async-let-await.swift +++ b/test/DebugInfo/async-let-await.swift @@ -13,7 +13,7 @@ public func getVegetables() async -> [String] { public func chopVegetables() async throws -> [String] { let veggies = await getVegetables() // CHECK-NOT: {{^define }} - // CHECK: #dbg_declare(ptr %0, ![[V:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_plus_uconst, {{[0-9]+}}) + // CHECK: #dbg_declare(ptr %0, ![[V:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}) // CHECK: ![[V]] = !DILocalVariable(name: "veggies" return veggies.map { "chopped \($0)" } } diff --git a/test/DebugInfo/move_function_dbginfo_async.swift b/test/DebugInfo/move_function_dbginfo_async.swift index b2f9f315da74b..454e2bc3f1c9e 100644 --- a/test/DebugInfo/move_function_dbginfo_async.swift +++ b/test/DebugInfo/move_function_dbginfo_async.swift @@ -45,19 +45,19 @@ public func forceSplit5() async {} // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalF"(ptr swiftasync %0, ptr noalias %1, ptr %T) // CHECK: entry: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalFTQ0_"(ptr swiftasync %0) // CHECK: entryresume.0: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_2:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_2:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13letSimpleTestyyxnYalFTY1_"(ptr swiftasync %0) // CHECK: entryresume.1: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_3:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[SIMPLE_TEST_METADATA_3:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[SIMPLE_TEST_METADATA_3]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void // CHECK-NEXT: ret void @@ -73,7 +73,7 @@ public func forceSplit5() async {} // DWARF2: DW_AT_linkage_name ("$s3out13letSimpleTestyyxnYalFTQ0_") // DWARF2: DW_AT_name ("letSimpleTest") // DWARF2: DW_TAG_formal_parameter -// DWARF2-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:DW_OP_.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF2-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:DW_OP_.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref) // DWARF2-NEXT: DW_AT_name ("msg") // @@ -82,7 +82,7 @@ public func forceSplit5() async {} // DWARF3: DW_AT_name ("letSimpleTest") // DWARF3: DW_TAG_formal_parameter // DWARF3: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF3-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF3-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref) // DWARF3-NEXT: DW_AT_name ("msg") public func letSimpleTest(_ msg: __owned T) async { await forceSplit() @@ -90,21 +90,21 @@ public func letSimpleTest(_ msg: __owned T) async { } // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalF"(ptr swiftasync %0, ptr %1, ptr noalias %2, ptr %T) -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref) // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"(ptr swiftasync %{{[0-9]+}}) // CHECK-NEXT: ret void // CHECK-NEXT: } // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTQ0_"(ptr swiftasync %0) // CHECK: entryresume.0: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref) // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_", i64 0, i64 0) // CHECK-NEXT: ret void // CHECK-NEXT: } // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_"(ptr swiftasync %0) // CHECK: entryresume.1: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"(ptr swiftasync // CHECK-NEXT: ret void @@ -115,9 +115,9 @@ public func letSimpleTest(_ msg: __owned T) async { // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY3_"(ptr swiftasync %0) // CHECK: entryresume.3: -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async10forceSplityyYaF"( // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -134,7 +134,7 @@ public func letSimpleTest(_ msg: __owned T) async { // DWARF5: DW_AT_linkage_name ("$s3out13varSimpleTestyyxz_xtYalFTQ0_") // DWARF5: DW_AT_name ("varSimpleTest") // DWARF5: DW_TAG_formal_parameter -// DWARF5-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF5-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref) // DWARF5-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out13varSimpleTestyyxz_xtYalFTY1_' %t/out.o | %FileCheck -check-prefix=DWARF6 %s @@ -142,7 +142,7 @@ public func letSimpleTest(_ msg: __owned T) async { // DWARF6: DW_AT_name ("varSimpleTest") // DWARF6: DW_TAG_formal_parameter // DWARF6-NEXT: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF6-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF6-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref) // DWARF6-NEXT: DW_AT_name ("msg") // // We were just moved and are not reinit yet. This is caused by us hopping twice @@ -166,9 +166,9 @@ public func letSimpleTest(_ msg: __owned T) async { // DWARF8: DW_TAG_formal_parameter // DWARF8: DW_AT_location (0x{{[a-f0-9]+}}: // DWARF8-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): -// DWARF8-SAME: DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref +// DWARF8-SAME: DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref // DWARF8-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): -// DWARF8-SAME: DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x[[MSG_LOC]], DW_OP_plus_uconst 0x8, DW_OP_deref +// DWARF8-SAME: DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x[[MSG_LOC]], DW_OP_deref // DWARF8-NEXT: DW_AT_name ("msg") // // We did not consume the value again here, so we just get a normal entry value for @@ -178,14 +178,14 @@ public func letSimpleTest(_ msg: __owned T) async { // DWARF9: DW_AT_linkage_name ("$s3out13varSimpleTestyyxz_xtYalFTQ4_") // DWARF9: DW_AT_name ("varSimpleTest") // DWARF9: DW_TAG_formal_parameter -// DWARF9-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF9-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x[[MSG_LOC:[a-f0-9]+]], DW_OP_deref) // DWARF9-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out13varSimpleTestyyxz_xtYalFTY5_' %t/out.o | %FileCheck -check-prefix=DWARF10 %s // DWARF10: DW_AT_linkage_name ("$s3out13varSimpleTestyyxz_xtYalFTY5_") // DWARF10: DW_AT_name ("varSimpleTest") // DWARF10: DW_TAG_formal_parameter -// DWARF10-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8, DW_OP_deref +// DWARF10-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x18, DW_OP_deref // DWARF10-NEXT: DW_AT_name ("msg") // Change name to varSimpleTestArg @@ -202,13 +202,13 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaF"(ptr swiftasync %0) // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY0_"(ptr swiftasync %0) -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref) // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTQ1_"(ptr swiftasync %0) -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24, DW_OP_deref) // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY2_"(ptr swiftasync %0) -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(), ![[ADDR_LOC]] // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTQ3_"(ptr swiftasync %0) @@ -219,7 +219,7 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async16varSimpleTestVaryyYaFTY4_"(ptr swiftasync %0) // CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(), ![[ADDR_LOC:[0-9]+]] -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref), ![[ADDR_LOC]] // We are not an argument, so no problem here. // @@ -230,7 +230,7 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // DWARF12: DW_AT_linkage_name ("$s3out16varSimpleTestVaryyYaFTY0_") // // DWARF12: DW_TAG_variable -// DWARF12-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8) +// DWARF12-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x18) // DWARF12-NEXT: DW_AT_name ("k") // // MISSING-DWARF12: DW_TAG_variable @@ -241,7 +241,7 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // DWARF13: DW_AT_linkage_name ("$s3out16varSimpleTestVaryyYaFTQ1_") // // DWARF13: DW_TAG_variable -// DWARF13-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8) +// DWARF13-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x18) // DWARF13-NEXT: DW_AT_name ("k") // // MISSING-DWARF13: DW_TAG_variable @@ -254,7 +254,7 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // DWARF14: DW_AT_linkage_name ("$s3out16varSimpleTestVaryyYaFTY2_") // DWARF14: DW_TAG_variable // DWARF14-NEXT: DW_AT_location (0x{{[0-9a-f]+}}: -// DWARF14-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8) +// DWARF14-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x18) // DWARF14-NEXT: DW_AT_name ("k") // DWARF14: DW_TAG_variable // DWARF14-NEXT: DW_AT_location @@ -281,7 +281,7 @@ public func varSimpleTest(_ msg: inout T, _ msg2: T) async { // MISSING-DWARF16-NEXT: DW_AT_name ("m") // DWARF16: DW_TAG_variable // DWARF16-NEXT: DW_AT_location (0x{{[0-9a-f]+}}: -// DWARF16-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8) +// DWARF16-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x18) // DWARF16-NEXT: DW_AT_name ("k") public func varSimpleTestVar() async { var k = Klass() @@ -306,13 +306,13 @@ public func varSimpleTestVar() async { // CHECK-NEXT: } // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ0_"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTY1_", i64 0, i64 0) // CHECK-NEXT: ret void // CHECK-NEXT: } // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTY1_"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]*]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]*]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]*]] // CHECK: br i1 %{{[0-9]}}, label %[[LHS_BLOCK:[a-zA-Z\.0-9]*]], label %[[RHS_BLOCK:[a-zA-Z\.0-9]*]], // // CHECK: [[LHS_BLOCK]]: @@ -338,7 +338,7 @@ public func varSimpleTestVar() async { // This is the false branch. // // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20letArgCCFlowTrueTestyyxnYalFTQ3_"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[msg_var:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_deref) +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[msg_var:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref) // CHECK-NEXT: #dbg_value(ptr undef, ![[msg_var]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-NEXT: ret void, @@ -362,7 +362,7 @@ public func varSimpleTestVar() async { // DWARF18: DW_AT_linkage_name ("$s3out20letArgCCFlowTrueTestyyxnYalFTQ0_") // DWARF18-NEXT: DW_AT_name ("letArgCCFlowTrueTest") // DWARF18: DW_TAG_formal_parameter -// DWARF18-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF18-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x18, DW_OP_deref) // DWARF18-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20letArgCCFlowTrueTestyyxnYalFTY1_' %t/out.o | %FileCheck -check-prefix=DWARF19 %s @@ -370,8 +370,8 @@ public func varSimpleTestVar() async { // DWARF19-NEXT: DW_AT_name ("letArgCCFlowTrueTest") // DWARF19: DW_TAG_formal_parameter // DWARF19-NEXT: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF19-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8, DW_OP_deref -// DWARF19-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8, DW_OP_deref) +// DWARF19-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x18, DW_OP_deref +// DWARF19-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x18, DW_OP_deref) // DWARF19-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20letArgCCFlowTrueTestyyxnYalFTQ2_' %t/out.o | %FileCheck -check-prefix=DWARF20 %s @@ -440,14 +440,14 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // SIL: } // end sil function '$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlF' // CHECK-LABEL: define swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlF"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit1yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ0_"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY1_"( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: br i1 %{{[0-9]+}}, label %[[LHS_BLOCK:[a-zA-Z0-9]+]], label %[[RHS_BLOCK:[a-zA-Z0-9]+]] // CHECK: [[LHS_BLOCK]]: @@ -464,24 +464,24 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY3_"( // CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ4_"( // CHECK-NOT: #dbg_value -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @swift_task_switch(ptr swiftasync %{{[0-9]+}}, ptr @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY5_", // CHECK: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY5_"( // CHECK: #dbg_value(ptr undef, ![[METADATA:[0-9]+]], !DIExpression(DW_OP_deref), ![[ADDR_LOC:[0-9]+]] // CHECK: #dbg_value(ptr undef, ![[METADATA]], !DIExpression(DW_OP_deref), ![[ADDR_LOC]] -// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] +// CHECK: #dbg_value(ptr %{{[0-9]+}}, ![[METADATA]], !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), ![[ADDR_LOC]] // CHECK: musttail call swifttailcc void @"$s27move_function_dbginfo_async11forceSplit4yyYaF"( // CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ6_"( // CHECK-NOT: #dbg_value( -// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_deref), +// CHECK: #dbg_value(ptr %{{[0-9]+}}, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_deref), // CHECK-NOT: #dbg_value( // CHECK: musttail call swifttailcc void %{{[0-9]+}}(ptr swiftasync // CHECK-NEXT: ret void, @@ -500,7 +500,7 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // DWARF25: DW_AT_linkage_name ("$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ0_") // DWARF25-NEXT: DW_AT_name ("varArgCCFlowTrueTest") // DWARF25: DW_TAG_formal_parameter -// DWARF25-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref) +// DWARF25-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x40, DW_OP_deref) // DWARF25-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTY1_' %t/out.o | %FileCheck -check-prefix=DWARF26 %s @@ -508,8 +508,8 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // DWARF26-NEXT: DW_AT_name ("varArgCCFlowTrueTest") // DWARF26: DW_TAG_formal_parameter // DWARF26-NEXT: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF26-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref -// DWARF26-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref) +// DWARF26-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x40, DW_OP_deref +// DWARF26-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG]]), DW_OP_plus_uconst 0x40, DW_OP_deref) // DWARF26-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ2_' %t/out.o | %FileCheck -check-prefix=DWARF27 %s @@ -523,7 +523,7 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // DWARF28-NEXT: DW_AT_name ("varArgCCFlowTrueTest") // DWARF28: DW_TAG_formal_parameter // DWARF28-NEXT: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF28-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref) +// DWARF28-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x40, DW_OP_deref) // DWARF28-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ4_' %t/out.o | %FileCheck -check-prefix=DWARF29 %s @@ -537,14 +537,14 @@ public func letArgCCFlowTrueTest(_ msg: __owned T) async { // DWARF30-NEXT: DW_AT_name ("varArgCCFlowTrueTest") // DWARF30: DW_TAG_formal_parameter // DWARF30-NEXT: DW_AT_location (0x{{[a-f0-9]+}}: -// DWARF30-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref) +// DWARF30-NEXT: [0x{{[a-f0-9]+}}, 0x{{[a-f0-9]+}}): DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_plus_uconst 0x40, DW_OP_deref) // DWARF30-NEXT: DW_AT_name ("msg") // // RUN: %llvm-dwarfdump -c --name='$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ6_' %t/out.o | %FileCheck -check-prefix=DWARF31 %s // DWARF31: DW_AT_linkage_name ("$s3out20varArgCCFlowTrueTestyyxzYaAA1PRzlFTQ6_") // DWARF31-NEXT: DW_AT_name ("varArgCCFlowTrueTest") // DWARF31: DW_TAG_formal_parameter -// DWARF31-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x30, DW_OP_deref) +// DWARF31-NEXT: DW_AT_location (DW_OP_entry_value([[ASYNC_REG:.*]]), DW_OP_deref, DW_OP_plus_uconst 0x40, DW_OP_deref) // DWARF31-NEXT: DW_AT_name ("msg") public func varArgCCFlowTrueTest(_ msg: inout T) async { await forceSplit1() From 58bbadd28ea916406d29ca9973a9c5037485a701 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 13 Sep 2024 08:51:24 -0700 Subject: [PATCH 093/110] [DebugInfo] Dont generate line information at the split point of async funclets Unless there is some meaningful code on the same line as an await call (e.g. other parts of an expression), there should be no additional line entries associated with that line on the continuation funclet. This patch changes codegen to avoid emitting debug location for the "prologue" code at the start of a funclet, instead of simply copying the debug location of the split point. --- lib/IRGen/GenCall.cpp | 4 ++++ ...wait-no-debug-info-after-split-point.swift | 24 +++++++++++++++++++ test/DebugInfo/async-let.swift | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/DebugInfo/async-await-no-debug-info-after-split-point.swift diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 394f53a924a47..d26c594f9b64d 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -50,6 +50,7 @@ #include "GenPoly.h" #include "GenProto.h" #include "GenType.h" +#include "IRGenDebugInfo.h" #include "IRGenFunction.h" #include "IRGenModule.h" #include "LoadableTypeInfo.h" @@ -219,6 +220,9 @@ llvm::CallInst *IRGenFunction::emitSuspendAsyncCall( auto *id = Builder.CreateIntrinsicCall(llvm::Intrinsic::coro_suspend_async, {resultTy}, args); if (restoreCurrentContext) { + // This is setup code after the split point. Don't associate any line + // numbers to it. + irgen::PrologueLocation LocRAII(IGM.DebugInfo.get(), Builder); llvm::Value *calleeContext = Builder.CreateExtractValue(id, asyncContextIndex); calleeContext = diff --git a/test/DebugInfo/async-await-no-debug-info-after-split-point.swift b/test/DebugInfo/async-await-no-debug-info-after-split-point.swift new file mode 100644 index 0000000000000..c85fa8b4c5157 --- /dev/null +++ b/test/DebugInfo/async-await-no-debug-info-after-split-point.swift @@ -0,0 +1,24 @@ +// RUN: %target-swift-frontend %s -emit-irgen -g -o - \ +// RUN: -module-name M -disable-availability-checking \ +// RUN: -parse-as-library | %FileCheck %s --check-prefix=CHECK + +// REQUIRES: concurrency + + +func ASYNC___1___() async -> Int { + return 42 +} + +// Check that the first debug location after a split point is for the line +// _after_ the await. + +// CHECK: define {{.*}} @"$s1M12ASYNC___2___SiyYaF" +func ASYNC___2___() async -> Int { + var x = 10 + await ASYNC___1___() + // CHECK: call {{.*}} @llvm.coro.suspend.async{{.*}} ptr @__swift_async_resume_get_context{{.*}} !dbg + // CHECK: !dbg ![[FirstDbg:[0-9]+]] + // CHECK: ![[FirstDbg]] = !DILocation(line: [[@LINE+1]] + x = 12 + return x +} diff --git a/test/DebugInfo/async-let.swift b/test/DebugInfo/async-let.swift index 835f3a23260c4..39ba5f5368e88 100644 --- a/test/DebugInfo/async-let.swift +++ b/test/DebugInfo/async-let.swift @@ -8,7 +8,7 @@ public actor Alice { let bob = Bob() // CHECK: define {{.*}}$s1M5AliceC4callyyYaFTY0_{{.*}} !dbg ![[SCOPE0:[0-9]+]] - // CHECK: load ptr, ptr {{.*}} !dbg ![[HOP0:[0-9]+]] + // CHECK: asyncLet_begin{{.*}} !dbg ![[HOP0:[0-9]+]] // CHECK: define {{.*}}$s1M5AliceC4callyyYaFTY1_{{.*}} !dbg ![[SCOPE1:[0-9]+]] // CHECK: load ptr, ptr {{.*}} !dbg ![[HOP1:[0-9]+]] @@ -20,7 +20,7 @@ public actor Alice { // CHECK: load ptr, ptr {{.*}} !dbg ![[LET_HOP1:[0-9]+]] public func call() async { // CHECK: ![[SCOPE0]] = distinct !DISubprogram({{.*}}line: [[@LINE-1]] - // CHECK: ![[HOP0]] = !DILocation(line: [[@LINE-2]], column: 15 + // CHECK: ![[HOP0]] = !DILocation(line: [[@LINE+1]], column: 11 async let a = bob.call(x: 1) // CHECK: ![[SCOPE1]] = distinct !DISubprogram({{.*}}line: [[@LINE-4]] // CHECK: ![[HOP1]] = !DILocation(line: [[@LINE+5]], column: 17 From 565645723d14dcf3f6131bf7b4d339aacc1153e5 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 16 Sep 2024 16:18:12 -0700 Subject: [PATCH 094/110] [rebranch] Add another missing `llvm/IR/Module.h` include More `Module.h`. --- lib/LLVMPasses/LLVMEmitAsyncEntryReturnMetadata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/LLVMPasses/LLVMEmitAsyncEntryReturnMetadata.cpp b/lib/LLVMPasses/LLVMEmitAsyncEntryReturnMetadata.cpp index 11c596ef34bd0..e970ae6faebbb 100644 --- a/lib/LLVMPasses/LLVMEmitAsyncEntryReturnMetadata.cpp +++ b/lib/LLVMPasses/LLVMEmitAsyncEntryReturnMetadata.cpp @@ -4,6 +4,7 @@ #include "swift/LLVMPasses/Passes.h" #include "llvm/Pass.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/Module.h" #include "llvm/Transforms/Utils/ModuleUtils.h" using namespace llvm; From 623540b53bbd9160a7dc1c75b33b467cb95206f5 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Wed, 18 Sep 2024 14:56:08 +0100 Subject: [PATCH 095/110] [cxx-interop][rebranch] Re-enable an APINotes test This was resolved by https://github.com/swiftlang/llvm-project/pull/9251. rdar://127262612 --- test/ClangImporter/enum-renames.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/ClangImporter/enum-renames.swift b/test/ClangImporter/enum-renames.swift index 4f32b60eee022..9557b7be6ec36 100644 --- a/test/ClangImporter/enum-renames.swift +++ b/test/ClangImporter/enum-renames.swift @@ -1,5 +1,3 @@ -// REQUIRES: rdar127262612 - // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify import enums_using_attributes From efe1c978249f90a9c80424fc5c926d9407dbf498 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 11 Sep 2024 16:56:28 -0700 Subject: [PATCH 096/110] [Basic] Update `moveFileIfDifferent` tests to not rely on `getUniqueID` These tests were relying on specifics of `getUniqueID` that aren't necessarily true - namely that moving a file from `source` to `dest` doesn't change the returned ID. They are really just testing `moveFileIfDifferent`, which doesn't need to make this assumption. --- unittests/Basic/FileSystemTest.cpp | 263 ++++++++++++++++------------- 1 file changed, 144 insertions(+), 119 deletions(-) diff --git a/unittests/Basic/FileSystemTest.cpp b/unittests/Basic/FileSystemTest.cpp index 82c1667bd8047..e20be8b5710b3 100644 --- a/unittests/Basic/FileSystemTest.cpp +++ b/unittests/Basic/FileSystemTest.cpp @@ -15,8 +15,11 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" +#include + #define ASSERT_NO_ERROR(x) \ do if (std::error_code ASSERT_NO_ERROR_ec = x) { \ llvm::errs() << #x ": did not return errc::success.\n" \ @@ -29,87 +32,102 @@ using namespace llvm::sys; using namespace swift; namespace { + +std::string getFileContents(llvm::StringRef path) { + auto fs = llvm::vfs::getRealFileSystem(); + auto file = fs->openFileForRead(path); + if (!file) + return ""; + + auto buffer = (*file)->getBuffer(""); + if (!buffer) + return ""; + + return (*buffer)->getBuffer().str(); +} + TEST(FileSystem, MoveFileIfDifferentEmpty) { // Create unique temporary directory for these tests llvm::SmallString<128> dirPath; ASSERT_NO_ERROR(fs::createUniqueDirectory("FileSystem-test", dirPath)); - // Test 1: Move empty over nonexistent. llvm::SmallString<128> sourceFile = dirPath; path::append(sourceFile, "source.txt"); - { - std::error_code error; - llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); - } - - fs::UniqueID origID; - ASSERT_NO_ERROR(fs::getUniqueID(sourceFile, origID)); llvm::SmallString<128> destFile = dirPath; path::append(destFile, "dest.txt"); - ASSERT_FALSE(fs::exists(destFile)); - - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); - - fs::UniqueID destID; - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(origID, destID); - - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); - // Test 2: Move empty over empty. + // Test 1: Move empty over nonexistent. { - std::error_code error; - llvm::raw_fd_ostream emptyOut(destFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); + { + std::error_code error; + llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + } + ASSERT_FALSE(fs::exists(destFile)); + + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); + + ASSERT_NO_ERROR(fs::remove(destFile, false)); } - fs::UniqueID newID; - ASSERT_NO_ERROR(fs::getUniqueID(destFile, newID)); - ASSERT_NE(origID, newID); + // Test 2: Move empty over empty. + { + { + std::error_code error; + llvm::raw_fd_ostream emptySource(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); + llvm::raw_fd_ostream emptyDest(destFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + } - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(newID, destID); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); - origID = destID; + ASSERT_NO_ERROR(fs::remove(destFile, false)); + } // Test 3: Move empty over non-empty. { - std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); - nonEmptyOut << "a"; - } + { + std::error_code error; + llvm::raw_fd_ostream emptySource(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + + llvm::raw_fd_ostream dest(destFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + dest << "a"; + } - ASSERT_NO_ERROR(fs::getUniqueID(destFile, newID)); - ASSERT_NE(origID, newID); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); + ASSERT_EQ(getFileContents(destFile), ""); - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(origID, destID); + ASSERT_NO_ERROR(fs::remove(destFile, false)); + } + + // Test 4: Move over self. + { + { + std::error_code error; + llvm::raw_fd_ostream emptySource(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + } - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); - // Test 4: Move empty over self. - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, sourceFile)); - ASSERT_TRUE(fs::exists(sourceFile)); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, sourceFile)); + ASSERT_TRUE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(fs::getUniqueID(sourceFile, newID)); - ASSERT_EQ(origID, newID); + ASSERT_NO_ERROR(fs::remove(sourceFile, false)); + } // Clean up. - ASSERT_NO_ERROR(fs::remove(sourceFile, false)); ASSERT_NO_ERROR(fs::remove(dirPath, false)); } @@ -118,103 +136,110 @@ TEST(FileSystem, MoveFileIfDifferentNonEmpty) { llvm::SmallString<128> dirPath; ASSERT_NO_ERROR(fs::createUniqueDirectory("FileSystem-test", dirPath)); - // Test 1: Move source over nonexistent. llvm::SmallString<128> sourceFile = dirPath; path::append(sourceFile, "source.txt"); - { - std::error_code error; - llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); - sourceOut << "original"; - ASSERT_NO_ERROR(error); - } - - fs::UniqueID origID; - ASSERT_NO_ERROR(fs::getUniqueID(sourceFile, origID)); llvm::SmallString<128> destFile = dirPath; path::append(destFile, "dest.txt"); - ASSERT_FALSE(fs::exists(destFile)); - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); + // Test 1: Move source over nonexistent. + { + { + std::error_code error; + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + sourceOut << "original"; + } + ASSERT_FALSE(fs::exists(destFile)); - fs::UniqueID destID; - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(origID, destID); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); + ASSERT_EQ(getFileContents(destFile), "original"); + + ASSERT_NO_ERROR(fs::remove(destFile, false)); + } // Test 2: Move source over empty. { - std::error_code error; - llvm::raw_fd_ostream emptyOut(destFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); - } + { + std::error_code error; + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + sourceOut << "original"; - fs::UniqueID newID; - ASSERT_NO_ERROR(fs::getUniqueID(destFile, newID)); - ASSERT_NE(origID, newID); + llvm::raw_fd_ostream destOut(destFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + } - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(origID, destID); + ASSERT_EQ(getFileContents(destFile), "original"); - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); + ASSERT_NO_ERROR(fs::remove(destFile, false)); + } // Test 3: Move source over non-empty-but-different. { - std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); - nonEmptyOut << "different"; - } + { + std::error_code error; + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + sourceOut << "original"; - ASSERT_NO_ERROR(fs::getUniqueID(destFile, newID)); - ASSERT_NE(origID, newID); + llvm::raw_fd_ostream destOut(destFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + destOut << "different"; + } - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(origID, destID); + ASSERT_EQ(getFileContents(destFile), "original"); - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); + ASSERT_NO_ERROR(fs::remove(destFile, false)); + } // Test 4: Move source over identical. { - std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); - ASSERT_NO_ERROR(error); - nonEmptyOut << "original"; + { + std::error_code error; + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + sourceOut << "original"; + + llvm::raw_fd_ostream destOut(destFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + destOut << "original"; + } + + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); + ASSERT_TRUE(fs::exists(destFile)); + ASSERT_FALSE(fs::exists(sourceFile)); + + ASSERT_NO_ERROR(fs::remove(destFile, false)); } - ASSERT_NO_ERROR(fs::getUniqueID(destFile, newID)); - ASSERT_NE(origID, newID); - - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, destFile)); - ASSERT_TRUE(fs::exists(destFile)); - ASSERT_FALSE(fs::exists(sourceFile)); - - ASSERT_NO_ERROR(fs::getUniqueID(destFile, destID)); - ASSERT_EQ(newID, destID); - - ASSERT_NO_ERROR(fs::rename(destFile, sourceFile)); - origID = newID; - // Test 5: Move source over self. - ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, sourceFile)); - ASSERT_TRUE(fs::exists(sourceFile)); + { + { + std::error_code error; + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); + ASSERT_NO_ERROR(error); + sourceOut << "original"; + } - ASSERT_NO_ERROR(fs::getUniqueID(sourceFile, newID)); - ASSERT_EQ(origID, newID); + ASSERT_NO_ERROR(moveFileIfDifferent(sourceFile, sourceFile)); + ASSERT_TRUE(fs::exists(sourceFile)); + + ASSERT_NO_ERROR(fs::remove(sourceFile, false)); + } // Clean up. - ASSERT_NO_ERROR(fs::remove(sourceFile, false)); ASSERT_NO_ERROR(fs::remove(dirPath, false)); } From a7d01a1ef76c5b46a71256a1a18793b83b3857c9 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 23 Sep 2024 11:21:33 +0100 Subject: [PATCH 097/110] [utils][presets] Build libc++ for LLDB on linux We pass `-stdlib=libc++` in the test-suite to Clang for many of our tests because we want to explicilty test against libc++ type layouts. However, if we don't do this against a newly built libc++ we risk testing against old/unexpected layouts or if libc++ isn't available on the system, falling back to the system libstdc++. This patch adds libcxx as an explicit target in the preset so the tests build against a fresh libc++ (as we do for our other LLDB presets too). --- utils/build-presets.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/build-presets.ini b/utils/build-presets.ini index f42a9cf0268c0..973aa33862e9a 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -3066,6 +3066,8 @@ mixin-preset= sourcekit_stress_test_mixin [preset: linux_lldb] +# Build libcxx for tests +libcxx lldb foundation libdispatch From d7ac1cf7d793e5978d982aaa976eddf60c882d82 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Wed, 25 Sep 2024 09:30:25 -0700 Subject: [PATCH 098/110] Revert "[utils][presets] Build libc++ for LLDB on linux" This reverts commit a7d01a1ef76c5b46a71256a1a18793b83b3857c9. We need to upgrade the bots toolchain before this can be enabled. --- utils/build-presets.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/build-presets.ini b/utils/build-presets.ini index 973aa33862e9a..f42a9cf0268c0 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -3066,8 +3066,6 @@ mixin-preset= sourcekit_stress_test_mixin [preset: linux_lldb] -# Build libcxx for tests -libcxx lldb foundation libdispatch From a341986e757122d900f74d63a84a492b1fac4a27 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 20 Sep 2024 17:15:51 -0700 Subject: [PATCH 099/110] Remove the LLDB (classic) test configuration. --- utils/build-script-impl | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 66ce1514091c3..898ed926836b5 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -2760,32 +2760,20 @@ for host in "${ALL_HOSTS[@]}"; do echo "--- Running LLDB unit tests ---" with_pushd ${lldb_build_dir} \ call ${NINJA_BIN} -j ${BUILD_JOBS} unittests/LLDBUnitTests - echo "--- Running LLDB tests (Swift Config: Precise/ClangImporter) ---" + echo "--- Running LLDB tests (Swift Config: ClangImporter) ---" with_pushd ${lldb_build_dir} \ call ${NINJA_BIN} -j ${BUILD_JOBS} lldb-test-deps with_pushd ${results_dir} \ call "${llvm_build_dir}/bin/llvm-lit" \ "${lldb_build_dir}/test" \ ${LLVM_LIT_ARGS} ${LLVM_LIT_FILTER_ARG} \ - --param dotest-args="--setting symbols.use-swift-clangimporter=true --setting symbols.swift-precise-compiler-invocation=true" - echo "--- Rerun LLDB Swift API tests (Swift Config: Precise/DWARFImporter) ---" + --param dotest-args="--setting symbols.use-swift-clangimporter=true" + echo "--- Rerun LLDB Swift API tests (Swift Config: DWARFImporter) ---" with_pushd ${results_dir} \ call "${llvm_build_dir}/bin/llvm-lit" \ "${lldb_build_dir}/test" \ ${LLVM_LIT_ARGS} ${FILTER_SWIFT_API_OPTION} \ - --param dotest-args="--setting symbols.use-swift-clangimporter=false --setting symbols.swift-precise-compiler-invocation=true" - echo "--- Rerun LLDB Swift API tests (Swift Config: Classic/ClangImporter) ---" - with_pushd ${results_dir} \ - call "${llvm_build_dir}/bin/llvm-lit" \ - "${lldb_build_dir}/test" \ - ${LLVM_LIT_ARGS} ${FILTER_SWIFT_API_OPTION} \ - --param dotest-args="--setting symbols.use-swift-clangimporter=true --setting symbols.swift-precise-compiler-invocation=false" - echo "--- Rerun LLDB Swift API tests (Swift Config: Classic/DWARFImporter) ---" - with_pushd ${results_dir} \ - call "${llvm_build_dir}/bin/llvm-lit" \ - "${lldb_build_dir}/test" \ - ${LLVM_LIT_ARGS} ${FILTER_SWIFT_API_OPTION} \ - --param dotest-args="--setting symbols.use-swift-clangimporter=false --setting symbols.swift-precise-compiler-invocation=false" + --param dotest-args="--setting symbols.use-swift-clangimporter=false" if [[ -x "${LLDB_TEST_SWIFT_COMPATIBILITY}" ]] ; then echo "Running LLDB swift compatibility tests against" \ From 50f19307838a3acbc213da80bc26427d73afe109 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 27 Sep 2024 08:50:46 -0700 Subject: [PATCH 100/110] Revert "[build-script] Run LLDB tests with new redecl-completion setting" This reverts commit 885858567758fd61fdafce3629f30654d022334c. This mode is not working well with rebranch, so we're disabling its testing to reduce the CI noise. --- utils/build-script-impl | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 898ed926836b5..83a3f3ea6ec80 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -2786,18 +2786,6 @@ for host in "${ALL_HOSTS[@]}"; do --param dotest-args="${DOTEST_ARGS}" \ --filter=compat fi - - if [[ "$(true_false ${LLDB_TEST_SWIFT_ONLY})" == "FALSE" ]]; then - echo "--- Rerun LLDB API tests (Config: Redecl completion) ---" - with_pushd ${results_dir} \ - call "${llvm_build_dir}/bin/llvm-lit" \ - "${lldb_build_dir}/test/API" \ - ${LLVM_LIT_ARGS} \ - --param dotest-args="--setting plugin.typesystem.clang.experimental-redecl-completion=true" \ - --filter="lang|functionalities|types|commands" - - # FIXME: run shell-tests with new setting. LLDB doesn't support that yet. - fi continue ;; llbuild) From 684166e24cbbea3e69457df15ebe008c368c310c Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Fri, 27 Sep 2024 21:19:16 -0700 Subject: [PATCH 101/110] [embedded] Skip C++ stdlib for unicode stubs `stdint.h` should be picked up from `clang/lib/Headers`, but is instead being picked up by the system libc++. There's no C++ stdlib being used here, so just exclude it. Resolves rdar://134584685. --- stdlib/public/stubs/Unicode/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/public/stubs/Unicode/CMakeLists.txt b/stdlib/public/stubs/Unicode/CMakeLists.txt index 90b85e9597b42..6c68ebb48a096 100644 --- a/stdlib/public/stubs/Unicode/CMakeLists.txt +++ b/stdlib/public/stubs/Unicode/CMakeLists.txt @@ -23,7 +23,8 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB) elseif (SWIFT_HOST_VARIANT STREQUAL "macosx") set(extra_c_compile_flags -D__MACH__ -D__APPLE__ -ffreestanding) endif() - + list(APPEND extra_c_compile_flags -nostdinc++) + set(SWIFT_SDK_embedded_ARCH_${mod}_MODULE "${mod}") set(SWIFT_SDK_embedded_LIB_SUBDIR "embedded") set(SWIFT_SDK_embedded_ARCH_${mod}_TRIPLE "${triple}") From 8d2d92a96fabd3e928b99614f8e607630fb71733 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Tue, 1 Oct 2024 11:33:36 -0700 Subject: [PATCH 102/110] [ClangImporter][CAS] Add delay init CAS inputs in clang importer Handle the special clang instance usage in clang importer to make sure the inputs from CAS are initialized before perform frontend actions. --- lib/ClangImporter/ClangImporter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 0450a34839bc9..65f031427b50b 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1487,6 +1487,10 @@ ClangImporter::create(ASTContext &ctx, if (importerOpts.Mode == ClangImporterOptions::Modes::PrecompiledModule) return importer; + instance.initializeDelayedInputFileFromCAS(); + if (instance.getDiagnostics().hasErrorOccurred()) + return nullptr; + bool canBegin = action->BeginSourceFile(instance, instance.getFrontendOpts().Inputs[0]); if (!canBegin) From ab219d246e9a9504c486eab206de4ba9124a9453 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Thu, 3 Oct 2024 11:23:16 -0700 Subject: [PATCH 103/110] [ClangImporter] Update the error condition when delayed inputs are used Return error only when no inputs are available, instead of relying on checking no errors occured in diagnostics. --- lib/ClangImporter/ClangImporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 43d71ad39cc87..23b9e789c508b 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1501,8 +1501,8 @@ ClangImporter::create(ASTContext &ctx, return importer; instance.initializeDelayedInputFileFromCAS(); - if (instance.getDiagnostics().hasErrorOccurred()) - return nullptr; + if (instance.getFrontendOpts().Inputs.empty()) + return nullptr; // no inputs available. bool canBegin = action->BeginSourceFile(instance, instance.getFrontendOpts().Inputs[0]); From d589133b1d602762c5346738bc5cf3395400d6a4 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 9 Oct 2024 08:13:49 -0700 Subject: [PATCH 104/110] Fix test/IRGen/enum_copy_init_with_take_memcpy.swift on rebranch --- test/IRGen/enum_copy_init_with_take_memcpy.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/IRGen/enum_copy_init_with_take_memcpy.swift b/test/IRGen/enum_copy_init_with_take_memcpy.swift index cae60dffe2529..20e1880f92828 100644 --- a/test/IRGen/enum_copy_init_with_take_memcpy.swift +++ b/test/IRGen/enum_copy_init_with_take_memcpy.swift @@ -27,13 +27,12 @@ struct HasAnEnum { } -// CHECK: define{{.*}} hidden swiftcc i64 @"$s31enum_copy_init_with_take_memcpy9HasAnEnumV9readValueSiyF"(ptr {{.*}} %0) -// CHECK: [[T0:%.*]] = getelementptr inbounds %T31enum_copy_init_with_take_memcpy9HasAnEnumV, ptr %0 -// CHECK: [[T1:%.*]] = load i8, ptr [[T0]] -// CHECK: [[T2:%.*]] = and i8 [[T1]], 1 -// CHECK: [[T3:%.*]] = icmp eq i8 [[T2]], 0 -// CHECK: [[T4:%.*]] = select i1 [[T3]], i64 -1, i64 4 -// CHECK: ret i64 [[T4]] -// CHECK: } +// CHECK: define {{.*}} swiftcc range(i64 -1, 5) i64 @"$s31enum_copy_init_with_take_memcpy9HasAnEnumV9readValueSiyF"(ptr {{.*}} %0) +// CHECK: [[T0:%.*]] = getelementptr inbounds i8, ptr %0, i64 160 +// CHECK: [[T1:%.*]] = load i8, ptr [[T0]] +// CHECK: [[T2:%.*]] = icmp eq i8 [[T1]], 2 +// CHECK: br i1 [[T2]], label +// CHECK: [[R:%.*]] = phi i64 [ -1, {{.*}} ], [ 4, {{.*}} ] +// CHECK: ret i64 [[R]] } From 7443fc1c6ffed879925ad977fea49b4f9f44574f Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Tue, 15 Oct 2024 16:18:43 -0700 Subject: [PATCH 105/110] [DebugInfo] Stop emitting spare bits mask in debug info We're now able to calculate the spare bits mask from other information. Stop emitting it in debug info. --- lib/IRGen/IRGenDebugInfo.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 9b0e9122521eb..fdae69fdcf87a 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1389,21 +1389,9 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type, } } - APInt SpareBitsMask; - auto &EnumStrategy = - getEnumImplStrategy(IGM, DbgTy.getType()->getCanonicalType()); - - auto VariantOffsetInBits = 0; - if (auto SpareBitsMaskInfo = EnumStrategy.calculateSpareBitsMask()) { - SpareBitsMask = SpareBitsMaskInfo->bits; - // The offset of the variant mask in the overall enum. - VariantOffsetInBits = SpareBitsMaskInfo->byteOffset * 8; - } - auto VPTy = DBuilder.createVariantPart( Scope, {}, File, Line, SizeInBits, AlignInBits, Flags, nullptr, - DBuilder.getOrCreateArray(Elements), /*UniqueIdentifier=*/"", - VariantOffsetInBits, SpareBitsMask); + DBuilder.getOrCreateArray(Elements), /*UniqueIdentifier=*/""); auto DITy = DBuilder.createStructType( Scope, Name, File, Line, SizeInBits, AlignInBits, Flags, nullptr, From f5de38e2cc96e3f5700eafbe5d72cf3b4c27d394 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Thu, 13 Jun 2024 09:34:43 -0700 Subject: [PATCH 106/110] Remove RemoteInspection code to fetch no-longer-used reflection metadata without relying on spare bit information in the reflection metadata (which was added in #40906). As a result, we can remove the code from #40906. This is the first step in such removal. It removes the RemoteMirror code for looking up such metadata. It leaves behind: * Sufficient stubs for LLDB to continue to build. Once LLDB is updated, these stubs can be removed as well. * The compiler code to emit such metadata. This allows new binaries to still reflect MPEs on older runtimes. This will need to be kept for a transitional period. (cherry picked from commit c20ef6de2ac36f967deac6939bc57a7799328ac2) --- .../swift/RemoteInspection/DescriptorFinder.h | 26 ++-- include/swift/RemoteInspection/Records.h | 105 ------------- .../RemoteInspection/ReflectionContext.h | 27 +--- .../llvm/BinaryFormat/Swift.def | 1 - .../swift/RemoteInspection/TypeRefBuilder.h | 38 +---- .../public/RemoteInspection/TypeLowering.cpp | 2 - .../RemoteInspection/TypeRefBuilder.cpp | 142 ------------------ .../SwiftRemoteMirror/SwiftRemoteMirror.cpp | 2 - .../SwiftShims/swift/shims/MetadataSections.h | 1 - stdlib/public/runtime/SwiftRT-COFF.cpp | 2 - stdlib/public/runtime/SwiftRT-ELF-WASM.cpp | 2 - 11 files changed, 24 insertions(+), 324 deletions(-) diff --git a/include/swift/RemoteInspection/DescriptorFinder.h b/include/swift/RemoteInspection/DescriptorFinder.h index 4199d73f053de..96508c40304af 100644 --- a/include/swift/RemoteInspection/DescriptorFinder.h +++ b/include/swift/RemoteInspection/DescriptorFinder.h @@ -93,26 +93,31 @@ struct FieldDescriptorBase { getFieldRecords() = 0; }; +// There are no longer any clients of this interface, but we +// need to keep this stubbed out until all the +// implementors have been removed. In particular, LLDB +// still implements this interface. +// TODO: Delete this after Swift 6.0 ships struct MultiPayloadEnumDescriptorBase { - virtual ~MultiPayloadEnumDescriptorBase(){}; + virtual ~MultiPayloadEnumDescriptorBase(){ abort(); }; - virtual llvm::StringRef getMangledTypeName() = 0; - - virtual uint32_t getContentsSizeInWords() const = 0; + virtual llvm::StringRef getMangledTypeName() { abort(); }; - virtual size_t getSizeInBytes() const = 0; + virtual uint32_t getContentsSizeInWords() const { abort(); }; - virtual uint32_t getFlags() const = 0; + virtual size_t getSizeInBytes() const { abort(); }; - virtual bool usesPayloadSpareBits() const = 0; + virtual uint32_t getFlags() const { abort(); }; - virtual uint32_t getPayloadSpareBitMaskByteOffset() const = 0; + virtual bool usesPayloadSpareBits() const { abort(); }; - virtual uint32_t getPayloadSpareBitMaskByteCount() const = 0; + virtual uint32_t getPayloadSpareBitMaskByteOffset() const { abort(); }; - virtual const uint8_t *getPayloadSpareBits() const = 0; + virtual uint32_t getPayloadSpareBitMaskByteCount() const { abort(); }; + virtual const uint8_t *getPayloadSpareBits() const { abort(); }; }; + /// Interface for finding type descriptors. Implementors may provide descriptors /// that live inside or outside reflection metadata. struct DescriptorFinder { @@ -125,6 +130,7 @@ struct DescriptorFinder { virtual std::unique_ptr getFieldDescriptor(const TypeRef *TR) = 0; + // TODO: Delete this as soon as LLDB no longer attempts to override it virtual std::unique_ptr getMultiPayloadEnumDescriptor(const TypeRef *TR) { abort(); }; }; diff --git a/include/swift/RemoteInspection/Records.h b/include/swift/RemoteInspection/Records.h index aa08ce3ef5b6d..1c0ceeb976257 100644 --- a/include/swift/RemoteInspection/Records.h +++ b/include/swift/RemoteInspection/Records.h @@ -378,111 +378,6 @@ class BuiltinTypeDescriptor { } }; -class MultiPayloadEnumDescriptor { -public: - const RelativeDirectPointer TypeName; - -private: - // This descriptor contains a series of 32-bit words - uint32_t contents[]; - - // Properties are stored in `contents` at particular indexes: - - // uint32_t SizeFlags; - // Upper 16 bits are the size of the contents (in 32-bit words): - // (This allows us to expand this structure in the future; - // new fields should have accessors that test whether the - // size is large enough and return "non-existent" if the - // descriptor isn't large enough to have that field.) - // Lower 16 bits are flag bits - - int getSizeFlagsIndex() const { return 0; } - - // uint32_t PayloadSpareBitMaskByteOffsetCount; - // Number of bytes in "payload spare bits", and - // offset of them within the payload area - // Only present if `usePayloadSpareBits()` - - int getPayloadSpareBitMaskByteCountIndex() const { - return getSizeFlagsIndex() + 1; - } - - // uint8_t *PayloadSpareBits; - // Variably-sized bitmask field (padded to a multiple of 4 bytes) - // Only present if `usePayloadSpareBits()` - - int getPayloadSpareBitsIndex() const { - int PayloadSpareBitMaskByteCountFieldSize = usesPayloadSpareBits() ? 1 : 0; - return getPayloadSpareBitMaskByteCountIndex() + PayloadSpareBitMaskByteCountFieldSize; - } - - // uint32_t foo; - // TODO: Some future field - // int getFooIndex() const { - // int PayloadSpareBitMaskFieldSize = (getPayloadSpareBitMaskByteCount() + 3) / 4; - // return getPayloadSpareBitsIndex() + PayloadSpareBitMaskFieldSize; - // } - - // uint32_t getFoo() const { - // if (getFooIndex() < getContentsSizeInWords()) { - // return contents[getFooIndex()]; - // } else { - // return 0; // Field isn't present - // } - // } - -public: - // - // Data derived from the above... - // - - uint32_t getContentsSizeInWords() const { - return contents[getSizeFlagsIndex()] >> 16; - } - - size_t getSizeInBytes() const { -// assert(getContentsSizeInWords() > 0 && "Malformed MPEnum reflection record"); - size_t sizeInBytes = sizeof(TypeName) + getContentsSizeInWords() * 4; - return sizeInBytes; - } - - uint32_t getFlags() const { - assert(getContentsSizeInWords() > 0 && "Malformed MPEnum reflection record"); - return contents[getSizeFlagsIndex()] & 0xffff; - } - - bool usesPayloadSpareBits() const { - return getFlags() & 1; - } - - uint32_t getPayloadSpareBitMaskByteOffset() const { - if (usesPayloadSpareBits()) { - return contents[getPayloadSpareBitMaskByteCountIndex()] >> 16; - } else { - return 0; - } - } - - uint32_t getPayloadSpareBitMaskByteCount() const { - if (usesPayloadSpareBits()) { - auto byteCount = contents[getPayloadSpareBitMaskByteCountIndex()] & 0xffff; - assert(getContentsSizeInWords() >= 2 + (byteCount + 3) / 4 - && "Malformed MPEnum reflection record: mask bigger than record"); - return byteCount; - } else { - return 0; - } - } - - const uint8_t *getPayloadSpareBits() const { - if (usesPayloadSpareBits()) { - return reinterpret_cast(&contents[getPayloadSpareBitsIndex()]); - } else { - return nullptr; - } - } -}; - class CaptureTypeRecord { public: const RelativeDirectPointer MangledTypeName; diff --git a/include/swift/RemoteInspection/ReflectionContext.h b/include/swift/RemoteInspection/ReflectionContext.h index 7ca0450d31ced..c78121d5f0ce2 100644 --- a/include/swift/RemoteInspection/ReflectionContext.h +++ b/include/swift/RemoteInspection/ReflectionContext.h @@ -335,8 +335,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr)); auto ConformMdSec = findMachOSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform)); - auto MPEnumMdSec = findMachOSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum)); if (FieldMdSec.first == nullptr && AssocTySec.first == nullptr && @@ -344,8 +342,7 @@ class ReflectionContext CaptureSec.first == nullptr && TypeRefMdSec.first == nullptr && ReflStrMdSec.first == nullptr && - ConformMdSec.first == nullptr && - MPEnumMdSec.first == nullptr) + ConformMdSec.first == nullptr) return {}; ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, @@ -355,7 +352,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; auto InfoID = this->addReflectionInfo(info); @@ -470,8 +466,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr)); auto ConformMdSec = findCOFFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform)); - auto MPEnumMdSec = findCOFFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum)); if (FieldMdSec.first == nullptr && AssocTySec.first == nullptr && @@ -479,8 +473,7 @@ class ReflectionContext CaptureSec.first == nullptr && TypeRefMdSec.first == nullptr && ReflStrMdSec.first == nullptr && - ConformMdSec.first == nullptr && - MPEnumMdSec.first == nullptr) + ConformMdSec.first == nullptr) return {}; ReflectionInfo Info = {{FieldMdSec.first, FieldMdSec.second}, @@ -490,7 +483,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; return this->addReflectionInfo(Info); } @@ -687,9 +679,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr), true); auto ConformMdSec = findELFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform), true); - auto MPEnumMdSec = findELFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum), true); - if (Error) return {}; @@ -699,7 +688,7 @@ class ReflectionContext // ELF executable. if (FieldMdSec.first || AssocTySec.first || BuiltinTySec.first || CaptureSec.first || TypeRefMdSec.first || ReflStrMdSec.first || - ConformMdSec.first || MPEnumMdSec.first) { + ConformMdSec.first) { ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, {AssocTySec.first, AssocTySec.second}, {BuiltinTySec.first, BuiltinTySec.second}, @@ -707,7 +696,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; result = this->addReflectionInfo(info); } @@ -730,15 +718,13 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr), false); ConformMdSec = findELFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform), false); - MPEnumMdSec = findELFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum), false); if (Error) return {}; if (FieldMdSec.first || AssocTySec.first || BuiltinTySec.first || CaptureSec.first || TypeRefMdSec.first || ReflStrMdSec.first || - ConformMdSec.first || MPEnumMdSec.first) { + ConformMdSec.first) { ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, {AssocTySec.first, AssocTySec.second}, {BuiltinTySec.first, BuiltinTySec.second}, @@ -746,7 +732,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; auto rid = this->addReflectionInfo(info); if (!result) @@ -861,7 +846,8 @@ class ReflectionContext ReflectionSectionKind::fieldmd, ReflectionSectionKind::assocty, ReflectionSectionKind::builtin, ReflectionSectionKind::capture, ReflectionSectionKind::typeref, ReflectionSectionKind::reflstr, - ReflectionSectionKind::conform, ReflectionSectionKind::mpenum}; + ReflectionSectionKind::conform + }; llvm::SmallVector, uint64_t>, 6> Pairs; for (auto Section : Sections) { @@ -887,7 +873,6 @@ class ReflectionContext {Pairs[4].first, Pairs[4].second}, {Pairs[5].first, Pairs[5].second}, {Pairs[6].first, Pairs[6].second}, - {Pairs[7].first, Pairs[7].second}, PotentialModuleNames}; return addReflectionInfo(Info); } diff --git a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def index 05b60e40632cd..1ea0bc548b37e 100644 --- a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def +++ b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def @@ -30,4 +30,3 @@ HANDLE_SWIFT_SECTION(protocs, "__swift5_protos", "swift5_protocols", ".sw5prt$B") HANDLE_SWIFT_SECTION(acfuncs, "__swift5_acfuncs", "swift5_accessible_functions", ".sw5acfn$B") -HANDLE_SWIFT_SECTION(mpenum, "__swift5_mpenum", "swift5_mpenum", ".sw5mpen$B") diff --git a/include/swift/RemoteInspection/TypeRefBuilder.h b/include/swift/RemoteInspection/TypeRefBuilder.h index 9ce7276d32d5a..3a45da7f7f395 100644 --- a/include/swift/RemoteInspection/TypeRefBuilder.h +++ b/include/swift/RemoteInspection/TypeRefBuilder.h @@ -231,21 +231,6 @@ class CaptureDescriptorIterator }; using CaptureSection = ReflectionSection; -class MultiPayloadEnumDescriptorIterator - : public ReflectionSectionIteratorBase { -public: - MultiPayloadEnumDescriptorIterator(RemoteRef Cur, uint64_t Size) - : ReflectionSectionIteratorBase(Cur, Size, "MultiPayloadEnum") {} - - static uint64_t - getCurrentRecordSize(RemoteRef MPER) { - return MPER->getSizeInBytes(); - } -}; -using MultiPayloadEnumSection = - ReflectionSection; - using GenericSection = ReflectionSection; struct ReflectionInfo { @@ -256,7 +241,6 @@ struct ReflectionInfo { GenericSection TypeReference; GenericSection ReflectionString; GenericSection Conformance; - MultiPayloadEnumSection MultiPayloadEnum; llvm::SmallVector PotentialModuleNames; }; @@ -490,10 +474,6 @@ class TypeRefBuilder { /// Get the unsubstituted capture types for a closure context. ClosureContextInfo getClosureContextInfo(RemoteRef CD); - /// Get the multipayload enum projection information for a given TR - std::unique_ptr - getMultiPayloadEnumDescriptor(const TypeRef *TR) override; - const TypeRef *lookupTypeWitness(const std::string &MangledTypeName, const std::string &Member, StringRef Protocol); @@ -516,8 +496,6 @@ class TypeRefBuilder { /// Load unsubstituted field types for a nominal type. RemoteRef getFieldTypeInfo(const TypeRef *TR); - RemoteRef getMultiPayloadEnumInfo(const TypeRef *TR); - void populateFieldTypeInfoCacheWithReflectionAtIndex(size_t Index); std::optional> @@ -573,8 +551,7 @@ class TypeRefBuilder { public: /// - /// Dumping typerefs, field declarations, builtin types, captures, - /// multi-payload enums + /// Dumping typerefs, field declarations, builtin types, captures /// void dumpTypeRef(RemoteRef MangledName, std::ostream &stream, bool printTypeName = false); @@ -583,7 +560,6 @@ class TypeRefBuilder { void dumpFieldSection(std::ostream &stream); void dumpBuiltinTypeSection(std::ostream &stream); void dumpCaptureSection(std::ostream &stream); - void dumpMultiPayloadEnumSection(std::ostream &stream); template