Skip to content

Merge 2020-04-01 into swift/tensorflow #1010

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 46 commits into from
Apr 3, 2020

Conversation

dabrahams
Copy link

No description provided.

augusto2112 and others added 30 commits March 24, 2020 19:09
The algorithm supports both assigning a fixed offset to a field prior to
layout and allowing fields to have sizes that aren't multiples of their
required alignments.  This means that the well-known algorithm of sorting
by decreasing alignment isn't always good enough.  Still, we start with
that, and only if that leaves padding around do we fall back on a greedy
padding-minimizing algorithm.

There is no known efficient algorithm for producing a guaranteed-minimal
layout in all cases.  In fact, allowing arbitrary fixed-offset fields means
there's a straightforward reduction from bin-packing, making this NP-hard.
But as usual with such problems, we can still efficiently produce adequate
solutions to the cases that matter most to us.

I intend to use this in coroutine frame layout, where the retcon lowerings
very badly want to minimize total space usage, and where the switch lowering
can indeed produce a header with interior padding if the promise field is
highly-aligned.  But it may be useful in a much wider variety of situations.
Previously, we would ignore alloca alignment when building the frame
and just use the natural alignment of the allocated type.  If an alloca
is over-aligned for its IR type, this could lead to a frame entry with
inadequate alignment for the downstream uses of the alloca.

Since highly-aligned fields also tend to produce poor layouts under a
naive layout algorithm, I've also switched coroutine frames to use the
new optimal struct layout algorithm.

In order to communicate the frame size and alignment to later passes,
I needed to set align+dereferenceable attributes on the frame-pointer
parameter of the resume function.  This is clearly the right thing to
do, but the align attribute currently seems to result in assumptions
being added during inlining that the optimizer cannot easily remove.
…ing an issue.

Summary:
When ASan reports an issue the contents of the system log buffer
(`error_message_buffer`) get flushed to the system log (via
`LogFullErrorReport()`). After this happens the buffer is not cleared
but this is usually fine because the process usually exits soon after
reporting the issue.

However, when ASan runs in `halt_on_error=0` mode execution continues
without clearing the buffer. This leads to problems if more ASan
issues are found and reported.

1. Duplicate ASan reports in the system log. The Nth (start counting from 1)
ASan report  will be duplicated (M - N) times in the system log if M is the
number of ASan issues reported.

2. Lost ASan reports. Given a sufficient
number of reports the buffer will fill up and consequently cannot be appended
to. This means reports can be lost.

The fix here is to reset `error_message_buffer_pos` to 0 which
effectively clears the system log buffer.

A test case is included but unfortunately it is Darwin specific because
querying the system log is an OS specific activity.

rdar://problem/55986279

Reviewers: kubamracek, yln, vitalybuka, kcc, filcab

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D76749

(cherry picked from commit 445b810)
Add a missing null check in ImportType. Without this, a program that
does not contain an N_AST reference pointing back to a swiftmodule it
uses can cause lldb to crash.

rdar://60734897
The SymbolMapTranslator defines an operator bool() which checks whether
we should translate at all. This returns false if the list of obfuscated
strings is empty.

The NonRelocatableStringPool (OffsetsStringPool) takes a lambda for
translating obfuscated strings rather than a SymbolMapTranslator.
However, we were unconditionally passing the SymbolMapTranslator, which
got implicitly converted to a std::function because it defines an
operator().

In the string pool, we call operator bool but on the lambda, and not on
the SymbolMapTranslator. This would always be true, because we were
passing the translator unconditionally. This caused spurious warnings
about obfuscated strings not being found.

This patch fixes the problem by only passing the translation lambda when
SymbolMapTranslator::operator bool() is true.
[dsymutil] Only set a translation lambda if the translator is valid
…NSError.py

[lldb/Test] XFAIL TestDataFormatterObjCNSError except for gmodules.
[SwiftASTContext] Add missing null check in ImportType
…queried.

Summary:
Follow up fix to 445b810. The `log show` command only works for
privileged users so run a quick test of the command during lit config to
see if the command works and only add the `darwin_log_cmd` feature if
this is the case.

Unfortunately this means the `asan/TestCases/Darwin/duplicate_os_log_reports.cpp`
test and any other tests in the future that use this feature won't run
for unprivileged users which is likely the case in CI.

rdar://problem/55986279

Reviewers: kubamracek, yln, dcoughlin

Subscribers: Charusso, #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D76899

(cherry picked from commit 853a1e6)
GetDeveloperDirectory returns a const char* which is NULL when we cannot
find the developer directory. This crashes in
PlatformDarwinKernel::CollectKextAndKernelDirectories because we're
unconditionally assigning it to a std::string. Coincidentally I just
refactored a bunch of code in PlatformMacOSX so instead of a ad-hoc fix
I've reimplemented the method based on GetXcodeContentsDirectory.

The change is mostly NFC. Obviously it fixes the crash, but it also
removes support for finding the Xcode directory through he legacy
$XCODE_SELECT_PREFIX_DIR/usr/share/xcode-select/xcode_dir_path.

Differential revision: https://reviews.llvm.org/D76938

(cherry picked from commit 457eb05)
[ASan] Fix issue where system log buffer was not cleared after reporting an issue.
Fix some bugs with high-alignment fields in continuations
…34920e762a90d0deb670becb

[lldb/PlatformMacOSX] Re-implement GetDeveloperDirectory
We have tried chaging `LLDB_SWIFT_LIBS` in `test/API/CMakelists.txt` before
to point it to a directory that actually contains the just built runtime
libraries. Unfortunately, `LLDB_SWIFT_LIBS` is a cache variable that gets
passed by `build-script`, so this change has no effect.

Instead, add `macosx` to the uses of the variable. For `LD_LIBRARY_PATH`,
which is used on non-darwin systems, use `CMAKE_SYSTEM_PROCESSOR` instead
which is what the Swift test code seems to be doing.

This also fixed the same issue in the Shell tests.
[lldb/test] Fix Swift testsuite environemnt
value as undefined

    - Correct a debug info salvage and add a test

    Reviewers: aprantl, vsk

    Differential Revision: https://reviews.llvm.org/D76930
    Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=45080

(cherry picked from commit 135709a)
…PR45259)

In InnerLoopVectorizer::getOrCreateTripCount, when the backedge taken
count is a SCEV add expression, its type is defined by the type of the
last operand of the add expression.

In the test case from PR45259, this last operand happens to be a
pointer, which (according to llvm::Type) does not have a primitive size
in bits. In this case, LoopVectorize fails to truncate the SCEV and
crashes as a result.

Uing ScalarEvolution::getTypeSizeInBits makes the truncation work as expected.

https://bugs.llvm.org/show_bug.cgi?id=45259

Differential Revision: https://reviews.llvm.org/D76669

(cherry picked from commit dcc410b)
Cherry-pick DSE debug info fix, fix loopvectorize crash
ainu-bot and others added 16 commits March 30, 2020 19:13
Implement TypeSystemSwiftTypeRef::IsArrayType()
Move all unimplemented Swift Typesystem functions into the base class (NFC)
[Swift] Replace calls to FuncDecl::getName & EnumElementDecl::getName with ValueDecl::getBaseIdentifier
The message has a format specifier but was being printed unformatted.
This corrects the macro usage to use the formatting version.  Improves
the debug logging only.
Target: print the message with formatting
@dabrahams dabrahams merged commit abf47d2 into swift/tensorflow Apr 3, 2020
@dabrahams dabrahams deleted the swift/tensorflow-stage branch April 3, 2020 16:39
@dabrahams dabrahams restored the swift/tensorflow-stage branch April 3, 2020 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.