Skip to content

Commit 345e988

Browse files
authored
Merge pull request #22699 from apple/stable-update-5.1
Update Swift:master to work with new stable re-branch from swift-5.1-branch
2 parents 52b61f8 + 868e794 commit 345e988

Some content is hidden

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

58 files changed

+392
-277
lines changed

include/swift/Basic/FileSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace llvm {
2323
class Twine;
2424
}
2525

26-
namespace clang {
26+
namespace llvm {
2727
namespace vfs {
2828
class FileSystem;
2929
}
@@ -58,7 +58,7 @@ namespace swift {
5858

5959
namespace vfs {
6060
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
61-
getFileOrSTDIN(clang::vfs::FileSystem &FS,
61+
getFileOrSTDIN(llvm::vfs::FileSystem &FS,
6262
const llvm::Twine &Name, int64_t FileSize = -1,
6363
bool RequiresNullTerminator = true, bool IsVolatile = false);
6464
} // end namespace vfs

include/swift/Basic/SourceManager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace swift {
2626
/// This class manages and owns source buffers.
2727
class SourceManager {
2828
llvm::SourceMgr LLVMSourceMgr;
29-
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> FileSystem;
29+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem;
3030
unsigned CodeCompletionBufferID = 0U;
3131
unsigned CodeCompletionOffset;
3232

@@ -37,7 +37,7 @@ class SourceManager {
3737
///
3838
/// This is as much a hack to prolong the lifetime of status objects as it is
3939
/// to speed up stats.
40-
mutable llvm::DenseMap<StringRef, clang::vfs::Status> StatusCache;
40+
mutable llvm::DenseMap<StringRef, llvm::vfs::Status> StatusCache;
4141

4242
// \c #sourceLocation directive handling.
4343
struct VirtualFile {
@@ -49,8 +49,8 @@ class SourceManager {
4949
mutable std::pair<const char *, const VirtualFile*> CachedVFile = {nullptr, nullptr};
5050

5151
public:
52-
SourceManager(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> FS =
53-
clang::vfs::getRealFileSystem())
52+
SourceManager(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
53+
llvm::vfs::getRealFileSystem())
5454
: FileSystem(FS) {}
5555

5656
llvm::SourceMgr &getLLVMSourceMgr() {
@@ -60,11 +60,11 @@ class SourceManager {
6060
return LLVMSourceMgr;
6161
}
6262

63-
void setFileSystem(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> FS) {
63+
void setFileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
6464
FileSystem = FS;
6565
}
6666

67-
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> getFileSystem() {
67+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() {
6868
return FileSystem;
6969
}
7070

include/swift/Frontend/Frontend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class CompilerInstance {
430430

431431
DiagnosticEngine &getDiags() { return Diagnostics; }
432432

433-
clang::vfs::FileSystem &getFileSystem() { return *SourceMgr.getFileSystem(); }
433+
llvm::vfs::FileSystem &getFileSystem() { return *SourceMgr.getFileSystem(); }
434434

435435
ASTContext &getASTContext() {
436436
return *Context;

include/swift/Frontend/ParseableInterfaceSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
8080
CompilerInvocation &SubInvocation, StringRef InPath, StringRef OutPath);
8181

8282
static bool buildSwiftModuleFromSwiftInterface(
83-
clang::vfs::FileSystem &FS, DiagnosticEngine &Diags, SourceLoc DiagLoc,
83+
llvm::vfs::FileSystem &FS, DiagnosticEngine &Diags, SourceLoc DiagLoc,
8484
CompilerInvocation &SubInvocation, StringRef InPath, StringRef OutPath,
8585
StringRef ModuleCachePath, DependencyTracker *OuterTracker,
8686
bool ShouldSerializeDeps);

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,17 +1163,6 @@ FUNCTION(InstantiateObjCClass, swift_instantiateObjCClass, C_CC,
11631163
ATTRS(NoUnwind))
11641164
FUNCTION(ObjCAllocWithZone, objc_allocWithZone, C_CC,
11651165
RETURNS(ObjCPtrTy), ARGS(ObjCClassPtrTy), ATTRS(NoUnwind))
1166-
FUNCTION(ObjCRetain, objc_retain, C_CC,
1167-
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
1168-
FUNCTION(ObjCRelease, objc_release, C_CC,
1169-
RETURNS(VoidTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
1170-
FUNCTION(ObjCAutorelease, objc_autorelease, C_CC,
1171-
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
1172-
FUNCTION(ObjCRetainAutoreleasedReturnValue,
1173-
objc_retainAutoreleasedReturnValue, C_CC,
1174-
RETURNS(Int8PtrTy), ARGS(Int8PtrTy), ATTRS(NoUnwind))
1175-
FUNCTION(ObjCAutoreleaseReturnValue, objc_autoreleaseReturnValue, C_CC,
1176-
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
11771166
FUNCTION(ObjCMsgSend, objc_msgSend, C_CC,
11781167
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
11791168
FUNCTION(ObjCMsgSendStret, objc_msgSend_stret, C_CC,

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
496496
bool Invalid;
497497
unsigned StartLocCol =
498498
ClangContext.getSourceManager().getSpellingColumnNumber(
499-
RC->getLocStart(), &Invalid);
499+
RC->getBeginLoc(), &Invalid);
500500
if (Invalid)
501501
StartLocCol = 0;
502502

lib/AST/Builtins.cpp

Lines changed: 114 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,46 +1272,138 @@ swift::getLLVMIntrinsicIDForBuiltinWithOverflow(BuiltinValueKind ID) {
12721272
llvm_unreachable("Cannot convert the overflow builtin to llvm intrinsic.");
12731273
}
12741274

1275-
static Type DecodeIntrinsicType(ArrayRef<llvm::Intrinsic::IITDescriptor> &Table,
1276-
ArrayRef<Type> Tys, ASTContext &Context) {
1275+
namespace {
1276+
1277+
class IntrinsicTypeDecoder {
1278+
ArrayRef<llvm::Intrinsic::IITDescriptor> &Table;
1279+
ArrayRef<Type> TypeArguments;
1280+
ASTContext &Context;
1281+
public:
1282+
IntrinsicTypeDecoder(ArrayRef<llvm::Intrinsic::IITDescriptor> &table,
1283+
ArrayRef<Type> typeArguments, ASTContext &ctx)
1284+
: Table(table), TypeArguments(typeArguments), Context(ctx) {}
1285+
1286+
Type decodeImmediate();
1287+
1288+
/// Return the type argument at the given index.
1289+
Type getTypeArgument(unsigned index) {
1290+
if (index >= TypeArguments.size())
1291+
return Type();
1292+
return TypeArguments[index];
1293+
}
1294+
1295+
/// Create a pointer type.
1296+
Type makePointer(Type eltType, unsigned addrspace) {
1297+
// Reject non-default address space pointers.
1298+
if (addrspace)
1299+
return Type();
1300+
1301+
// For now, always ignore the element type and use RawPointer.
1302+
return Context.TheRawPointerType;
1303+
}
1304+
1305+
/// Create a vector type.
1306+
Type makeVector(Type eltType, unsigned width) {
1307+
return BuiltinVectorType::get(Context, eltType, width);
1308+
}
1309+
1310+
/// Return the first type or, if the second type is a vector type, a vector
1311+
/// of the first type of the same length as the second type.
1312+
Type maybeMakeVectorized(Type eltType, Type maybeVectorType) {
1313+
if (auto vectorType = maybeVectorType->getAs<BuiltinVectorType>()) {
1314+
return makeVector(eltType, vectorType->getNumElements());
1315+
}
1316+
return eltType;
1317+
}
1318+
};
1319+
1320+
} // end anonymous namespace
1321+
1322+
static Type DecodeIntrinsicType(ArrayRef<llvm::Intrinsic::IITDescriptor> &table,
1323+
ArrayRef<Type> typeArguments, ASTContext &ctx) {
1324+
return IntrinsicTypeDecoder(table, typeArguments, ctx).decodeImmediate();
1325+
}
1326+
1327+
Type IntrinsicTypeDecoder::decodeImmediate() {
12771328
typedef llvm::Intrinsic::IITDescriptor IITDescriptor;
12781329
IITDescriptor D = Table.front();
12791330
Table = Table.slice(1);
12801331
switch (D.Kind) {
1281-
default:
1282-
llvm_unreachable("Unhandled case");
1283-
case IITDescriptor::Half:
12841332
case IITDescriptor::MMX:
12851333
case IITDescriptor::Metadata:
1286-
case IITDescriptor::Vector:
12871334
case IITDescriptor::ExtendArgument:
12881335
case IITDescriptor::TruncArgument:
1336+
case IITDescriptor::HalfVecArgument:
12891337
case IITDescriptor::VarArg:
1338+
case IITDescriptor::Token:
1339+
case IITDescriptor::VecOfAnyPtrsToElt:
12901340
// These types cannot be expressed in swift yet.
12911341
return Type();
12921342

1293-
case IITDescriptor::Void: return TupleType::getEmpty(Context);
1294-
case IITDescriptor::Float: return Context.TheIEEE32Type;
1295-
case IITDescriptor::Double: return Context.TheIEEE64Type;
1296-
1343+
// Fundamental types.
1344+
case IITDescriptor::Void:
1345+
return TupleType::getEmpty(Context);
1346+
case IITDescriptor::Half:
1347+
return Context.TheIEEE16Type;
1348+
case IITDescriptor::Float:
1349+
return Context.TheIEEE32Type;
1350+
case IITDescriptor::Double:
1351+
return Context.TheIEEE64Type;
1352+
case IITDescriptor::Quad:
1353+
return Context.TheIEEE128Type;
12971354
case IITDescriptor::Integer:
12981355
return BuiltinIntegerType::get(D.Integer_Width, Context);
1299-
case IITDescriptor::Pointer:
1300-
if (D.Pointer_AddressSpace)
1301-
return Type(); // Reject non-default address space pointers.
1302-
1303-
// Decode but ignore the pointee. Just decode all IR pointers to unsafe
1304-
// pointer type.
1305-
(void)DecodeIntrinsicType(Table, Tys, Context);
1306-
return Context.TheRawPointerType;
1356+
1357+
// A vector of an immediate type.
1358+
case IITDescriptor::Vector: {
1359+
Type eltType = decodeImmediate();
1360+
if (!eltType) return Type();
1361+
return makeVector(eltType, D.Vector_Width);
1362+
}
1363+
1364+
// A pointer to an immediate type.
1365+
case IITDescriptor::Pointer: {
1366+
Type pointeeType = decodeImmediate();
1367+
if (!pointeeType) return Type();
1368+
return makePointer(pointeeType, D.Pointer_AddressSpace);
1369+
}
1370+
1371+
// A type argument.
13071372
case IITDescriptor::Argument:
1308-
if (D.getArgumentNumber() >= Tys.size())
1309-
return Type();
1310-
return Tys[D.getArgumentNumber()];
1373+
return getTypeArgument(D.getArgumentNumber());
1374+
1375+
// A pointer to a type argument.
1376+
case IITDescriptor::PtrToArgument: {
1377+
Type argType = getTypeArgument(D.getArgumentNumber());
1378+
if (!argType) return Type();
1379+
unsigned addrspace = 0; // An apparent limitation of LLVM.
1380+
return makePointer(argType, addrspace);
1381+
}
1382+
1383+
// A vector of the same width as a type argument.
1384+
case IITDescriptor::SameVecWidthArgument: {
1385+
Type maybeVectorType = getTypeArgument(D.getArgumentNumber());
1386+
if (!maybeVectorType) return Type();
1387+
Type eltType = decodeImmediate();
1388+
if (!eltType) return Type();
1389+
return maybeMakeVectorized(eltType, maybeVectorType);
1390+
}
1391+
1392+
// A pointer to the element type of a type argument, which must be a vector.
1393+
case IITDescriptor::PtrToElt: {
1394+
Type argType = getTypeArgument(D.getArgumentNumber());
1395+
if (!argType) return Type();
1396+
auto vecType = argType->getAs<BuiltinVectorType>();
1397+
if (!vecType) return Type();
1398+
unsigned addrspace = 0; // An apparent limitation of LLVM.
1399+
return makePointer(vecType->getElementType(), addrspace);
1400+
}
1401+
1402+
// A struct, which we translate as a tuple.
13111403
case IITDescriptor::Struct: {
13121404
SmallVector<TupleTypeElt, 5> Elts;
13131405
for (unsigned i = 0; i != D.Struct_NumElements; ++i) {
1314-
Type T = DecodeIntrinsicType(Table, Tys, Context);
1406+
Type T = decodeImmediate();
13151407
if (!T) return Type();
13161408

13171409
Elts.push_back(T);

lib/Basic/FileSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/Support/Path.h"
2121
#include "llvm/Support/Process.h"
2222
#include "llvm/Support/Signals.h"
23+
#include "llvm/Support/VirtualFileSystem.h"
2324

2425
using namespace swift;
2526

@@ -223,7 +224,7 @@ std::error_code swift::moveFileIfDifferent(const llvm::Twine &source,
223224
}
224225

225226
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
226-
swift::vfs::getFileOrSTDIN(clang::vfs::FileSystem &FS,
227+
swift::vfs::getFileOrSTDIN(llvm::vfs::FileSystem &FS,
227228
const llvm::Twine &Filename,
228229
int64_t FileSize,
229230
bool RequiresNullTerminator,

lib/Basic/Platform.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
138138
case llvm::Triple::Mesa3D:
139139
case llvm::Triple::Contiki:
140140
case llvm::Triple::AMDPAL:
141+
case llvm::Triple::HermitCore:
142+
case llvm::Triple::Hurd:
141143
return "";
142144
case llvm::Triple::Darwin:
143145
case llvm::Triple::MacOSX:

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx,
419419
case clang::BuiltinType::OCLClkEvent:
420420
case clang::BuiltinType::OCLQueue:
421421
case clang::BuiltinType::OCLReserveID:
422+
case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
423+
case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
424+
case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
425+
case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
426+
case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
427+
case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
428+
case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
429+
case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
430+
case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleRefStreamout:
431+
case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualRefStreamout:
432+
case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin:
433+
case clang::BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin:
422434
return OmissionTypeName();
423435

424436
// OpenMP types that don't have Swift equivalents.

0 commit comments

Comments
 (0)