Skip to content

swift/tensorflow merge (2020-06-09) #1321

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

Merged
merged 42 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
77ecbf2
[InstCombine] prevent infinite loop with sub/abs of constant expressi…
fhahn Jun 2, 2020
34e60c2
Merge commit '77ecbf214571' from apple/stable/20200108 into swift/rel…
Jun 2, 2020
6b1a01b
Merge commit '34e60c20f6dc' from swift/release/5.3 into swift/master
Jun 2, 2020
ea3e220
[DAGComb] Do not turn insert_elt into shuffle for single elt vectors.…
fhahn Jun 2, 2020
c898871
Merge commit 'ea3e2201ff91' from apple/stable/20200108 into swift/rel…
Jun 2, 2020
0d4deaa
Merge commit 'c898871f99bd' from swift/release/5.3 into swift/master
Jun 2, 2020
312cdb4
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 2, 2020
a478838
[test/swift] Inspect children of self in Base.init and Child.init, NFC
vedantk Jun 2, 2020
1304f50
Modernize parts of SwiftASTManipulator::WrapExpression, NFC
vedantk Jun 2, 2020
a28e9cf
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 2, 2020
a2f3d7d
Remove redundant code (NFC)
adrian-prantl Jun 2, 2020
d08d94b
Merge pull request #1303 from adrian-prantl/cleanup-target
fredriss Jun 2, 2020
bb23375
Merge commit 'd08d94ba7825' from apple/stable/20200108 into swift/rel…
Jun 3, 2020
1a9bad5
Merge commit 'bb2337537035' from swift/release/5.3 into swift/master
Jun 3, 2020
dba03f9
Fix UB in EmulateInstructionARM64.cpp
adrian-prantl Jun 1, 2020
acc173e
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 3, 2020
5b8bad5
Merge commit 'c1a72480784e' from swift/release/5.3 into swift/master
Jun 3, 2020
3b11cbd
Merge pull request #1305 from adrian-prantl/60926115
fredriss Jun 3, 2020
c1a7248
Merge commit '3b11cbd7c057' from apple/stable/20200108 into swift/rel…
Jun 3, 2020
df9551d
[lldb/formatter] Add Swift.UnsafeBufferPointer data formatter
medismailben Jun 2, 2020
b47464f
[lldb] Update SourceFile constructor calls
hamishknight Jun 3, 2020
44cecca
Merge pull request #1302 from vedantk/gardening
vedantk Jun 3, 2020
49288b7
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 3, 2020
14b54c5
Merge pull request #1276 from medismailben/swift/master
medismailben Jun 3, 2020
30937ec
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 3, 2020
4e91154
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 3, 2020
fca7f54
[LLDB] nullptr and false are not the same
davezarzycki Jun 4, 2020
f516ac6
Merge pull request #1309 from davezarzycki/lldb_nullptr_false_fix
davezarzycki Jun 4, 2020
fd529f0
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 4, 2020
448579f
Merge remote-tracking branch 'github/swift/tensorflow' into HEAD
ainu-bot Jun 4, 2020
4233316
[dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file
JDevlieghere Jun 5, 2020
e6b0a87
Move GetXcode*Directory into HostInfo (NFC)
adrian-prantl Jun 5, 2020
da0ea99
Teach GetXcodeSDK to look in the Xcode that contains LLDB
adrian-prantl Jun 5, 2020
d6fc7c9
Merge pull request #1316 from adrian-prantl/64000666
fredriss Jun 5, 2020
5d3ab23
Merge commit 'd6fc7c9a0c16' from apple/stable/20200108 into swift/rel…
adrian-prantl Jun 5, 2020
ea0202e
Adapt to upstream changes: GetXcodeContentsDirectory moving to HostInfo
adrian-prantl Jun 5, 2020
cafeebd
Merge commit 'ea0202e1411a' from swift/release/5.3 into swift/master
Jun 6, 2020
786154a
Merge pull request #1313 from JDevlieghere/no-nast-symbols
JDevlieghere Jun 5, 2020
277b591
Merge commit '786154a9853d' from apple/stable/20200108 into swift/rel…
Jun 6, 2020
15c0dbb
Merge commit '277b591f2a97' from swift/release/5.3 into swift/master
Jun 6, 2020
94f1132
Merge pull request #1307 from hamishknight/pipeline-parse
hamishknight Jun 8, 2020
55d27a5
Merge remote-tracking branch 'github/swift/master' into HEAD
ainu-bot Jun 8, 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
3 changes: 3 additions & 0 deletions lldb/include/lldb/Host/HostInfoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class HostInfoBase {
static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
llvm::StringRef dir);

static FileSpec GetXcodeContentsDirectory() { return {}; }
static FileSpec GetXcodeDeveloperDirectory() { return {}; }

/// Return the directory containing a specific Xcode SDK.
static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }

Expand Down
3 changes: 2 additions & 1 deletion lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class HostInfoMacOSX : public HostInfoPosix {
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
static FileSpec GetXcodeContentsDirectory();
static FileSpec GetXcodeDeveloperDirectory();

/// Query xcrun to find an Xcode SDK directory.
static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Utility/XcodeSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class XcodeSDK {
static std::string GetCanonicalName(Info info);
/// Return the best-matching SDK type for a specific triple.
static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple);

static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
};

} // namespace lldb_private
Expand Down
73 changes: 72 additions & 1 deletion lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,82 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
}
}

FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
static FileSpec g_xcode_contents_path;
static std::once_flag g_once_flag;
std::call_once(g_once_flag, [&]() {
// Try the shlib dir first.
if (FileSpec fspec = HostInfo::GetShlibDir()) {
if (FileSystem::Instance().Exists(fspec)) {
std::string xcode_contents_dir =
XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
if (!xcode_contents_dir.empty()) {
g_xcode_contents_path = FileSpec(xcode_contents_dir);
return;
}
}
}

if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
FileSpec fspec(developer_dir_env_var);
if (FileSystem::Instance().Exists(fspec)) {
// FIXME: This looks like it couldn't possibly work!
std::string xcode_contents_dir =
XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
if (!xcode_contents_dir.empty()) {
g_xcode_contents_path = FileSpec(xcode_contents_dir);
return;
}
}
}

FileSpec fspec(HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS()));
if (fspec) {
if (FileSystem::Instance().Exists(fspec)) {
std::string xcode_contents_dir =
XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
if (!xcode_contents_dir.empty()) {
g_xcode_contents_path = FileSpec(xcode_contents_dir);
return;
}
}
}
});
return g_xcode_contents_path;
}

lldb_private::FileSpec HostInfoMacOSX::GetXcodeDeveloperDirectory() {
static lldb_private::FileSpec g_developer_directory;
static llvm::once_flag g_once_flag;
llvm::call_once(g_once_flag, []() {
if (FileSpec fspec = GetXcodeContentsDirectory()) {
fspec.AppendPathComponent("Developer");
if (FileSystem::Instance().Exists(fspec))
g_developer_directory = fspec;
}
});
return g_developer_directory;
}

static std::string GetXcodeSDK(XcodeSDK sdk) {
XcodeSDK::Info info = sdk.Parse();
std::string sdk_name = XcodeSDK::GetCanonicalName(info);
auto find_sdk = [](std::string sdk_name) -> std::string {
std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
std::string xcrun_cmd;
Environment env = Host::GetEnvironment();
std::string developer_dir = env.lookup("DEVELOPER_DIR");
if (developer_dir.empty())
if (FileSpec fspec = HostInfo::GetShlibDir())
if (FileSystem::Instance().Exists(fspec)) {
FileSpec path(
XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
if (path.RemoveLastPathComponent())
developer_dir = path.GetPath();
}
if (!developer_dir.empty())
xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;

int status = 0;
int signo = 0;
std::string output_str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,8 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos(
// Update the module's platform with the DYLD info.
ArchSpec dyld_spec = image_infos[idx].GetArchitecture();
if (dyld_spec.GetTriple().getOS() == llvm::Triple::IOS &&
dyld_spec.GetTriple().getEnvironment() == llvm::Triple::MacABI) {
dyld_spec.GetTriple().getEnvironment() == llvm::Triple::MacABI)
image_module_sp->MergeArchitecture(dyld_spec);
const auto &target_triple = target.GetArchitecture().GetTriple();
// If dyld reports the process as being loaded as MACCATALYST,
// force-update the target's architecture to MACCATALYST.
if (!(target_triple.getOS() == llvm::Triple::IOS &&
target_triple.getEnvironment() == llvm::Triple::MacABI))
target.SetArchitecture(dyld_spec);
}
}
}

Expand Down
124 changes: 68 additions & 56 deletions lldb/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,41 @@ void SwiftASTManipulator::WrapExpression(
__builtin_logger_initialize()
)";

// The debug function declarations need only be declared once per session - on the first REPL call.
// This code assumes that the first call is the first REPL call; don't call playground once then playground || repl again
// The debug function declarations need only be declared once per session -
// on the first REPL call. This code assumes that the first call is the
// first REPL call; don't call playground once then playground || repl
// again
bool first_expression = options.GetPreparePlaygroundStubFunctions();

const char *playground_prefix = first_expression ? playground_logger_declarations : "";
const char *playground_prefix =
first_expression ? playground_logger_declarations : "";

if (pound_file && pound_line) {
wrapped_stream.Printf("%s#sourceLocation(file: \"%s\", line: %u)\n%s\n",
playground_prefix, pound_file, pound_line,
orig_text);
} else {
// In 2017+, xcode playgrounds send orig_text that starts with a module loading prefix (not the above prefix), then a sourceLocation specifier that indicates the page name, and then the page body text.
// The first_body_line mechanism in this function cannot be used to compensate for the playground_prefix added here, since it incorrectly continues to apply even after sourceLocation directives are read frmo the orig_text.
// To make sure playgrounds work correctly whether or not they supply their own sourceLocation, create a dummy sourceLocation here with a fake filename that starts counting the first line of orig_text as line 1.
// In 2017+, xcode playgrounds send orig_text that starts with a module
// loading prefix (not the above prefix), then a sourceLocation specifier
// that indicates the page name, and then the page body text. The
// first_body_line mechanism in this function cannot be used to
// compensate for the playground_prefix added here, since it incorrectly
// continues to apply even after sourceLocation directives are read from
// the orig_text. To make sure playgrounds work correctly whether or not
// they supply their own sourceLocation, create a dummy sourceLocation
// here with a fake filename that starts counting the first line of
// orig_text as line 1.
wrapped_stream.Printf("%s#sourceLocation(file: \"%s\", line: %u)\n%s\n",
playground_prefix, "Playground.swift", 1,
orig_text);
}
first_body_line = 1;
return;
} else if (repl) { // repl but not playground.
}

assert(!playground && "Playground mode not expected");

if (repl) {
if (pound_file && pound_line) {
wrapped_stream.Printf("#sourceLocation(file: \"%s\", line: %u)\n%s\n",
llvm::sys::path::filename(pound_file).str().c_str(),
Expand All @@ -122,87 +136,85 @@ __builtin_logger_initialize()
return;
}

std::string expr_source_path;
assert(!playground && !repl && "Playground/REPL mode not expected");

if (pound_file && pound_line) {
fixed_text.Printf("#sourceLocation(file: \"%s\", line: %u)\n%s\n",
pound_file, pound_line, orig_text);
text = fixed_text.GetString().data();
} else if (generate_debug_info) {
std::string expr_source_path;
if (SwiftASTManipulator::SaveExpressionTextToTempFile(orig_text, options,
expr_source_path)) {
expr_source_path)) {
fixed_text.Printf("#sourceLocation(file: \"%s\", line: 1)\n%s\n",
expr_source_path.c_str(), orig_text);
text = fixed_text.GetString().data();
}
}

// Note: All the wrapper functions we make are marked with the
// @LLDBDebuggerFunction macro so that the compiler
// can do whatever special treatment it need to do on them. If you add new
// variants be sure to mark them this way.
// Also, any function that might end up being in an extension of swift class
// needs to be marked final, since otherwise
// the compiler might try to dispatch them dynamically, which it can't do
// correctly for these functions.

llvm::SmallString<32> buffer;
llvm::raw_svector_ostream os(buffer);
// @LLDBDebuggerFunction macro so that the compiler can do whatever special
// treatment it need to do on them. If you add new variants be sure to mark
// them this way. Also, any function that might end up being in an extension
// of swift class needs to be marked final, since otherwise the compiler
// might try to dispatch them dynamically, which it can't do correctly for
// these functions.

std::string availability = "";
if (!os_version.empty())
os << "@available(" << os_version << ", *)";
std::string availability = os.str();
availability = (llvm::Twine("@available(") + os_version + ", *)").str();

StreamString wrapped_expr_text;
wrapped_expr_text.Printf("do\n"
"{\n"
"%s%s%s\n" // Don't indent the code so error columns
// match up with errors from compiler
"}\n"
"catch (let __lldb_tmp_error)\n"
"{\n"
" var %s = __lldb_tmp_error\n"
"}\n",

// Avoid indenting user code: this makes column information from compiler
// errors match up with what the user typed.
wrapped_expr_text.Printf(R"(
do {
%s%s%s
} catch (let __lldb_tmp_error) {
var %s = __lldb_tmp_error
}
)",
GetUserCodeStartMarker(), text,
GetUserCodeEndMarker(), GetErrorName());

if (needs_object_ptr | static_method) {
if (needs_object_ptr || static_method) {
const char *func_decorator = "";
if (static_method) {
if (is_class)
func_decorator = "final class";
else
func_decorator = "static";
} else if (is_class &&
!(weak_self)) {
} else if (is_class && !weak_self) {
func_decorator = "final";
} else {
func_decorator = "mutating";
}

const char *optional_extension =
(weak_self)
? "Swift.Optional where Wrapped == "
: "";

wrapped_stream.Printf(
"extension %s$__lldb_context {\n"
" @LLDBDebuggerFunction %s\n"
" %s func $__lldb_wrapped_expr_%u(_ $__lldb_arg : "
"UnsafeMutablePointer<Any>) {\n"
"%s" // This is the expression text (with newlines).
" }\n"
"}\n"
"%s\n"
"func $__lldb_expr(_ $__lldb_arg : UnsafeMutablePointer<Any>) {\n"
" do {\n"
" $__lldb_injected_self.$__lldb_wrapped_expr_%u(\n"
" $__lldb_arg\n"
" )\n"
" }\n"
"}\n",
optional_extension, availability.c_str(), func_decorator,
current_counter, wrapped_expr_text.GetData(), availability.c_str(),
current_counter);
weak_self ? "Swift.Optional where Wrapped == " : "";

// The expression text is inserted into the body of $__lldb_wrapped_expr_%u.
wrapped_stream.Printf(R"(
extension %s$__lldb_context {
@LLDBDebuggerFunction %s
%s func $__lldb_wrapped_expr_%u(_ $__lldb_arg : UnsafeMutablePointer<Any>) {
%s
}
}
%s
func $__lldb_expr(_ $__lldb_arg : UnsafeMutablePointer<Any>) {
do {
$__lldb_injected_self.$__lldb_wrapped_expr_%u(
$__lldb_arg
)
}
}
)",
optional_extension, availability.c_str(),
func_decorator, current_counter,
wrapped_expr_text.GetData(), availability.c_str(),
current_counter);

first_body_line = 5;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1230,10 +1230,9 @@ static llvm::Expected<ParsedExpression> ParseAndImport(

// Create the source file. Note, we disable delayed parsing for the
// swift expression parser.
swift::SourceFile *source_file = new (*ast_context) swift::SourceFile(
module, source_file_kind, buffer_id, /*Keep tokens*/ false,
/*KeepSyntaxTree*/ false,
swift::SourceFile::ParsingFlags::DisableDelayedBodies);
swift::SourceFile *source_file = new (*ast_context)
swift::SourceFile(module, source_file_kind, buffer_id,
swift::SourceFile::ParsingFlags::DisableDelayedBodies);
module.addFile(*source_file);

// Swift Modules that rely on shared libraries (not frameworks)
Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,8 @@ void SwiftREPL::CompleteCode(const std::string &current_code,
repl_module = swift_ast->CreateModule(completion_module_info, error,
importInfo);
llvm::Optional<unsigned> bufferID;
swift::SourceFile *repl_source_file = new (*ast)
swift::SourceFile(*repl_module, swift::SourceFileKind::Main, bufferID,
/*Keep tokens*/false);
swift::SourceFile *repl_source_file = new (*ast) swift::SourceFile(
*repl_module, swift::SourceFileKind::Main, bufferID);
repl_module->addFile(*repl_source_file);
swift::performImportResolution(*repl_source_file);
m_completion_module_initialized = true;
Expand Down
Loading