Skip to content

Commit 924d151

Browse files
authored
---
yaml --- r: 348901 b: refs/heads/master c: f2b43e4 h: refs/heads/master i: 348899: 5c02690
1 parent d825276 commit 924d151

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
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: e40a6fd42d0eae6afee2fd380d6ee2d7c9fa1d9b
2+
refs/heads/master: f2b43e4bf0c5ecf152ccdf4eeecf0799a367fa8b
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/lib/SIL/SILProfiler.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ struct MapRegionCounters : public ASTWalker {
247247
if (skipExpr(E))
248248
return {true, E};
249249

250+
// Profiling for closures should be handled separately. Do not visit
251+
// closure expressions twice.
252+
if (isa<AbstractClosureExpr>(E) && !Parent.isNull())
253+
return {false, E};
254+
250255
// If AST visitation begins with an expression, the counter map must be
251256
// empty. Set up a counter for the root.
252257
if (Parent.isNull()) {
@@ -430,6 +435,20 @@ class SourceMappingRegion {
430435
assert(EndLoc && "Region has no end location");
431436
return *EndLoc;
432437
}
438+
439+
void print(llvm::raw_ostream &OS, const SourceManager &SM) const {
440+
OS << "[";
441+
if (hasStartLoc())
442+
getStartLoc().print(OS, SM);
443+
else
444+
OS << "?";
445+
OS << ", ";
446+
if (hasEndLoc())
447+
getEndLoc().print(OS, SM);
448+
else
449+
OS << "?";
450+
OS << "]";
451+
}
433452
};
434453

435454
/// An ASTWalker that maps ASTNodes to profiling counters.
@@ -591,6 +610,11 @@ struct PGOMapping : public ASTWalker {
591610
if (skipExpr(E))
592611
return {true, E};
593612

613+
// Profiling for closures should be handled separately. Do not visit
614+
// closure expressions twice.
615+
if (isa<AbstractClosureExpr>(E) && !Parent.isNull())
616+
return {false, E};
617+
594618
unsigned parent = getParentCounter();
595619

596620
if (Parent.isNull()) {
@@ -754,6 +778,11 @@ struct CoverageMapping : public ASTWalker {
754778
void pushRegion(ASTNode Node) {
755779
RegionStack.emplace_back(Node, getCounter(Node), Node.getStartLoc(),
756780
getEndLoc(Node));
781+
LLVM_DEBUG({
782+
llvm::dbgs() << "Pushed region: ";
783+
RegionStack.back().print(llvm::dbgs(), SM);
784+
llvm::dbgs() << "\n";
785+
});
757786
}
758787

759788
/// Replace the current region's count by pushing an incomplete region.
@@ -780,6 +809,8 @@ struct CoverageMapping : public ASTWalker {
780809
auto ParentIt = I;
781810
SourceLoc EndLoc = ParentIt->getEndLoc();
782811

812+
unsigned FirstPoppedIndex = SourceRegions.size();
813+
(void)FirstPoppedIndex;
783814
SourceRegions.push_back(std::move(*I++));
784815
for (; I != E; ++I) {
785816
if (!I->hasStartLoc())
@@ -789,6 +820,14 @@ struct CoverageMapping : public ASTWalker {
789820
SourceRegions.push_back(std::move(*I));
790821
}
791822

823+
LLVM_DEBUG({
824+
for (unsigned Idx = FirstPoppedIndex; Idx < SourceRegions.size(); ++Idx) {
825+
llvm::dbgs() << "Popped region: ";
826+
SourceRegions[Idx].print(llvm::dbgs(), SM);
827+
llvm::dbgs() << "\n";
828+
}
829+
});
830+
792831
RegionStack.erase(ParentIt, E);
793832
}
794833

@@ -1017,6 +1056,11 @@ struct CoverageMapping : public ASTWalker {
10171056
if (skipExpr(E))
10181057
return {true, E};
10191058

1059+
// Profiling for closures should be handled separately. Do not visit
1060+
// closure expressions twice.
1061+
if (isa<AbstractClosureExpr>(E) && !Parent.isNull())
1062+
return {false, E};
1063+
10201064
if (!RegionStack.empty())
10211065
extendRegion(E);
10221066

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_empty %s | %FileCheck %s
2+
3+
// Skip the sil prologue, which reproduces the swift source of this file
4+
// and confounds FileCheck.
5+
// CHECK-LABEL: sil @main
6+
7+
func singleDefaultArgument(i: Int = {
8+
// CHECK: sil_coverage_map {{.*}}closure #1 () -> Swift.Int in default argument 0
9+
// CHECK-NEXT: [[@LINE-2]]:37 -> [[@LINE+6]]:2 : 0
10+
// CHECK-NEXT: }
11+
struct SingleDefaultArgumentStruct {
12+
let sdasi: Int
13+
}
14+
return 2
15+
}()) {
16+
// CHECK: sil_coverage_map {{.*}}singleDefaultArgument(i: Swift.Int) -> ()
17+
// CHECK-NEXT: [[@LINE-2]]:6 -> [[@LINE+3]]:2 : 0
18+
// CHECK-NEXT: }
19+
print(i)
20+
}

trunk/utils/build-script-impl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,7 +3448,7 @@ for host in "${ALL_HOSTS[@]}"; do
34483448
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
34493449
# We don't have a toolchain so we should install to the specified dir
34503450
DYLIB_DIR="${INSTALL_DESTDIR}"
3451-
MODULE_DIR="${INSTALL_DESTDIR}"
3451+
MODULE_DIR="${INSTALL_DESTDIR}/${product}.swiftmodule/${SWIFT_HOST_VARIANT_ARCH}"
34523452
# Create the install dir if it doesn't exist
34533453
call mkdir -p "${INSTALL_DESTDIR}"
34543454
# Install libParser is necessary
@@ -3458,14 +3458,14 @@ for host in "${ALL_HOSTS[@]}"; do
34583458
else
34593459
# We have a toolchain so install to the toolchain
34603460
DYLIB_DIR="${host_install_destdir}${host_install_prefix}/lib/swift/${SWIFT_HOST_VARIANT}"
3461-
MODULE_DIR="${DYLIB_DIR}/${SWIFT_HOST_VARIANT_ARCH}"
3461+
MODULE_DIR="${DYLIB_DIR}/${product}.swiftmodule/${SWIFT_HOST_VARIANT_ARCH}"
34623462
fi
34633463
if [[ "${SKIP_SWIFTSYNTAX_SWIFTSIDE}" ]]; then
34643464
continue
34653465
fi
34663466
set_swiftsyntax_build_command
34673467
if [[ -z "${SKIP_INSTALL_SWIFTSYNTAX_MODULE}" ]] ; then
3468-
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --swiftmodule-dir "${MODULE_DIR}" --install
3468+
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --swiftmodule-base-name "${MODULE_DIR}" --install
34693469
else
34703470
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --install
34713471
fi

0 commit comments

Comments
 (0)