Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c8f1a53
[Runtime] Change ProtocolCache, NominalCache, and HashableConformance…
mikeash Nov 16, 2020
b2535b2
Demangling: avoid implicit fallthrough
compnerd Nov 17, 2020
fbfcaab
IRGen: Allow calling a pre-defined async silgen_name function using t…
aschwaighofer Nov 17, 2020
17aece4
[android] Mark Interpreter/async as an executable test.
drodriguez Nov 18, 2020
b66b112
[windows] Set TMP and TEMP, as well as TMPDIR.
drodriguez Nov 18, 2020
b07c06e
[Serialization] Fix crashes when allowing compiler errors in modules
bnbarham Nov 6, 2020
54bc17e
[Gardening] Fix up order-dependent batch code complete tests
bnbarham Nov 18, 2020
611284f
[sil] Element shadowing of SILInstruction::getKind() by renaming Mark…
gottesmm Nov 18, 2020
d249b5c
[Clang importer] Make sure we mirror protocol decls for all names.
DougGregor Nov 18, 2020
c7c0fed
[Clang importer] Narrow mirrored-import fixes to only consider 'async'.
DougGregor Nov 18, 2020
97c5e24
[Concurrency] Emit @asyncHandler bodies as traps.
DougGregor Nov 18, 2020
4a9ab66
Merge pull request #34805 from DougGregor/asynchandler-trap
ktoso Nov 18, 2020
5286d9c
Merge pull request #34804 from DougGregor/concurrency-import-mirrored…
DougGregor Nov 18, 2020
f82d297
Merge pull request #34792 from compnerd/implicit-fallthrough
compnerd Nov 18, 2020
32dac8b
Merge pull request #34797 from drodriguez/windows-temp-tmp-and-tmpdir
drodriguez Nov 18, 2020
4b6dcf6
Merge pull request #34796 from drodriguez/android-async-requires-exec…
drodriguez Nov 18, 2020
cae81ee
Fix issues with discontiguous-slice assignment (#34708)
natecook1000 Nov 18, 2020
ef05015
Remove old swift_dynamicCast implementation (#34789)
tbkka Nov 18, 2020
07bc5ef
Merge pull request #34798 from bnbarham/allow-errors-asserts
akyrtzi Nov 18, 2020
03646be
Merge pull request #34803 from gottesmm/pr-859299a3855ec8453c6129e100…
gottesmm Nov 18, 2020
632c9ff
Merge pull request #34793 from aschwaighofer/irgen_async_silgen_name
DougGregor Nov 18, 2020
5ea3bb2
Merge pull request #34769 from mikeash/concurrentmap-misc-to-concurre…
mikeash Nov 18, 2020
5aab24b
Merge pull request #34800 from bnbarham/fixup-batch-test
rintaro Nov 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,9 @@ void
SILCloner<ImplClass>::visitMarkUninitializedInst(MarkUninitializedInst *Inst) {
SILValue OpValue = getOpValue(Inst->getOperand());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(
Inst, getBuilder().createMarkUninitialized(getOpLocation(Inst->getLoc()),
OpValue, Inst->getKind()));
recordClonedInstruction(Inst, getBuilder().createMarkUninitialized(
getOpLocation(Inst->getLoc()), OpValue,
Inst->getMarkUninitializedKind()));
}

template<typename ImplClass>
Expand Down
3 changes: 1 addition & 2 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4124,8 +4124,7 @@ class MarkUninitializedInst
ThisKind(K) {}

public:

Kind getKind() const { return ThisKind; }
Kind getMarkUninitializedKind() const { return ThisKind; }

bool isVar() const { return ThisKind == Var; }
bool isRootSelf() const {
Expand Down
3 changes: 3 additions & 0 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(bool preferTypeRepr,

class ShouldPrintForModuleInterface : public ShouldPrintChecker {
bool shouldPrint(const Decl *D, const PrintOptions &options) override {
if (!D)
return false;

// Skip anything that is marked `@_implementationOnly` itself.
if (D->getAttrs().hasAttribute<ImplementationOnlyAttr>())
return false;
Expand Down
13 changes: 9 additions & 4 deletions lib/AST/DeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,17 @@ void AccessScope::dump() const {

if (auto *decl = getDeclContext()->getAsDecl()) {
llvm::errs() << Decl::getKindName(decl->getKind()) << " ";
if (auto *ext = dyn_cast<ExtensionDecl>(decl))
llvm::errs() << ext->getExtendedNominal()->getName();
else if (auto *named = dyn_cast<ValueDecl>(decl))
if (auto *ext = dyn_cast<ExtensionDecl>(decl)) {
auto *extended = ext->getExtendedNominal();
if (extended)
llvm::errs() << extended->getName();
else
llvm::errs() << "(null)";
} else if (auto *named = dyn_cast<ValueDecl>(decl)) {
llvm::errs() << named->getName();
else
} else {
llvm::errs() << (const void *)decl;
}

SourceLoc loc = decl->getLoc();
if (loc.isValid()) {
Expand Down
13 changes: 12 additions & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7463,9 +7463,20 @@ void SwiftDeclConverter::importNonOverriddenMirroredMethods(DeclContext *dc,
Impl.importMirroredDecl(objcMethod, dc, getVersion(), proto)) {
members.push_back(imported);

for (auto alternate : Impl.getAlternateDecls(imported))
for (auto alternate : Impl.getAlternateDecls(imported)) {
if (imported->getDeclContext() == alternate->getDeclContext())
members.push_back(alternate);
}

if (Impl.SwiftContext.LangOpts.EnableExperimentalConcurrency &&
!getVersion().supportsConcurrency()) {
auto asyncVersion = getVersion().withConcurrency(true);
if (auto asyncImport = Impl.importMirroredDecl(
objcMethod, dc, asyncVersion, proto)) {
if (asyncImport != imported)
members.push_back(asyncImport);
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/Demangling/NodePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,7 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
return nullptr;
case Node::Kind::ImplFunctionConventionName:
assert(false && "Already handled in ImplFunctionConvention");
return nullptr;
case Node::Kind::ImplErrorResult:
Printer << "@error ";
printChildren(Node, " ");
Expand Down
3 changes: 2 additions & 1 deletion lib/IDE/ModuleInterfacePrinting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ static bool printModuleInterfaceDecl(Decl *D,
// a cross-module extension.
if (!extensionHasClangNode(Ext)) {
auto ExtendedNominal = Ext->getExtendedNominal();
if (Ext->getModuleContext() == ExtendedNominal->getModuleContext())
if (!ExtendedNominal ||
Ext->getModuleContext() == ExtendedNominal->getModuleContext())
return false;
}
}
Expand Down
17 changes: 13 additions & 4 deletions lib/IRGen/Callee.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,28 @@ namespace irgen {

Signature Sig;

bool isFunctionPointerWithoutContext = false;

public:
/// Construct a FunctionPointer for an arbitrary pointer value.
/// We may add more arguments to this; try to use the other
/// constructors/factories if possible.
explicit FunctionPointer(KindTy kind, llvm::Value *value,
PointerAuthInfo authInfo,
const Signature &signature)
: Kind(kind), Value(value), AuthInfo(authInfo), Sig(signature) {
const Signature &signature,
bool isWithoutCtxt = false)
: Kind(kind), Value(value), AuthInfo(authInfo), Sig(signature),
isFunctionPointerWithoutContext(isWithoutCtxt) {
// The function pointer should have function type.
assert(value->getType()->getPointerElementType()->isFunctionTy());
// TODO: maybe assert similarity to signature.getType()?
}

// Temporary only!
explicit FunctionPointer(KindTy kind, llvm::Value *value,
const Signature &signature)
: FunctionPointer(kind, value, PointerAuthInfo(), signature) {}
const Signature &signature, bool
isWithoutCtxt = false)
: FunctionPointer(kind, value, PointerAuthInfo(), signature, isWithoutCtxt) {}

static FunctionPointer forDirect(IRGenModule &IGM,
llvm::Constant *value,
Expand Down Expand Up @@ -243,6 +248,10 @@ namespace irgen {

/// Form a FunctionPointer whose KindTy is ::Function.
FunctionPointer getAsFunction(IRGenFunction &IGF) const;

bool useStaticContextSize() const {
return isFunctionPointerWithoutContext;
}
};

class Callee {
Expand Down
41 changes: 27 additions & 14 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ void irgen::extractScalarResults(IRGenFunction &IGF, llvm::Type *bodyType,
std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
IRGenFunction &IGF, SILFunctionTypeRepresentation representation,
FunctionPointer functionPointer, llvm::Value *thickContext,
std::pair<bool, bool> values) {
std::pair<bool, bool> values, Size initialContextSize) {
assert(values.first || values.second);
bool emitFunction = values.first;
bool emitSize = values.second;
Expand Down Expand Up @@ -1997,11 +1997,16 @@ std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
}
llvm::Value *size = nullptr;
if (emitSize) {
auto *ptr = functionPointer.getRawPointer();
auto *descriptorPtr =
IGF.Builder.CreateBitCast(ptr, IGF.IGM.AsyncFunctionPointerPtrTy);
auto *sizePtr = IGF.Builder.CreateStructGEP(descriptorPtr, 1);
size = IGF.Builder.CreateLoad(sizePtr, IGF.IGM.getPointerAlignment());
if (functionPointer.useStaticContextSize()) {
size = llvm::ConstantInt::get(IGF.IGM.Int32Ty,
initialContextSize.getValue());
} else {
auto *ptr = functionPointer.getRawPointer();
auto *descriptorPtr =
IGF.Builder.CreateBitCast(ptr, IGF.IGM.AsyncFunctionPointerPtrTy);
auto *sizePtr = IGF.Builder.CreateStructGEP(descriptorPtr, 1);
size = IGF.Builder.CreateLoad(sizePtr, IGF.IGM.getPointerAlignment());
}
}
return {fn, size};
}
Expand Down Expand Up @@ -2270,7 +2275,8 @@ class AsyncCallEmission final : public CallEmission {
llvm::Value *dynamicContextSize32;
std::tie(calleeFunction, dynamicContextSize32) = getAsyncFunctionAndSize(
IGF, CurCallee.getOrigFunctionType()->getRepresentation(),
CurCallee.getFunctionPointer(), thickContext);
CurCallee.getFunctionPointer(), thickContext,
std::make_pair(true, true), layout.getSize());
auto *dynamicContextSize =
IGF.Builder.CreateZExt(dynamicContextSize32, IGF.IGM.SizeTy);
contextBuffer = emitAllocAsyncContext(IGF, dynamicContextSize);
Expand Down Expand Up @@ -4494,13 +4500,20 @@ llvm::Value *FunctionPointer::getPointer(IRGenFunction &IGF) const {
switch (Kind.value) {
case KindTy::Value::Function:
return Value;
case KindTy::Value::AsyncFunctionPointer:
auto *descriptorPtr =
IGF.Builder.CreateBitCast(Value, IGF.IGM.AsyncFunctionPointerPtrTy);
auto *addrPtr = IGF.Builder.CreateStructGEP(descriptorPtr, 0);
return IGF.emitLoadOfRelativePointer(
Address(addrPtr, IGF.IGM.getPointerAlignment()), /*isFar*/ false,
/*expectedType*/ getFunctionType()->getPointerTo());
case KindTy::Value::AsyncFunctionPointer: {
if (!isFunctionPointerWithoutContext) {
auto *descriptorPtr =
IGF.Builder.CreateBitCast(Value, IGF.IGM.AsyncFunctionPointerPtrTy);
auto *addrPtr = IGF.Builder.CreateStructGEP(descriptorPtr, 0);
return IGF.emitLoadOfRelativePointer(
Address(addrPtr, IGF.IGM.getPointerAlignment()), /*isFar*/ false,
/*expectedType*/ getFunctionType()->getPointerTo());
} else {
return IGF.Builder.CreateBitOrPointerCast(
Value, getFunctionType()->getPointerTo());
}
}

}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/IRGen/GenCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ namespace irgen {
std::pair<llvm::Value *, llvm::Value *> getAsyncFunctionAndSize(
IRGenFunction &IGF, SILFunctionTypeRepresentation representation,
FunctionPointer functionPointer, llvm::Value *thickContext,
std::pair<bool, bool> values = {true, true});
std::pair<bool, bool> values = {true, true},
Size initialContextSize = Size(0));
llvm::CallingConv::ID expandCallingConv(IRGenModule &IGM,
SILFunctionTypeRepresentation convention);

Expand Down
7 changes: 5 additions & 2 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2288,13 +2288,16 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
fn, NotForDefinition, false /*isDynamicallyReplaceableImplementation*/,
isa<PreviousDynamicFunctionRefInst>(i));
llvm::Value *value;
if (fn->isAsync()) {
auto isSpecialAsyncWithoutCtxtSize =
fn->isAsync() && fn->getName().equals("swift_task_future_wait");
if (fn->isAsync() && !isSpecialAsyncWithoutCtxtSize) {
value = IGM.getAddrOfAsyncFunctionPointer(fn);
value = Builder.CreateBitCast(value, fnPtr->getType());
} else {
value = fnPtr;
}
FunctionPointer fp = FunctionPointer(fnType, value, sig);
FunctionPointer fp =
FunctionPointer(fnType, value, sig, isSpecialAsyncWithoutCtxtSize);

// Store the function as a FunctionPointer so we can avoid bitcasting
// or thunking if we don't need to.
Expand Down
4 changes: 2 additions & 2 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
}

void visitMarkUninitializedInst(MarkUninitializedInst *MU) {
switch (MU->getKind()) {
switch (MU->getMarkUninitializedKind()) {
case MarkUninitializedInst::Var: *this << "[var] "; break;
case MarkUninitializedInst::RootSelf: *this << "[rootself] "; break;
case MarkUninitializedInst::CrossModuleRootSelf:
Expand All @@ -1466,7 +1466,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
*this << "[delegatingselfallocated] ";
break;
}

*this << getIDAndType(MU->getOperand());
}

Expand Down
9 changes: 8 additions & 1 deletion lib/SILGen/SILGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,14 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
fd->getResultInterfaceType(), fd->hasThrows(), fd->getThrowsLoc());
prepareEpilog(true, fd->hasThrows(), CleanupLocation(fd));

emitStmt(fd->getTypecheckedBody());
if (fd->isAsyncHandler()) {
// Async handlers are need to have their bodies emitted into a
// detached task.
// FIXME: Actually implement these properly.
B.createBuiltinTrap(fd->getTypecheckedBody());
} else {
emitStmt(fd->getTypecheckedBody());
}

emitEpilog(fd);

Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NominalTypeWalker : public ASTWalker {
/// (2) Walk over all ExtensionDecls to determine conformances.
if (auto *e = dyn_cast<ExtensionDecl>(D)) {
auto *ntd = e->getExtendedNominal();
if (!isa<ProtocolDecl>(ntd)) {
if (ntd && !isa<ProtocolDecl>(ntd)) {
for (auto *conformance : e->getLocalConformances()) {
if (isa<NormalProtocolConformance>(conformance)) {
auto *proto = conformance->getProtocol();
Expand Down
5 changes: 3 additions & 2 deletions lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class DIMemoryObjectInfo {

/// True if this is an initializer that initializes stored properties.
bool isNonDelegatingInit() const {
switch (MemoryInst->getKind()) {
switch (MemoryInst->getMarkUninitializedKind()) {
case MarkUninitializedInst::Var:
return false;
case MarkUninitializedInst::RootSelf:
Expand All @@ -210,7 +210,8 @@ class DIMemoryObjectInfo {
}

bool isRootSelf() const {
return MemoryInst->getKind() == MarkUninitializedInst::RootSelf;
return MemoryInst->getMarkUninitializedKind() ==
MarkUninitializedInst::RootSelf;
}

bool isDelegatingSelfAllocated() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const ParamDecl *getParamDeclFromOperand(SILValue value) {
bool isUseOfSelfInInitializer(Operand *oper) {
if (auto *PBI = dyn_cast<ProjectBoxInst>(oper->get())) {
if (auto *MUI = dyn_cast<MarkUninitializedInst>(PBI->getOperand())) {
switch (MUI->getKind()) {
switch (MUI->getMarkUninitializedKind()) {
case MarkUninitializedInst::Kind::Var:
return false;
case MarkUninitializedInst::Kind::RootSelf:
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Transforms/AllocBoxToStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
auto *User = HeapBox->getSingleUse()->getUser();
if (auto *MUI = dyn_cast<MarkUninitializedInst>(User)) {
HeapBox = MUI;
Kind = MUI->getKind();
Kind = MUI->getMarkUninitializedKind();
}
}

Expand Down
9 changes: 6 additions & 3 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3952,7 +3952,7 @@ class DeclDeserializer {
auto extendedType = MF.getType(extendedTypeID);
ctx.evaluator.cacheOutput(ExtendedTypeRequest{extension},
std::move(extendedType));
auto nominal = dyn_cast<NominalTypeDecl>(MF.getDecl(extendedNominalID));
auto nominal = dyn_cast_or_null<NominalTypeDecl>(MF.getDecl(extendedNominalID));
ctx.evaluator.cacheOutput(ExtendedNominalRequest{extension},
std::move(nominal));

Expand All @@ -3969,7 +3969,9 @@ class DeclDeserializer {
encodeLazyConformanceContextData(numConformances,
MF.DeclTypeCursor.GetCurrentBitNo()));

nominal->addExtension(extension);
if (nominal) {
nominal->addExtension(extension);
}

#ifndef NDEBUG
if (outerParams) {
Expand Down Expand Up @@ -6176,7 +6178,8 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
auto isConformanceReq = [](const Requirement &req) {
return req.getKind() == RequirementKind::Conformance;
};
if (conformanceCount != llvm::count_if(proto->getRequirementSignature(),
if (!isAllowModuleWithCompilerErrorsEnabled() &&
conformanceCount != llvm::count_if(proto->getRequirementSignature(),
isConformanceReq)) {
fatal(llvm::make_error<llvm::StringError>(
"serialized conformances do not match requirement signature",
Expand Down
15 changes: 11 additions & 4 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,8 @@ void Serializer::writeASTBlockEntity(
using namespace decls_block;

// The conformance must be complete, or we can't serialize it.
assert(conformance->isComplete());
assert(conformance->isComplete() ||
getASTContext().LangOpts.AllowModuleWithCompilerErrors);
assert(NormalConformancesToSerialize.hasRef(conformance));

auto protocol = conformance->getProtocol();
Expand Down Expand Up @@ -1541,6 +1542,8 @@ static bool shouldSerializeMember(Decl *D) {
case DeclKind::Extension:
case DeclKind::Module:
case DeclKind::PrecedenceGroup:
if (D->getASTContext().LangOpts.AllowModuleWithCompilerErrors)
return false;
llvm_unreachable("decl should never be a member");

case DeclKind::MissingMember:
Expand Down Expand Up @@ -5050,7 +5053,9 @@ static void collectInterestingNestedDeclarations(
if (!nominalParent) {
const DeclContext *DC = member->getDeclContext();
nominalParent = DC->getSelfNominalTypeDecl();
assert(nominalParent && "parent context is not a type or extension");
assert(nominalParent ||
nestedType->getASTContext().LangOpts.AllowModuleWithCompilerErrors &&
"parent context is not a type or extension");
}
nestedTypeDecls[nestedType->getName()].push_back({
S.addDeclRef(nominalParent),
Expand Down Expand Up @@ -5115,8 +5120,10 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
.push_back({ getKindForTable(D), addDeclRef(D) });
} else if (auto ED = dyn_cast<ExtensionDecl>(D)) {
const NominalTypeDecl *extendedNominal = ED->getExtendedNominal();
extensionDecls[extendedNominal->getName()]
.push_back({ extendedNominal, addDeclRef(D) });
if (extendedNominal) {
extensionDecls[extendedNominal->getName()]
.push_back({ extendedNominal, addDeclRef(D) });
}
} else if (auto OD = dyn_cast<OperatorDecl>(D)) {
operatorDecls[OD->getName()]
.push_back({ getStableFixity(OD->getFixity()), addDeclRef(D) });
Expand Down
Loading