Skip to content

Commit be0819c

Browse files
committed
---
yaml --- r: 345073 b: refs/heads/master c: b2cb64c h: refs/heads/master i: 345071: 276a87a
1 parent 2b0fe67 commit be0819c

File tree

10 files changed

+41
-19
lines changed

10 files changed

+41
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 918e250e5ca22a250532910ccafd9e572333d03d
2+
refs/heads/master: b2cb64cc48c38f5102cc721a153698a47d862813
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class ExponentialGrowthAppendingBinaryByteStream
5959

6060
/// This is an optimized version of \c writeBytes that assumes we know the
6161
/// size of \p Value at compile time (which in particular holds for integers).
62-
/// It does so by avoiding the memcopy that \c writeBytes requires to copy
63-
/// the arbitrarily sized Buffer to the output buffer and using a direct
64-
/// memory assignment instead.
65-
/// This assumes that the enianess of this steam is the same as the native
62+
/// It does so by exposing the memcpy to the optimizer along with the size
63+
/// of the value being assigned; the compiler can then optimize the memcpy
64+
/// into a fixed set of instructions.
65+
/// This assumes that the endianess of this steam is the same as the native
6666
/// endianess on the executing machine. No endianess transformations are
6767
/// performed.
6868
template<typename T>
@@ -77,7 +77,7 @@ class ExponentialGrowthAppendingBinaryByteStream
7777
Data.resize(RequiredSize);
7878
}
7979

80-
*(T *)(Data.data() + Offset) = Value;
80+
::memcpy(Data.data() + Offset, &Value, sizeof Value);
8181

8282
return llvm::Error::success();
8383
}

trunk/include/swift/SIL/SILBuilder.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ class SILBuilder {
264264
/// setInsertionPoint - Set the insertion point to insert before the specified
265265
/// instruction.
266266
void setInsertionPoint(SILInstruction *I) {
267+
assert(I && "can't set insertion point to a null instruction");
267268
setInsertionPoint(I->getParent(), I->getIterator());
268269
}
269270

@@ -276,6 +277,7 @@ class SILBuilder {
276277
/// setInsertionPoint - Set the insertion point to insert at the end of the
277278
/// specified block.
278279
void setInsertionPoint(SILBasicBlock *BB) {
280+
assert(BB && "can't set insertion point to a null basic block");
279281
setInsertionPoint(BB, BB->end());
280282
}
281283

@@ -2202,7 +2204,9 @@ class SavedInsertionPointRAII {
22022204
SavedInsertionPointRAII &operator=(SavedInsertionPointRAII &&) = delete;
22032205

22042206
~SavedInsertionPointRAII() {
2205-
if (SavedIP.is<SILInstruction *>()) {
2207+
if (SavedIP.isNull()) {
2208+
Builder.clearInsertionPoint();
2209+
} else if (SavedIP.is<SILInstruction *>()) {
22062210
Builder.setInsertionPoint(SavedIP.get<SILInstruction *>());
22072211
} else {
22082212
Builder.setInsertionPoint(SavedIP.get<SILBasicBlock *>());

trunk/lib/IDE/CodeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
15981598
Type ExprType;
15991599

16001600
/// Whether the expr is of statically inferred metatype.
1601-
bool IsStaticMetatype;
1601+
bool IsStaticMetatype = false;
16021602

16031603
/// User-provided base type for LookupKind::Type completions.
16041604
Type BaseType;

trunk/lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
395395

396396
Expr *getContainingExpr(size_t index) const {
397397
if (ExprStack.size() > index)
398-
return ExprStack.end()[-(index + 1)];
398+
return ExprStack.end()[-std::ptrdiff_t(index + 1)];
399399
return nullptr;
400400
}
401401

trunk/lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,15 @@ class SILPerformanceInliner {
109109
/// increasing the code size.
110110
TrivialFunctionThreshold = 18,
111111

112-
/// Configuration for the "soft" caller block limit.
112+
/// Configuration for the "soft" caller block limit. When changing, make sure
113+
/// you update BlockLimitMaxIntNumerator.
113114
BlockLimitDenominator = 3000,
114115

116+
/// Computations with BlockLimitDenominator will overflow with numerators
117+
/// >= this value. This equals cbrt(INT_MAX) * cbrt(BlockLimitDenominator);
118+
/// we hardcode its value because std::cbrt() is not constexpr.
119+
BlockLimitMaxIntNumerator = 18608,
120+
115121
/// No inlining is done if the caller has more than this number of blocks.
116122
OverallCallerBlockLimit = 400,
117123

@@ -418,10 +424,13 @@ bool SILPerformanceInliner::isProfitableToInline(
418424
// We reduce the benefit if the caller is too large. For this we use a
419425
// cubic function on the number of caller blocks. This starts to prevent
420426
// inlining at about 800 - 1000 caller blocks.
421-
int blockMinus =
422-
(NumCallerBlocks * NumCallerBlocks) / BlockLimitDenominator *
423-
NumCallerBlocks / BlockLimitDenominator;
424-
Benefit -= blockMinus;
427+
if (NumCallerBlocks < BlockLimitMaxIntNumerator)
428+
Benefit -=
429+
(NumCallerBlocks * NumCallerBlocks) / BlockLimitDenominator *
430+
NumCallerBlocks / BlockLimitDenominator;
431+
else
432+
// The calculation in the if branch would overflow if we performed it.
433+
Benefit = 0;
425434

426435
// If we have profile info - use it for final inlining decision.
427436
auto *bb = AI.getInstruction()->getParent();

trunk/lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,13 @@ ReabstractionInfo::createSubstitutedType(SILFunction *OrigF,
730730
// FIXME: Some of the added new requirements may not have been taken into
731731
// account by the substGenericArgs. So, canonicalize in the context of the
732732
// specialized signature.
733-
FnTy = cast<SILFunctionType>(
734-
CanSpecializedGenericSig->getCanonicalTypeInContext(FnTy));
733+
if (CanSpecializedGenericSig)
734+
FnTy = cast<SILFunctionType>(
735+
CanSpecializedGenericSig->getCanonicalTypeInContext(FnTy));
736+
else {
737+
FnTy = cast<SILFunctionType>(FnTy->getCanonicalType());
738+
assert(!FnTy->hasTypeParameter() && "Type parameters outside generic context?");
739+
}
735740
}
736741
assert(FnTy);
737742

trunk/lib/Sema/TypeCheckCaptures.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
719719
DynamicSelfCaptureLoc,
720720
DynamicSelf,
721721
AFR);
722-
AFR.getBody()->walk(finder);
722+
if (AFR.getBody())
723+
AFR.getBody()->walk(finder);
723724

724725
unsigned inoutCount = 0;
725726
for (auto C : Captures) {

trunk/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ static bool passCursorInfoForDecl(SourceFile* SF,
873873
auto ClangNode = VD->getClangNode();
874874
if (ClangNode) {
875875
auto ClangMod = Importer->getClangOwningModule(ClangNode);
876-
ModuleName = ClangMod->getFullModuleName();
876+
if (ClangMod)
877+
ModuleName = ClangMod->getFullModuleName();
877878
} else if (VD->getLoc().isInvalid() && VD->getModuleContext() != MainModule) {
878879
ModuleName = VD->getModuleContext()->getName().str();
879880
}

trunk/tools/SourceKit/tools/sourcekitd/include/sourcekitd/CompactArray.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ class CompactArrayReaderImpl {
102102
CompactArrayReaderImpl(void *Buf) : Buf(Buf) {}
103103

104104
uint64_t getEntriesBufSize() const {
105-
return *(uint64_t*)Buf;
105+
uint64_t result;
106+
std::memcpy(&result, Buf, sizeof result);
107+
return result;
106108
}
107109
const uint8_t *getEntriesBufStart() const {
108110
return (const uint8_t *)(((uint64_t*)Buf)+1);

0 commit comments

Comments
 (0)