Skip to content

Commit 8567332

Browse files
Merge pull request #2056 from apple/swift/tensorflow-merge
Merge 2020-10-28 into swift/tensorflow
2 parents b2bb309 + 6c50663 commit 8567332

File tree

668 files changed

+13426
-15875
lines changed

Some content is hidden

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

668 files changed

+13426
-15875
lines changed

clang/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
105105
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
106106
endif()
107107

108-
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
109108
option(LLVM_INSTALL_TOOLCHAIN_ONLY
110109
"Only include toolchain files in the 'install' target." OFF)
111110

clang/cmake/caches/Apple-stage2.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ set(LLVM_TOOLCHAIN_TOOLS
5858
llvm-size
5959
CACHE STRING "")
6060

61+
set(LLVM_BUILD_UTILS ON CACHE BOOL "")
62+
set(LLVM_INSTALL_UTILS ON CACHE BOOL "")
63+
set(LLVM_TOOLCHAIN_UTILITIES
64+
FileCheck
65+
yaml2obj
66+
CACHE STRING "")
67+
6168
set(LLVM_DISTRIBUTION_COMPONENTS
6269
clang
6370
LTO
@@ -66,6 +73,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
6673
cxx-headers
6774
Remarks
6875
${LLVM_TOOLCHAIN_TOOLS}
76+
${LLVM_TOOLCHAIN_UTILITIES}
6977
CACHE STRING "")
7078

7179
# test args

clang/docs/SourceBasedCodeCoverage.rst

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ directory structure will be created. Additionally, the following special
7979

8080
* "%h" expands out to the hostname of the machine running the program.
8181

82+
* "%t" expands out to the value of the ``TMPDIR`` environment variable. On
83+
Darwin, this is typically set to a temporary scratch directory.
84+
8285
* "%Nm" expands out to the instrumented binary's signature. When this pattern
8386
is specified, the runtime creates a pool of N raw profiles which are used for
8487
on-line profile merging. The runtime takes care of selecting a raw profile

clang/include/clang/Basic/CodeGenOptions.def

+4
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ CODEGENOPT(KeepStaticConsts, 1, 0)
393393
/// Whether to not follow the AAPCS that enforce at least one read before storing to a volatile bitfield
394394
CODEGENOPT(ForceAAPCSBitfieldLoad, 1, 0)
395395

396+
/// Assume that by-value parameters do not alias any other values.
397+
CODEGENOPT(PassByValueIsNoAlias, 1, 0)
398+
399+
396400
#undef CODEGENOPT
397401
#undef ENUM_CODEGENOPT
398402
#undef VALUE_CODEGENOPT

clang/include/clang/Basic/DiagnosticGroups.td

+3-1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi,
234234
def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
235235
def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
236236
def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
237+
def FormatInsufficientArgs : DiagGroup<"format-insufficient-args">;
237238
def FormatExtraArgs : DiagGroup<"format-extra-args">;
238239
def FormatZeroLength : DiagGroup<"format-zero-length">;
239240

@@ -840,7 +841,8 @@ def FormatPedantic : DiagGroup<"format-pedantic">;
840841
def FormatTypeConfusion : DiagGroup<"format-type-confusion">;
841842
def Format : DiagGroup<"format",
842843
[FormatExtraArgs, FormatZeroLength, NonNull,
843-
FormatSecurity, FormatY2K, FormatInvalidSpecifier]>,
844+
FormatSecurity, FormatY2K, FormatInvalidSpecifier,
845+
FormatInsufficientArgs]>,
844846
DiagCategory<"Format String Issue">;
845847
def FormatNonLiteral : DiagGroup<"format-nonliteral">;
846848
def Format2 : DiagGroup<"format=2",

clang/include/clang/Basic/DiagnosticSemaKinds.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -8945,7 +8945,7 @@ def note_array_declared_here : Note<
89458945
"array %0 declared here">;
89468946

89478947
def warn_printf_insufficient_data_args : Warning<
8948-
"more '%%' conversions than data arguments">, InGroup<Format>;
8948+
"more '%%' conversions than data arguments">, InGroup<FormatInsufficientArgs>;
89498949
def warn_printf_data_arg_not_used : Warning<
89508950
"data argument not used by format string">, InGroup<FormatExtraArgs>;
89518951
def warn_format_invalid_conversion : Warning<

clang/include/clang/Driver/Options.td

+5-2
Original file line numberDiff line numberDiff line change
@@ -1457,11 +1457,11 @@ def fno_pch_validate_input_files_content:
14571457
Group<f_Group>, Flags<[DriverOption]>;
14581458
def fpch_instantiate_templates:
14591459
Flag <["-"], "fpch-instantiate-templates">,
1460-
Group<f_Group>, Flags<[CC1Option]>,
1460+
Group<f_Group>, Flags<[CC1Option, CoreOption]>,
14611461
HelpText<"Instantiate templates already while building a PCH">;
14621462
def fno_pch_instantiate_templates:
14631463
Flag <["-"], "fno-pch-instantiate-templates">,
1464-
Group<f_Group>, Flags<[CC1Option]>;
1464+
Group<f_Group>, Flags<[CC1Option, CoreOption]>;
14651465
defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
14661466
"code for uses of this PCH that assumes an explicit object file will be built for the PCH">;
14671467
defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ",
@@ -4339,6 +4339,9 @@ def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">,
43394339
def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], "fcompatibility-qualified-id-block-type-checking">,
43404340
HelpText<"Allow using blocks with parameters of more specific type than "
43414341
"the type system guarantees when a parameter is qualified id">;
4342+
def fpass_by_value_is_noalias: Flag<["-"], "fpass-by-value-is-noalias">,
4343+
HelpText<"Allows assuming by-value parameters do not alias any other value. "
4344+
"Has no effect on non-trivially-copyable classes in C++.">, Group<f_Group>;
43424345

43434346
// FIXME: Remove these entirely once functionality/tests have been excised.
43444347
def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group<f_Group>,

clang/lib/APINotes/APINotesYAMLCompiler.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -429,22 +429,6 @@ namespace llvm {
429429
}
430430
};
431431

432-
template <>
433-
struct ScalarTraits<VersionTuple> {
434-
static void output(const VersionTuple &value, void*,
435-
llvm::raw_ostream &out) {
436-
out << value;
437-
}
438-
static StringRef input(StringRef scalar, void*, VersionTuple &value) {
439-
if (value.tryParse(scalar))
440-
return "not a version number in the form XX.YY";
441-
442-
return StringRef();
443-
}
444-
445-
static QuotingType mustQuote(StringRef) { return QuotingType::None; }
446-
};
447-
448432
template <>
449433
struct MappingTraits<Param> {
450434
static void mapping(IO &io, Param& p) {

clang/lib/AST/ASTImporter.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -1743,12 +1743,28 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
17431743
Decl *ImportedDecl = *ImportedOrErr;
17441744
FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
17451745
if (FieldFrom && FieldTo) {
1746-
const RecordType *RecordFrom = FieldFrom->getType()->getAs<RecordType>();
1747-
const RecordType *RecordTo = FieldTo->getType()->getAs<RecordType>();
1748-
if (RecordFrom && RecordTo) {
1749-
RecordDecl *FromRecordDecl = RecordFrom->getDecl();
1750-
RecordDecl *ToRecordDecl = RecordTo->getDecl();
1746+
RecordDecl *FromRecordDecl = nullptr;
1747+
RecordDecl *ToRecordDecl = nullptr;
1748+
// If we have a field that is an ArrayType we need to check if the array
1749+
// element is a RecordDecl and if so we need to import the defintion.
1750+
if (FieldFrom->getType()->isArrayType()) {
1751+
// getBaseElementTypeUnsafe(...) handles multi-dimensonal arrays for us.
1752+
FromRecordDecl = FieldFrom->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
1753+
ToRecordDecl = FieldTo->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
1754+
}
1755+
1756+
if (!FromRecordDecl || !ToRecordDecl) {
1757+
const RecordType *RecordFrom =
1758+
FieldFrom->getType()->getAs<RecordType>();
1759+
const RecordType *RecordTo = FieldTo->getType()->getAs<RecordType>();
1760+
1761+
if (RecordFrom && RecordTo) {
1762+
FromRecordDecl = RecordFrom->getDecl();
1763+
ToRecordDecl = RecordTo->getDecl();
1764+
}
1765+
}
17511766

1767+
if (FromRecordDecl && ToRecordDecl) {
17521768
if (FromRecordDecl->isCompleteDefinition() &&
17531769
!ToRecordDecl->isCompleteDefinition()) {
17541770
Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);

clang/lib/AST/DeclObjC.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,8 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
949949
if (!Redecl && isRedeclaration()) {
950950
// This is the last redeclaration, go back to the first method.
951951
return cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
952-
isInstanceMethod());
952+
isInstanceMethod(),
953+
/*AllowHidden=*/true);
953954
}
954955

955956
return Redecl ? Redecl : this;
@@ -982,7 +983,8 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
982983
if (isRedeclaration()) {
983984
// It is possible that we have not done deserializing the ObjCMethod yet.
984985
ObjCMethodDecl *MD =
985-
cast<ObjCContainerDecl>(CtxD)->getMethod(Sel, isInstanceMethod());
986+
cast<ObjCContainerDecl>(CtxD)->getMethod(Sel, isInstanceMethod(),
987+
/*AllowHidden=*/true);
986988
return MD ? MD : this;
987989
}
988990

@@ -1299,8 +1301,9 @@ void ObjCMethodDecl::getOverriddenMethods(
12991301
const ObjCMethodDecl *Method = this;
13001302

13011303
if (Method->isRedeclaration()) {
1302-
Method = cast<ObjCContainerDecl>(Method->getDeclContext())->
1303-
getMethod(Method->getSelector(), Method->isInstanceMethod());
1304+
Method = cast<ObjCContainerDecl>(Method->getDeclContext())
1305+
->getMethod(Method->getSelector(), Method->isInstanceMethod(),
1306+
/*AllowHidden=*/true);
13041307
}
13051308

13061309
if (Method->isOverriding()) {

clang/lib/Basic/Targets/OSTargets.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
154154
MinVersion = llvm::VersionTuple(5U);
155155
break;
156156
default:
157-
llvm_unreachable("Unexpected OS");
157+
// Conservatively return 8 bytes if OS is unknown.
158+
return 64;
158159
}
159160

160161
unsigned Major, Minor, Micro;

clang/lib/CodeGen/CGCall.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,13 @@ void CodeGenModule::ConstructAttributeList(
21922192
if (AI.getIndirectByVal())
21932193
Attrs.addByValAttr(getTypes().ConvertTypeForMem(ParamType));
21942194

2195+
auto *Decl = ParamType->getAsRecordDecl();
2196+
if (CodeGenOpts.PassByValueIsNoAlias && Decl &&
2197+
Decl->getArgPassingRestrictions() == RecordDecl::APK_CanPassInRegs)
2198+
// When calling the function, the pointer passed in will be the only
2199+
// reference to the underlying object. Mark it accordingly.
2200+
Attrs.addAttribute(llvm::Attribute::NoAlias);
2201+
21952202
CharUnits Align = AI.getIndirectAlign();
21962203

21972204
// In a byval argument, it is important that the required
@@ -3746,10 +3753,7 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, QualType ArgType,
37463753
}
37473754

37483755
SanitizerScope SanScope(this);
3749-
assert(RV.isScalar());
3750-
llvm::Value *V = RV.getScalarVal();
3751-
llvm::Value *Cond =
3752-
Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
3756+
llvm::Value *Cond = EmitNonNullRValueCheck(RV, ArgType);
37533757
llvm::Constant *StaticData[] = {
37543758
EmitCheckSourceLocation(ArgLoc), EmitCheckSourceLocation(AttrLoc),
37553759
llvm::ConstantInt::get(Int32Ty, ArgNo + 1),

clang/lib/CodeGen/CGExpr.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,13 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
11701170
return Address(EmitScalarExpr(E), Align);
11711171
}
11721172

1173+
llvm::Value *CodeGenFunction::EmitNonNullRValueCheck(RValue RV, QualType T) {
1174+
llvm::Value *V = RV.getScalarVal();
1175+
if (auto MPT = T->getAs<MemberPointerType>())
1176+
return CGM.getCXXABI().EmitMemberPointerIsNotNull(*this, V, MPT);
1177+
return Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
1178+
}
1179+
11731180
RValue CodeGenFunction::GetUndefRValue(QualType Ty) {
11741181
if (Ty->isVoidType())
11751182
return RValue::get(nullptr);

clang/lib/CodeGen/CodeGenFunction.h

+3
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,9 @@ class CodeGenFunction : public CodeGenTypeCache {
35633563
// LValue Expression Emission
35643564
//===--------------------------------------------------------------------===//
35653565

3566+
/// Create a check that a scalar RValue is non-null.
3567+
llvm::Value *EmitNonNullRValueCheck(RValue RV, QualType T);
3568+
35663569
/// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
35673570
RValue GetUndefRValue(QualType Ty);
35683571

clang/lib/CodeGen/SwiftCallingConv.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,24 @@ void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) {
9393
// Just add it all as opaque.
9494
addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
9595

96-
// Everything else is scalar and should not convert as an LLVM aggregate.
96+
// Atomic types.
97+
} else if (const auto *atomicType = type->getAs<AtomicType>()) {
98+
auto valueType = atomicType->getValueType();
99+
auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
100+
auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
101+
102+
addTypedData(atomicType->getValueType(), begin);
103+
104+
// Add atomic padding.
105+
auto atomicPadding = atomicSize - valueSize;
106+
if (atomicPadding > CharUnits::Zero())
107+
addOpaqueData(begin + valueSize, begin + atomicSize);
108+
109+
// Everything else is scalar and should not convert as an LLVM aggregate.
97110
} else {
98111
// We intentionally convert as !ForMem because we want to preserve
99112
// that a type was an i1.
100-
auto llvmType = CGM.getTypes().ConvertType(type);
113+
auto *llvmType = CGM.getTypes().ConvertType(type);
101114
addTypedData(llvmType, begin);
102115
}
103116
}

0 commit comments

Comments
 (0)