Skip to content

Commit 04c8aba

Browse files
authored
Merge pull request #1044 from swiftwasm/master
[pull] swiftwasm from master
2 parents 64c8561 + df95485 commit 04c8aba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+215
-327
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ if(POLICY CMP0067)
1212
cmake_policy(SET CMP0067 NEW)
1313
endif()
1414

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

benchmark/single-source/DataBenchmarks.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import TestsUtils
1414
import Foundation
1515

16-
let d: [BenchmarkCategory] = [.validation, .api, .Data]
16+
let d: [BenchmarkCategory] = [.validation, .api, .Data, .cpubench]
1717

1818
public let DataBenchmarks = [
1919
BenchmarkInfo(name: "DataCreateEmpty",

benchmark/single-source/DictionarySwap.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let numberMap = Dictionary(uniqueKeysWithValues: zip(1...size, 1...size))
1919
let boxedNums = (1...size).lazy.map { Box($0) }
2020
let boxedNumMap = Dictionary(uniqueKeysWithValues: zip(boxedNums, boxedNums))
2121

22-
let t: [BenchmarkCategory] = [.validation, .api, .Dictionary]
22+
let t: [BenchmarkCategory] = [.validation, .api, .Dictionary, .cpubench]
2323

2424
public let DictionarySwap = [
2525
BenchmarkInfo(name: "DictionarySwap",

benchmark/single-source/NIOChannelPipeline.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TestsUtils
1414

1515
// Mini benchmark implementing the gist of SwiftNIO's ChannelPipeline as
1616
// implemented by NIO 1 and NIO 2.[01]
17-
let t: [BenchmarkCategory] = [.runtime, .refcount]
17+
let t: [BenchmarkCategory] = [.runtime, .refcount, .cpubench]
1818
let N = 100
1919

2020
public let NIOChannelPipeline = [

benchmark/single-source/ObjectiveCNoBridgingStubs.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Foundation
2121
import ObjectiveCTests
2222
#endif
2323

24-
let t: [BenchmarkCategory] = [.validation, .bridging]
24+
let t: [BenchmarkCategory] = [.validation, .bridging, .cpubench]
2525

2626
public let ObjectiveCNoBridgingStubs = [
2727
BenchmarkInfo(name: "ObjectiveCBridgeStubToNSStringRef",

benchmark/single-source/ReversedCollections.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public let ReversedCollections = [
1616
BenchmarkInfo(name: "ReversedArray2", runFunction: run_ReversedArray, tags: [.validation, .api, .Array],
1717
setUpFunction: { blackHole(arrayInput) },
1818
tearDownFunction: { arrayInput = nil }),
19-
BenchmarkInfo(name: "ReversedBidirectional", runFunction: run_ReversedBidirectional, tags: [.validation, .api]),
19+
BenchmarkInfo(name: "ReversedBidirectional", runFunction: run_ReversedBidirectional, tags: [.validation, .api, .cpubench]),
2020
BenchmarkInfo(name: "ReversedDictionary2", runFunction: run_ReversedDictionary, tags: [.validation, .api, .Dictionary],
2121
setUpFunction: { blackHole(dictionaryInput) },
2222
tearDownFunction: { dictionaryInput = nil })

benchmark/single-source/SortLargeExistentials.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import TestsUtils
1717
public let SortLargeExistentials = BenchmarkInfo(
1818
name: "SortLargeExistentials",
1919
runFunction: run_SortLargeExistentials,
20-
tags: [.validation, .api, .algorithm],
20+
tags: [.validation, .api, .algorithm, .cpubench],
2121
legacyFactor: 100)
2222

2323
protocol LetterKind {

benchmark/single-source/StackPromo.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TestsUtils
1414
public let StackPromo = BenchmarkInfo(
1515
name: "StackPromo",
1616
runFunction: run_StackPromo,
17-
tags: [.regression],
17+
tags: [.regression, .cpubench],
1818
legacyFactor: 100)
1919

2020
protocol Proto {

benchmark/single-source/StringReplaceSubrange.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import TestsUtils
1414

15-
let tags: [BenchmarkCategory] = [.validation, .api, .String]
15+
let tags: [BenchmarkCategory] = [.validation, .api, .String, .cpubench]
1616

1717
public let StringReplaceSubrange = [
1818
BenchmarkInfo(

include/swift/AST/ASTContext.h

-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ namespace swift {
111111
class SourceManager;
112112
class ValueDecl;
113113
class DiagnosticEngine;
114-
class TypeCheckerDebugConsumer;
115114
struct RawComment;
116115
class DocComment;
117116
class SILBoxType;
@@ -276,9 +275,6 @@ class ASTContext final {
276275
#define IDENTIFIER_WITH_NAME(Name, IdStr) Identifier Id_##Name;
277276
#include "swift/AST/KnownIdentifiers.def"
278277

279-
/// A consumer of type checker debug output.
280-
std::unique_ptr<TypeCheckerDebugConsumer> TypeCheckerDebug;
281-
282278
/// Cache for names of canonical GenericTypeParamTypes.
283279
mutable llvm::DenseMap<unsigned, Identifier>
284280
CanonicalGenericTypeParamTypeNames;

include/swift/AST/TypeCheckerDebugConsumer.h

-55
This file was deleted.

include/swift/SIL/SILInstruction.h

-4
Original file line numberDiff line numberDiff line change
@@ -6624,8 +6624,6 @@ class BeginCOWMutationInst final
66246624
friend SILBuilder;
66256625
friend TrailingObjects;
66266626

6627-
bool native;
6628-
66296627
BeginCOWMutationInst(SILDebugLocation loc, SILValue operand,
66306628
ArrayRef<SILType> resultTypes,
66316629
ArrayRef<ValueOwnershipKind> resultOwnerships,
@@ -6670,8 +6668,6 @@ class EndCOWMutationInst
66706668
{
66716669
friend SILBuilder;
66726670

6673-
bool keepUnique;
6674-
66756671
EndCOWMutationInst(SILDebugLocation DebugLoc, SILValue Operand,
66766672
bool keepUnique)
66776673
: UnaryInstructionBase(DebugLoc, Operand, Operand->getType()) {

lib/AST/ASTContext.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "swift/AST/SubstitutionMap.h"
4545
#include "swift/AST/SILLayout.h"
4646
#include "swift/AST/TypeCheckRequests.h"
47-
#include "swift/AST/TypeCheckerDebugConsumer.h"
4847
#include "swift/Basic/Compiler.h"
4948
#include "swift/Basic/SourceManager.h"
5049
#include "swift/Basic/Statistic.h"
@@ -557,7 +556,6 @@ ASTContext::ASTContext(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
557556
TheBuiltinModule(createBuiltinModule(*this)),
558557
StdlibModuleName(getIdentifier(STDLIB_NAME)),
559558
SwiftShimsModuleName(getIdentifier(SWIFT_SHIMS_NAME)),
560-
TypeCheckerDebug(new StderrTypeCheckerDebugConsumer()),
561559
TheErrorType(
562560
new (*this, AllocationArena::Permanent)
563561
ErrorType(*this, Type(), RecursiveTypeProperties::HasError)),
@@ -3833,45 +3831,6 @@ void TypeLoc::setInvalidType(ASTContext &C) {
38333831
Ty = ErrorType::get(C);
38343832
}
38353833

3836-
namespace {
3837-
class raw_capturing_ostream : public raw_ostream {
3838-
std::string Message;
3839-
uint64_t Pos;
3840-
CapturingTypeCheckerDebugConsumer &Listener;
3841-
3842-
public:
3843-
raw_capturing_ostream(CapturingTypeCheckerDebugConsumer &Listener)
3844-
: Listener(Listener) {}
3845-
3846-
~raw_capturing_ostream() override {
3847-
flush();
3848-
}
3849-
3850-
void write_impl(const char *Ptr, size_t Size) override {
3851-
Message.append(Ptr, Size);
3852-
Pos += Size;
3853-
3854-
// Check if we have at least one complete line.
3855-
size_t LastNewline = StringRef(Message).rfind('\n');
3856-
if (LastNewline == StringRef::npos)
3857-
return;
3858-
Listener.handleMessage(StringRef(Message.data(), LastNewline + 1));
3859-
Message.erase(0, LastNewline + 1);
3860-
}
3861-
3862-
uint64_t current_pos() const override {
3863-
return Pos;
3864-
}
3865-
};
3866-
} // unnamed namespace
3867-
3868-
TypeCheckerDebugConsumer::~TypeCheckerDebugConsumer() { }
3869-
3870-
CapturingTypeCheckerDebugConsumer::CapturingTypeCheckerDebugConsumer()
3871-
: Log(new raw_capturing_ostream(*this)) {
3872-
Log->SetUnbuffered();
3873-
}
3874-
38753834
void SubstitutionMap::Storage::Profile(
38763835
llvm::FoldingSetNodeID &id,
38773836
GenericSignature genericSig,

lib/Demangling/Demangler.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,8 @@ NodePointer Demangler::demangleArchetype() {
20192019
if (!demangleBoundGenerics(boundGenericArgs, retroactiveConformances))
20202020
return nullptr;
20212021
auto Name = popNode();
2022+
if (!Name)
2023+
return nullptr;
20222024
auto opaque = createWithChildren(Node::Kind::OpaqueType, Name,
20232025
createNode(Node::Kind::Index, index));
20242026
auto boundGenerics = createNode(Node::Kind::TypeList);

lib/Frontend/CompilerInvocation.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,23 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
621621
Opts.VerifySyntaxTree = true;
622622
}
623623

624+
// If we are asked to emit a module documentation file, configure lexing and
625+
// parsing to remember comments.
626+
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath()) {
627+
Opts.AttachCommentsToDecls = true;
628+
}
629+
630+
// If we are doing index-while-building, configure lexing and parsing to
631+
// remember comments.
632+
if (!FrontendOpts.IndexStorePath.empty()) {
633+
Opts.AttachCommentsToDecls = true;
634+
}
635+
636+
// If we're parsing SIL, access control doesn't make sense to enforce.
637+
if (FrontendOpts.InputKind == InputFileKind::SIL) {
638+
Opts.EnableAccessControl = false;
639+
}
640+
624641
return HadError || UnsupportedOS || UnsupportedArch;
625642
}
626643

lib/Frontend/Frontend.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,8 @@ bool CompilerInstance::setup(const CompilerInvocation &Invok) {
298298
setUpLLVMArguments();
299299
setUpDiagnosticOptions();
300300

301-
const auto &frontendOpts = Invocation.getFrontendOptions();
302-
303-
// If we are asked to emit a module documentation file, configure lexing and
304-
// parsing to remember comments.
305-
if (frontendOpts.InputsAndOutputs.hasModuleDocOutputPath())
306-
Invocation.getLangOptions().AttachCommentsToDecls = true;
307-
308-
// If we are doing index-while-building, configure lexing and parsing to
309-
// remember comments.
310-
if (!frontendOpts.IndexStorePath.empty()) {
311-
Invocation.getLangOptions().AttachCommentsToDecls = true;
312-
}
313-
314301
assert(Lexer::isIdentifier(Invocation.getModuleName()));
315302

316-
if (isInSILMode())
317-
Invocation.getLangOptions().EnableAccessControl = false;
318-
319303
if (setUpInputs())
320304
return true;
321305

lib/SIL/CMakeLists.txt

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

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

lib/SIL/IR/CMakeLists.txt

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

lib/SIL/IR/SILDeclRef.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
233233

234234
// Native function-local declarations have shared linkage.
235235
// FIXME: @objc declarations should be too, but we currently have no way
236-
// of marking them "used" other than making them external.
236+
// of marking them "used" other than making them external.
237237
ValueDecl *d = getDecl();
238238
DeclContext *moduleContext = d->getDeclContext();
239239
while (!moduleContext->isModuleScopeContext()) {
@@ -335,6 +335,10 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
335335
}
336336
}
337337

338+
if (isEnumElement()) {
339+
limit = Limit::OnDemand;
340+
}
341+
338342
auto effectiveAccess = d->getEffectiveAccess();
339343

340344
// Private setter implementations for an internal storage declaration should

lib/SIL/Parser/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
sil_register_sources(
2-
ParseSIL.cpp
3-
)
4-
1+
target_sources(swiftSIL PRIVATE
2+
ParseSIL.cpp)

lib/SIL/SIL.cpp

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

0 commit comments

Comments
 (0)