Skip to content

[pull] swiftwasm from apple:master #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
42345da
SymbolGraph: Move pathComponents up and include interfaceLanguage
bitjammer Jan 28, 2020
37e403d
Compile libraries in testcases with -parse-as-library (NFC)
adrian-prantl Jan 29, 2020
f2c61d8
Bug fixes for type fingerprints
Jan 28, 2020
bbffc09
Tests for type fingerprints are enabled.
Jan 28, 2020
b0786e7
Fix propagation of guaranteed phi args during DiagnoseUnreachable.
atrick Jan 29, 2020
1af49ec
Fix an EscapeAnalysis assert to handle recent changes.
atrick Jan 29, 2020
f70f60b
Merge pull request #29526 from atrick/fix-guaranteed-phi
atrick Jan 29, 2020
b2083db
[ConstraintSystem] Add a fix to allow conversion between non-class ty…
xedin Jan 29, 2020
ec3b783
[Diagnostics] Improve diagnostic for invalid conversion to AnyObject
xedin Jan 29, 2020
7710ee8
Merge pull request #29527 from atrick/fix-escape-assert
swift-ci Jan 29, 2020
dd09401
Merge pull request #29528 from xedin/anyobject-conversion-diagnostics
xedin Jan 29, 2020
ffa6bf4
Fix memory leaks in ThreadBarriers.swift (#12212)
chrisamanse Jan 29, 2020
9676625
Merge pull request #29522 from adrian-prantl/test-update
adrian-prantl Jan 29, 2020
3fff5dd
[ConstraintSystem] Extend metatype instance type mismatch coverage
xedin Jan 29, 2020
0bd1e61
[build][gardening] adjust one more framework path (#29529)
edymtt Jan 29, 2020
17d9d20
Improve one of the comments in COWArrayOpts.
atrick Jan 29, 2020
0440e91
Try setting mod times explicitly to fix unreproducible ci failure.
Jan 29, 2020
4028ac2
EscapeAnalysis: add support for access markers.
atrick Jan 29, 2020
5b8ba88
Merge pull request #29525 from davidungar/type-prints-off-by-default2
Jan 29, 2020
f7b0cbc
Merge pull request #29531 from xedin/diag-all-metatype-mismatches
xedin Jan 29, 2020
b896013
Add source annotation to SILPrinter under flag -sil-print-sourceinfo …
meg-gupta Jan 29, 2020
454b30d
Merge pull request #29532 from atrick/comment-cow-array
swift-ci Jan 29, 2020
3c86061
Sema: Fix module interface printing of inherited generic initializers
slavapestov Jan 29, 2020
5661bff
Merge pull request #29533 from davidungar/putative-fix-for-rdar-58959…
swift-ci Jan 29, 2020
2e1e428
Added ability to add fingerprint via #
Jan 29, 2020
2c39aa1
Merge pull request #29534 from atrick/escape-access-marker
atrick Jan 29, 2020
b872052
Merge pull request #29535 from slavapestov/inherited-init-sugar-fix
slavapestov Jan 29, 2020
e13ea48
Private method should be for non-Windows only
Jan 29, 2020
2d59365
Merge pull request #29414 from bitjammer/acgarland/rdar-58853310-inte…
bitjammer Jan 29, 2020
d2ad3dc
[NFC] Commit a regression test for rdar://58960414
CodaFi Jan 29, 2020
286781f
Add a unit test for an individual node change, & add ability to set f…
Jan 30, 2020
30709ce
Merge pull request #29539 from davidungar/type-fingerprints-off-by-de…
Jan 30, 2020
6f6d786
Merge pull request #29536 from chrisamanse/fixWindows
compnerd Jan 30, 2020
9bd6385
Sema: Fix duplicate diagnostic spam with 'Self' in properties
slavapestov Jan 29, 2020
f4a5301
Sema: Fix crash when property type references type alias with unsatis…
slavapestov Jan 30, 2020
be37141
Revert "build: simplify version tracking logic"
shahmishal Jan 30, 2020
f0b7fb9
Merge pull request #29542 from slavapestov/self-diagnostic-spam
slavapestov Jan 30, 2020
dcaa950
[CSDiag] Removing unused FailureDiagnosis::visitTryExpr
LucianoPAlmeida Jan 30, 2020
2d10a8a
[ConstraintSystem] Extend function type conversion mismatch coverage
xedin Jan 30, 2020
d171b30
Allow fine-grained-dependency-include-intrafile in tests for compatib…
Jan 30, 2020
458ae7b
Use -fine-grained-dependency-include-intrafile for compatibility with…
Jan 30, 2020
6debe3d
[ConstraintSystem] Don't produce conformance fixes for mismatches ass…
xedin Jan 30, 2020
836d88f
Merge pull request #29546 from LucianoPAlmeida/visit-try-expr
xedin Jan 30, 2020
4ef4cd6
Merge pull request #29544 from slavapestov/conditional-requirements-c…
slavapestov Jan 30, 2020
9511295
Merge pull request #29548 from davidungar/type-fingerprints-off-by-de…
Jan 30, 2020
a572c4b
Merge pull request #29549 from xedin/diag-all-function-type-mismatches
xedin Jan 30, 2020
a34b044
Merge pull request #29545 from apple/revert-29040-version-control
shahmishal Jan 30, 2020
3375b36
Search nested types tables in parent modules
CodaFi Jan 30, 2020
e121cb0
Revert "[SourceKit] Disable module system headers validation"
rintaro Jan 30, 2020
cb20d0e
Revert "[CodeCompletion] Disable module system headers validation"
rintaro Jan 30, 2020
a56cd12
Merge pull request #29554 from CodaFi/module-scope-context-is-king
swift-ci Jan 31, 2020
59fd697
Merge pull request #29538 from CodaFi/heavy-industrial-runoff
CodaFi Jan 31, 2020
b3e4ac8
Merge pull request #29555 from rintaro/revert-sourcekit-rdar58550697
rintaro Jan 31, 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
5 changes: 4 additions & 1 deletion cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,10 @@ function(add_swift_target_library name)

list(APPEND swiftlib_swift_compile_flags_all "-Fsystem" "${ios_support_frameworks_path}")
list(APPEND swiftlib_c_compile_flags_all "-iframework" "${ios_support_frameworks_path}")
list(APPEND swiftlib_link_flags_all "-F" "${ios_support_frameworks_path}")
# We collate -F with the framework path to avoid unwanted deduplication
# of options by target_compile_options -- this way no undesired
# side effects are introduced should a new search path be added.
list(APPEND swiftlib_link_flags_all "-F${ios_support_frameworks_path}")
endif()

if(sdk IN_LIST SWIFT_APPLE_PLATFORMS AND SWIFTLIB_IS_SDK_OVERLAY)
Expand Down
17 changes: 16 additions & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ ERROR(cannot_convert_initializer_value,none,
"cannot convert value of type %0 to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_protocol,none,
"value of type %0 does not conform to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_anyobject,none,
"value of type %0 expected to be instance of class or "
"class-constrained type",
(Type, Type))
ERROR(cannot_convert_initializer_value_nil,none,
"'nil' cannot initialize specified type %0", (Type))

Expand All @@ -346,6 +350,10 @@ ERROR(cannot_convert_to_return_type,none,
(Type,Type))
ERROR(cannot_convert_to_return_type_protocol,none,
"return expression of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_return_type_to_anyobject,none,
"return expression of type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_to_return_type_nil,none,
"'nil' is incompatible with return type %0", (Type))

Expand Down Expand Up @@ -440,7 +448,10 @@ NOTE(candidate_performs_illegal_ephemeral_conv,none,

ERROR(cannot_convert_argument_value_protocol,none,
"argument type %0 does not conform to expected type %1", (Type, Type))

ERROR(cannot_convert_argument_value_anyobject,none,
"argument type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_argument_value_nil,none,
"'nil' is not compatible with expected argument type %0", (Type))

Expand Down Expand Up @@ -536,6 +547,10 @@ NOTE(assign_protocol_conformance_fix_it,none,
ERROR(cannot_convert_assign_protocol,none,
"value of type %0 does not conform to %1 in assignment",
(Type, Type))
ERROR(cannot_convert_assign_anyobject,none,
"value of type %0 expected to be an instance of "
"a class or class-constrained type in assignment",
(Type, Type))
ERROR(cannot_convert_assign_nil,none,
"'nil' cannot be assigned to type %0", (Type))

Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/FineGrainedDependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ class SourceFileDepGraph {
compoundNamesByRDK);

static constexpr char noncascadingOrPrivatePrefix = '#';
static constexpr char nameFingerprintSeparator = ',';

static std::string noncascading(std::string name);

Expand Down
3 changes: 3 additions & 0 deletions include/swift/Basic/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ class SourceManager {
llvm::Optional<unsigned> resolveOffsetForEndOfLine(unsigned BufferId,
unsigned Line) const;

/// Get the length of the line
llvm::Optional<unsigned> getLineLength(unsigned BufferId, unsigned Line) const;

SourceLoc getLocForLineCol(unsigned BufferId, unsigned Line, unsigned Col) const {
auto Offset = resolveFromLineCol(BufferId, Line, Col);
return Offset.hasValue() ? getLocForOffset(BufferId, Offset.getValue()) :
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Driver/FineGrainedDependencyDriverGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class ModuleDepGraph {
/// Call \p fn for each node whose key matches \p key.
void
forEachMatchingNode(const DependencyKey &key,
function_ref<void(const ModuleDepGraphNode *)>) const;
function_ref<void(ModuleDepGraphNode *)>) const;

void forEachNodeInJob(StringRef swiftDeps,
function_ref<void(ModuleDepGraphNode *)>) const;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ HelpText<"Emit dot files every time driver imports an fine-grained swiftdeps fil

def fine_grained_dependency_include_intrafile :
Flag<["-"], "fine-grained-dependency-include-intrafile">,
InternalDebugOpt,
Flags<[FrontendOption, HelpHidden]>,
HelpText<"Include within-file dependencies.">;

def emit_fine_grained_dependency_sourcefile_dot_files :
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Analysis/EscapeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class EscapeAnalysis : public BottomUpIPAnalysis {

/// Sets the outgoing points-to edge. The \p To node must be a Content node.
void setPointsToEdge(CGNode *To) {
assert(!To->mergeTo);
assert(!To->isMerged);
assert(To->Type == NodeType::Content &&
"Wrong node type for points-to edge");
pointsToIsEdge = true;
Expand Down
56 changes: 42 additions & 14 deletions lib/AST/FineGrainedDependenciesSourceFileDepGraphConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,10 @@ class SourceFileDepGraphConstructor {
for (const auto &contextNameFingerprint : contextNameFingerprints) {
auto p = g.findExistingNodePairOrCreateAndAddIfNew(
kind, contextNameFingerprint);
// When we don't have a fingerprint yet, must rebuild every provider when
// interfaceHash changes. So when interface (i.e. interface hash) of
// sourceFile changes, every provides is dirty. And since we don't know
// what happened, dirtyness might affect the interface.
if (!p.getInterface()->getFingerprint().hasValue())
g.addArc(g.getSourceFileNodePair().getInterface(), p.getInterface());
// Since the current type fingerprints only include tokens in the body,
// when the interface hash changes, it is possible that the type in the
// file has changed.
g.addArc(g.getSourceFileNodePair().getInterface(), p.getInterface());
}
}

Expand Down Expand Up @@ -809,8 +807,15 @@ bool swift::fine_grained_dependencies::emitReferenceDependencies(
// that may have been there. No error handling -- this is just a nicety, it
// doesn't matter if it fails.
llvm::sys::fs::rename(outputPath, outputPath + "~");
// Since, when fingerprints are enabled,
// the parser diverts token hashing into per-body fingerprints
// before it can know if a difference is in a private type,
// in order to be able to test the changed fingerprints
// we force the inclusion of private declarations when fingerprints
// are enabled.
const bool includeIntrafileDeps =
SF->getASTContext().LangOpts.FineGrainedDependenciesIncludeIntrafileOnes;
SF->getASTContext().LangOpts.FineGrainedDependenciesIncludeIntrafileOnes ||
SF->getASTContext().LangOpts.EnableTypeFingerprints;
const bool hadCompilationError = SF->getASTContext().hadError();
auto gc = SourceFileDepGraphConstructor::forSourceFile(
SF, depTracker, outputPath, includeIntrafileDeps, hadCompilationError);
Expand Down Expand Up @@ -843,33 +848,54 @@ bool swift::fine_grained_dependencies::emitReferenceDependencies(
static StringRef stripPrefix(const StringRef name) {
return name.ltrim(SourceFileDepGraph::noncascadingOrPrivatePrefix);
}
static StringRef stripFingerprint(const StringRef nameAndFingerprint) {
return nameAndFingerprint.split(SourceFileDepGraph::nameFingerprintSeparator)
.first;
}
static StringRef stripName(const StringRef nameAndFingerprint) {
return nameAndFingerprint.split(SourceFileDepGraph::nameFingerprintSeparator)
.second;
}
static std::string extractName(const StringRef prefixNameFingerprint) {
return stripFingerprint(stripPrefix(prefixNameFingerprint)).str();
}
static Optional<std::string> extractFingerprint(
const StringRef prefixNameFingerprint) {
const auto fp = stripName(stripPrefix(prefixNameFingerprint));
return fp.empty() ? None : Optional<std::string>(fp.str());
}

static std::vector<ContextNameFingerprint>
getBaseNameProvides(ArrayRef<std::string> simpleNames) {
std::vector<ContextNameFingerprint> result;
for (StringRef n : simpleNames)
result.push_back(ContextNameFingerprint("", stripPrefix(n).str(), None));
result.push_back(ContextNameFingerprint("", extractName(n),
extractFingerprint(n)));
return result;
}

static std::vector<ContextNameFingerprint>
getMangledHolderProvides(ArrayRef<std::string> simpleNames) {
std::vector<ContextNameFingerprint> result;
for (StringRef n : simpleNames)
result.push_back(ContextNameFingerprint(stripPrefix(n).str(), "", None));
result.push_back(ContextNameFingerprint(extractName(n), "",
extractFingerprint(n)));
return result;
}

static std::vector<ContextNameFingerprint> getCompoundProvides(
ArrayRef<std::pair<std::string, std::string>> compoundNames) {
std::vector<ContextNameFingerprint> result;
for (const auto &p : compoundNames)
result.push_back(ContextNameFingerprint(stripPrefix(p.first),
stripPrefix(p.second), None));
result.push_back(ContextNameFingerprint(extractName(p.first),
extractName(p.second),
extractFingerprint(p.second)));
return result;
}

static bool cascades(const std::string &s) { return s.empty() || s[0] != SourceFileDepGraph::noncascadingOrPrivatePrefix; }
static bool cascades(const std::string &s) {
return s.empty() || s[0] != SourceFileDepGraph::noncascadingOrPrivatePrefix;
}

// Use '_' as a prefix for a file-private member
static bool isPrivate(const std::string &s) {
Expand Down Expand Up @@ -899,7 +925,8 @@ getCompoundDepends(
// (On Linux, the compiler needs more verbosity than:
// result.push_back({{n, "", false}, cascades(n)});
result.push_back(
std::make_pair(std::make_tuple(stripPrefix(n), std::string(), false), cascades(n)));
std::make_pair(std::make_tuple(stripPrefix(n), std::string(), false),
cascades(n)));
}
for (auto &p : compoundNames) {
// Likewise, for Linux expand the following out:
Expand Down Expand Up @@ -927,7 +954,8 @@ SourceFileDepGraph SourceFileDepGraph::simulateLoad(
SourceFileDepGraphConstructor c(
swiftDepsFilename, includePrivateDeps, hadCompilationError, interfaceHash,
getSimpleDepends(simpleNamesByRDK[dependsTopLevel]),
getCompoundDepends(simpleNamesByRDK[dependsNominal], compoundNamesByRDK[dependsMember]),
getCompoundDepends(simpleNamesByRDK[dependsNominal],
compoundNamesByRDK[dependsMember]),
getSimpleDepends(simpleNamesByRDK[dependsDynamicLookup]),
getExternalDepends(simpleNamesByRDK[dependsExternal]),
{}, // precedence groups
Expand Down
58 changes: 41 additions & 17 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,59 @@ else()
set(UUID_INCLUDE "${UUID_INCLUDE_DIRS}")
endif()

function(generate_revision_inc revision_inc_var name dir)
find_first_existing_vc_file("${dir}" ${name}_vc)
# Figure out if we can track VC revisions.
# FIXME: Copied from Clang.
function(find_first_existing_file out_var)
foreach(file ${ARGN})
if(EXISTS "${file}")
set(${out_var} "${file}" PARENT_SCOPE)
return()
endif()
endforeach()
endfunction()

# Create custom target to generate the VC revision include.
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/${name}Revision.inc")
macro(find_first_existing_vc_file out_var path)
find_first_existing_file(${out_var}
"${path}/.git/logs/HEAD" # Git
"${path}/.svn/wc.db" # SVN 1.7
"${path}/.svn/entries" # SVN 1.6
)
endmacro()

set(generate_vcs_version_script "${LLVM_MAIN_SRC_DIR}/cmake/modules/GenerateVersionFromVCS.cmake")
set(generate_vcs_version_script "${LLVM_MAIN_SRC_DIR}/cmake/modules/GenerateVersionFromVCS.cmake")

add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${${name}_vc}" "${generate_vcs_version_script}"
COMMAND ${CMAKE_COMMAND} "-DNAMES=$<UPPER_CASE:name>"
"-D$<UPPER_CASE:name>_SOURCE_DIR=${dir}"
"-DHEADER_FILE=${version_inc}"
-P "${generate_vcs_version_script}")
function(generate_revision_inc revision_inc_var name dir)
find_first_existing_vc_file(dep_file "${dir}")
# Create custom target to generate the VC revision include.
set(revision_inc "${CMAKE_CURRENT_BINARY_DIR}/${name}Revision.inc")
string(TOUPPER ${name} upper_name)
if(DEFINED dep_file)
add_custom_command(OUTPUT "${revision_inc}"
DEPENDS "${dep_file}" "${generate_vcs_version_script}"
COMMAND
${CMAKE_COMMAND} "-DNAMES=${upper_name}"
"-D${upper_name}_SOURCE_DIR=${dir}"
"-DHEADER_FILE=${revision_inc}"
-P "${generate_vcs_version_script}")
else()
# Generate an empty Revision.inc file if we are not using git or SVN.
file(WRITE "${revision_inc}" "")
endif()

# Mark the generated header as being generated.
set_source_files_properties("${version_inc}"
set_source_files_properties("${revision_inc}"
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
set(${revision_inc_var} ${version_inc} PARENT_SCOPE)
set(${revision_inc_var} ${revision_inc} PARENT_SCOPE)
endfunction()

generate_revision_inc(llvm_revision_inc LLVM "${LLVM_MAIN_SRC_DIR}")
generate_revision_inc(clang_revision_inc Clang "${CLANG_MAIN_SRC_DIR}")
generate_revision_inc(swift_revision_inc Swift "${SWIFT_SOURCE_DIR}")

set(version_inc_files
${llvm_revision_inc} ${clang_revision_inc} ${swift_revision_inc})

add_swift_host_library(swiftBasic STATIC
AnyValue.cpp
Cache.cpp
Expand Down Expand Up @@ -68,10 +95,7 @@ add_swift_host_library(swiftBasic STATIC
Unicode.cpp
UUID.cpp
Version.cpp

${llvm_revision_inc}
${clang_revision_inc}
${swift_revision_inc}
${version_inc_files}

# Platform-specific TaskQueue implementations
Unix/TaskQueue.inc
Expand Down
15 changes: 14 additions & 1 deletion lib/Basic/SourceLoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,20 @@ SourceManager::resolveOffsetForEndOfLine(unsigned BufferId,
return resolveFromLineCol(BufferId, Line, ~0u);
}

llvm::Optional<unsigned>
SourceManager::getLineLength(unsigned BufferId, unsigned Line) const {
auto BegOffset = resolveFromLineCol(BufferId, Line, 0);
auto EndOffset = resolveFromLineCol(BufferId, Line, ~0u);
if (BegOffset && EndOffset) {
return EndOffset.getValue() - BegOffset.getValue();
}
return None;
}

llvm::Optional<unsigned> SourceManager::resolveFromLineCol(unsigned BufferId,
unsigned Line,
unsigned Col) const {
if (Line == 0 || Col == 0) {
if (Line == 0) {
return None;
}
const bool LineEnd = Col == ~0u;
Expand All @@ -353,6 +363,9 @@ llvm::Optional<unsigned> SourceManager::resolveFromLineCol(unsigned BufferId,
return None;
}
Ptr = LineStart;
if (Col == 0) {
return Ptr - InputBuf->getBufferStart();
}
// The <= here is to allow for non-inclusive range end positions at EOF
for (; ; ++Ptr) {
--Col;
Expand Down
7 changes: 6 additions & 1 deletion lib/Driver/FineGrainedDependencyDriverGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ ModuleDepGraph::findJobsToRecompileWhenNodesChange<
std::unordered_set<ModuleDepGraphNode *>>(
const std::unordered_set<ModuleDepGraphNode *> &);

template std::vector<const Job *>
ModuleDepGraph::findJobsToRecompileWhenNodesChange<
std::vector<ModuleDepGraphNode *>>(
const std::vector<ModuleDepGraphNode *> &);

std::vector<std::string> ModuleDepGraph::computeSwiftDepsFromNodes(
ArrayRef<const ModuleDepGraphNode *> nodes) const {
llvm::StringSet<> swiftDepsOfNodes;
Expand Down Expand Up @@ -441,7 +446,7 @@ void ModuleDepGraph::forEachNode(

void ModuleDepGraph::forEachMatchingNode(
const DependencyKey &key,
function_ref<void(const ModuleDepGraphNode *)> fn) const {
function_ref<void(ModuleDepGraphNode *)> fn) const {
nodeMap.forEachValueMatching(
key, [&](const std::string &, ModuleDepGraphNode *n) { fn(n); });
}
Expand Down
19 changes: 19 additions & 0 deletions lib/SIL/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ llvm::cl::opt<bool>
SILPrintDebugInfo("sil-print-debuginfo", llvm::cl::init(false),
llvm::cl::desc("Include debug info in SIL output"));

llvm::cl::opt<bool>
SILPrintSourceInfo("sil-print-sourceinfo", llvm::cl::init(false),
llvm::cl::desc("Include source annotation in SIL output"));

llvm::cl::opt<bool> SILPrintGenericSpecializationInfo(
"sil-print-generic-specialization-info", llvm::cl::init(false),
llvm::cl::desc("Include generic specialization"
Expand Down Expand Up @@ -618,7 +622,22 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
}
*this << '\n';

const auto &SM = BB->getModule().getASTContext().SourceMgr;
Optional<SILLocation> PrevLoc;
for (const SILInstruction &I : *BB) {
if (SILPrintSourceInfo) {
auto CurSourceLoc = I.getLoc().getSourceLoc();
if (CurSourceLoc.isValid()) {
if (!PrevLoc || SM.getLineNumber(CurSourceLoc) > SM.getLineNumber(PrevLoc->getSourceLoc())) {
auto Buffer = SM.findBufferContainingLoc(CurSourceLoc);
auto Line = SM.getLineNumber(CurSourceLoc);
auto LineLength = SM.getLineLength(Buffer, Line);
PrintState.OS << " // " << SM.extractText({SM.getLocForLineCol(Buffer, Line, 0), LineLength.getValueOr(0)}) <<
"\tSourceLoc: " << SM.getDisplayNameForLoc(CurSourceLoc) << ":" << Line << "\n";
PrevLoc = I.getLoc();
}
}
}
Ctx.printInstructionCallBack(&I);
if (SILPrintGenericSpecializationInfo) {
if (auto AI = ApplySite::isa(const_cast<SILInstruction *>(&I)))
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/Analysis/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ SILValue EscapeAnalysis::getPointerBase(SILValue value) {
case ValueKind::StructElementAddrInst:
case ValueKind::StructExtractInst:
case ValueKind::TupleElementAddrInst:
case ValueKind::BeginAccessInst:
case ValueKind::UncheckedTakeEnumDataAddrInst:
case ValueKind::UncheckedEnumDataInst:
case ValueKind::MarkDependenceInst:
Expand Down
Loading