Commit Graph

416964 Commits

Author SHA1 Message Date
Kristóf Umann d832078904 [analyzer] Improve NoOwnershipChangeVisitor's understanding of deallocators
The problem with leak bug reports is that the most interesting event in the code
is likely the one that did not happen -- lack of ownership change and lack of
deallocation, which is often present within the same function that the analyzer
inlined anyway, but not on the path of execution on which the bug occured. We
struggle to understand that a function was responsible for freeing the memory,
but failed.

D105819 added a new visitor to improve memory leak bug reports. In addition to
inspecting the ExplodedNodes of the bug pat, the visitor tries to guess whether
the function was supposed to free memory, but failed to. Initially (in D108753),
this was done by checking whether a CXXDeleteExpr is present in the function. If
so, we assume that the function was at least party responsible, and prevent the
analyzer from pruning bug report notes in it. This patch improves this heuristic
by recognizing all deallocator functions that MallocChecker itself recognizes,
by reusing MallocChecker::isFreeingCall.

Differential Revision: https://reviews.llvm.org/D118880
2022-03-03 11:27:56 +01:00
Nikita Popov c1b9667148 [InstCombine] Support opaque pointers in callee bitcast fold
To make this actually trigger, we also need to check whether the
function types differ, which is a hidden cast under opaque pointers.
The transform is somewhat less relevant there because it is
primarily about pointer bitcasts, but it can also happen with other
bit- or pointer-castable types.

Byval handling is easier with opaque pointers because there is no
need to adjust the byval type, we only need to make sure that it's
still a pointer.
2022-03-03 11:07:39 +01:00
David Spickett 6b3b3ef344 [lldb] Correct case in description of breakpoint --on-catch/throw
Somehow we ended up with catcH/throW.
2022-03-03 10:06:11 +00:00
Nikita Popov 6c8adc5054 [InstCombine] Remove unnecessary byval check in callee cast fold
The logic for handling this was fixed in
8d7f118ab2, but the check for byval
on the callee was retained. This resulted in a weird situation
where the transform would work depending on whether the byval
was only on the call or on both the call and the function.
2022-03-03 10:55:14 +01:00
Nikita Popov 2555ed55a4 [InstCombine] Add callee bitcast test with byval on callee (NFC)
Same as the existing test, but the callee also has a byval
attribute.
2022-03-03 10:55:14 +01:00
Cullen Rhodes e4fa8291a2 [AArch64] Allow copying of SVE registers in Streaming SVE
Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D118562
2022-03-03 09:51:14 +00:00
Cullen Rhodes 616586794b [AArch64] Add legal types for Streaming SVE
The compiler currently crashes for scalable types when compiling with
+sme, e.g.

  define <vscale x 4 x i32> @foo(<vscale x 4 x i32> %a) {
    ret <vscale x 4 x i32> %a
  }

since it doesn't know how to legalize the types. SME implies a subset of
SVE (+streaming-sve), the hasSVE predication in the backend needs
extending to consider types/operations that are legal in Streaming SVE.

This is the first patch adding legal types <-> register classes. Before
making the change +sve(2) was temporarily replaced with +sme in all the
intrinsics tests to see what failed, and again after making the change.
For all the tests that passed after adding the legal types another RUN
line has been added for +streaming-sve. More patches to follow.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D118561
2022-03-03 09:51:14 +00:00
Haojian Wu ba6c71b137 [AST] Use RecoveryExpr to model a DeclRefExpr which refers to an invalid Decl.
Previously, we didin't build a DeclRefExpr which refers to an invalid declaration.

In this patch, we handle this case by building an empty RecoveryExpr,
which will preserve more broken code (AST parent nodes that contain the
RecoveryExpr is preserved in the AST).

Differential Revision: https://reviews.llvm.org/D120812
2022-03-03 10:33:40 +01:00
Nikita Popov c262ba2aab [Scalarizer] Avoid pointer element type accesses
Pass through the load/store type to the Scatterer instead.
2022-03-03 10:28:58 +01:00
serge-sans-paille f90a66a544 Add missing include under -DEXPENSIVE_CHECKS
This is a follow-up to 59630917d6
2022-03-03 10:19:39 +01:00
Jean Perier f88a9497a2 [flang] Generate PDT runtime type info in the type definition scope
This patches modifies PDT runtime type info generation so that it is
easier to handle derived type descriptor in lowering. It changes three
aspects:

1. The symbol name suffix of runtime type info for PDT instantiation is
   changed from a serial number unrelated to the types to an encoding of
   the instantiated KIND parameters.
2. New runtime type info is not created for each instantiation of PDT without
   KIND parameters (only length parameters). Instead, the runtime type
   info of the type definition is always used. It is updated to contain
   the component descriptions.
3. Runtime type info of PDT instantiation is now always generated in the
   scope where the type is defined. If several PDT type instantiation
   are made in different scope with the same kind parameters, they will
   use the same runtime type info.

Rational of the change:

In lowering, derived type descriptors are not mapped when instantiating derived
type objects. They are mapped later when symbol knowledge is not available anymore.
This mapping is based on the FIR representation of derived types. For
PDT, the FIR type information does not allow deducing the instantiation
scope, it only allows retrieving the type name, the type _definition_
scope, and the kind parameter values. Therefore, in order to be able to
retrieve the derived type descriptor from a FIR type, the derived type
descriptor must be generated in the definition scope and must reflect
the kind parameters. This justifies the need for changes 1. and 3.
above (suffix and scope change). Changes 2. comes from the fact that
all runtime type info of type without kind parameters can be generated
from the type definition, and that because of the suffix change, the
symbol name for type definition and type instantiation are the same.

Although this change is first motivated by how lowering handles derived
types, I believe it is also an improvement from a functional point of
view since this change will allow reducing the number of generated
runtime type info for PDTs, since redundant information (different
instantiations with same kind parameters) will only be generated once.

Differential Revision: https://reviews.llvm.org/D120801
2022-03-03 10:15:21 +01:00
Jean Perier 392cba8603 [flang] Handle optional TARGET associate in ASSOCIATED runtime
The TARGET argument of ASSOCIATED may be dynamically optional, in which
case ASSOCIATED(POINTER, TARGET) is equal to ASSOCIATED(TARGET).

Make the runtime argument a pointer so that it can detect and handle
arguments that are dynamically optional.

Also fix the runtime to check if TARGET base address is not null and if
its element size is not null to match the requirement of ASSOCIATED
regarding TARGET:
- if TARGET is an object: true iff [..] TARGET is not a zerosized storage sequence
- if TARGET is a POINTER: true iff [..] POINTER and TARGET are associated

Not that ASSOCIATED will also returns false if TARGET is an unallocated allocatable.
This is not described in the standard, but is a unanimous behaviour of
existing compilers.

Differential Revision: https://reviews.llvm.org/D120835
2022-03-03 10:11:35 +01:00
Jean Perier 013160f6e2 [flang] Support PDT type descriptors in codegen
This change updates the mapping of derived types and type descriptor
object names to support kind parametrized derived types (PDT).
It moves the custom name mapping to the internal name utility.

To improve robustness and error reporting, type descriptors are also now
required to be generated in all compilation unit that manipulates
derived types. The previous codegen relied on the fact that descriptors
not defined in the current FIR module were available externally. Errors
with missing type descriptors were only caught at link time.

This patch makes derived type definition mandatory, except if the
derived types are expected to not have derived type descriptors (builtin
types), or if the newly added debug switch `--ignore-missing-type-desc`
is set. In those cases, a null pointer is used as type descriptor
pointer. The debug switch intends to help testing FIR to LLVM passes
without having to bother providing type descriptor data structures that
are normally built by the front-end.

Differential Revision: https://reviews.llvm.org/D120804
2022-03-03 10:08:18 +01:00
Nikita Popov 9404d44299 [llvm-stress] Support opaque pointers
With opaque pointers, generate the load/store type independently
of the pointer type.
2022-03-03 09:59:06 +01:00
Nikita Popov b214f550f7 [DSE] Drop redundant WalkerStepLimit adjustment
There is a general WalkerStepLimit adjustment higher up in the
loop, and I don't see any reason why this particular case would
need additional adjustment. Furthermore, this could underflow.
2022-03-03 09:42:38 +01:00
jacquesguan 44a430354d [RISCV] Fold store of vmv.f.s to a vse with VL=1.
This patch support the FP part of D109482.

Differential Revision: https://reviews.llvm.org/D120235
2022-03-03 16:35:19 +08:00
Martin Storsjö 77fd54d2eb [libcxx] [test] Fix the collate compare test for Glibc, Windows and FreeBSD
The old expected behaviour was specific to Apple platforms,
while Glibc, Windows and FreeBSD collate differently (ignoring
case). Make the old tested behaviour a special case for Apple
platforms, and make the default case the one used by the other
three.

In clang-cl/DLL configurations, the test is hit by
https://llvm.org/PR41018 (making the test fail to link).

Differential Revision: https://reviews.llvm.org/D120797
2022-03-03 10:09:24 +02:00
Martin Storsjö 4c3b74b7f5 [LLD] [COFF] Order .debug_* sections at the end, to avoid leaving gaps if stripped
So far, we sort all discardable sections at the end, with only some
extra logic to make sure that the .reloc section is at the start
of that group of sections. But if there are other discardable
sections, other than .reloc, they must also be ordered before
.debug_* sections, to avoid leaving gaps if the executable is
stripped.

(Stripping executables doesn't remove all discardable sections,
only the ones named .debug_*).

Rust binaries seem to include a .rmeta section, which is marked
discardable. This fixes stripping such binaries if built with
dwarf debug info included.

This fixes issues observed in MSYS2 in
https://github.com/msys2/MINGW-packages/pull/10555.

Differential Revision: https://reviews.llvm.org/D120805
2022-03-03 10:08:51 +02:00
Peixin-Qiao a5605c9a15 [MLIR] Fix afterIP for dynamic worksharing-loop after collaping loops
The loopInfos gets invalidated after collapsing nested loops. Use the
saved afterIP since the returned afterIP by applyDynamicWorkshareLoop
may be not valid.

Reviewed By: shraiysh

Differential Revision: https://reviews.llvm.org/D120294
2022-03-03 15:22:20 +08:00
serge-sans-paille 59630917d6 Cleanup includes: Transform/Scalar
Estimated impact on preprocessor output line:
before: 1062981579
after:  1062494547

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D120817
2022-03-03 07:56:34 +01:00
serge-sans-paille 81a1760cac Revert "Add missing include under EXPENSIVE_CHECK"
This reverts commit eeaca53df7.

It's a duplicate of
https://reviews.llvm.org/rG50874a188b94a25827963956887b878d3701509a
2022-03-03 07:56:34 +01:00
Jonas Devlieghere ef0de5dce7
[lldb] Update the CI docs
Remove the reproducer bot and the fedora bot.
2022-03-02 22:40:05 -08:00
Jonas Devlieghere 03dae31aca
[lldb] Update TestBasicEntryValues.py for `image lookup` output
Update TestBasicEntryValues.py for 15983c28aa which changes the output
for `image lookup -v`. This should fix the debian and macos build bots.
2022-03-02 22:35:34 -08:00
Danila Malyutin ff33b6f90a [Support][AArch64] Detect a few more host CPU features on AArch64
Add detecton for lse, sve and sve2 on linux

Differential Revision: https://reviews.llvm.org/D119435
2022-03-03 09:30:02 +03:00
Dominic Chen cd89f94aa9 [lldb] Fix python errors in gdbremote.py
Fix exceptions encountered while debugging gdb protocol

Differential Revision: https://reviews.llvm.org/D120792
2022-03-02 19:47:51 -08:00
Kai Luo 1cfcbf197c [PowerPC][atomics] Precommit test cases for i128 cmpxchg. NFC. 2022-03-03 10:47:52 +08:00
David Blaikie 831fa725ef More bazel fixes. 2022-03-03 02:05:32 +00:00
Jonas Devlieghere 42db8bfa20
[lldb] Skip check for the lldb prompt in TestIOHandlerProcessSTDIO
The check for the prompt isn't essential for this test. The check fail
on the lldb-arm-ubuntu because of what appears to be a missing space
after the prompt. Rather than disabling the test, let's see if we can
get it to pass without it.
2022-03-02 16:44:14 -08:00
David Blaikie f6bc0a48cc More attempts at bazel fix 2022-03-03 00:18:54 +00:00
Peter Klausler 3bfe90748e [flang] Remove bogus messages for actual/dummy procedure argument compatibility
Add new IsCompatibleWith() member functions to many classes in evaluate::characteristics
that apply more nuanced compatibility checking for function results, dummy
arguments, and procedure interfaces than the previous tests for complete
equivalence.  Use IsCompatibleWith() in semantics for call checking.

Differential Revision: https://reviews.llvm.org/D120844
2022-03-02 16:00:36 -08:00
Jonas Devlieghere 77bfdeb092
[lldb] Update error messages in TestMemoryHistory.py
Update TestMemoryHistory.py for daba823622
which changes the CommandObject & Disassemble error messages .
2022-03-02 15:56:45 -08:00
Jonas Devlieghere 37eb15ad7a
[lldb] Devirtualize IOHandler::{IsActive,SetIsDone,GetIsDone} (NFC)
There are no implementations overriding these methods.

Differential revision: https://reviews.llvm.org/D120766
2022-03-02 15:55:49 -08:00
Jonas Devlieghere 10222764a9
[lldb] Avoid data race in IOHandlerProcessSTDIO
This patch fixes a data race in IOHandlerProcessSTDIO. The race is
happens between the main thread and the event handling thread. The main
thread is running the IOHandler (IOHandlerProcessSTDIO::Run()) when an
event comes in that makes us pop the process IO handler which involves
cancelling the IOHandler (IOHandlerProcessSTDIO::Cancel). The latter
calls SetIsDone(true) which modifies m_is_done. At the same time, we
have the main thread reading the variable through GetIsDone().

This patch avoids the race by using a mutex to synchronize the two
threads. On the event thread, in IOHandlerProcessSTDIO ::Cancel method,
we obtain the lock before changing the value of m_is_done. On the main
thread, in IOHandlerProcessSTDIO::Run(), we obtain the lock before
reading the value of m_is_done. Additionally, we delay calling SetIsDone
until after the loop exists, to avoid a potential race between the two
writes.

  Write of size 1 at 0x00010b66bb68 by thread T7 (mutexes: write M2862, write M718324145051843688):
    #0 lldb_private::IOHandler::SetIsDone(bool) IOHandler.h:90 (liblldb.15.0.0git.dylib:arm64+0x971d84)
    #1 IOHandlerProcessSTDIO::Cancel() Process.cpp:4382 (liblldb.15.0.0git.dylib:arm64+0x5ddfec)
    #2 lldb_private::Debugger::PopIOHandler(std::__1::shared_ptr<lldb_private::IOHandler> const&) Debugger.cpp:1156 (liblldb.15.0.0git.dylib:arm64+0x3cb2a8)
    #3 lldb_private::Debugger::RemoveIOHandler(std::__1::shared_ptr<lldb_private::IOHandler> const&) Debugger.cpp:1063 (liblldb.15.0.0git.dylib:arm64+0x3cbd2c)
    #4 lldb_private::Process::PopProcessIOHandler() Process.cpp:4487 (liblldb.15.0.0git.dylib:arm64+0x5c583c)
    #5 lldb_private::Debugger::HandleProcessEvent(std::__1::shared_ptr<lldb_private::Event> const&) Debugger.cpp:1549 (liblldb.15.0.0git.dylib:arm64+0x3ceabc)
    #6 lldb_private::Debugger::DefaultEventHandler() Debugger.cpp:1622 (liblldb.15.0.0git.dylib:arm64+0x3cf2c0)
    #7 std::__1::__function::__func<lldb_private::Debugger::StartEventHandlerThread()::$_2, std::__1::allocator<lldb_private::Debugger::StartEventHandlerThread()::$_2>, void* ()>::operator()() function.h:352 (liblldb.15.0.0git.dylib:arm64+0x3d1bd8)
    #8 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) HostNativeThreadBase.cpp:62 (liblldb.15.0.0git.dylib:arm64+0x4c71ac)
    #9 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) HostThreadMacOSX.mm:18 (liblldb.15.0.0git.dylib:arm64+0x29ef544)

  Previous read of size 1 at 0x00010b66bb68 by main thread:
    #0 lldb_private::IOHandler::GetIsDone() IOHandler.h:92 (liblldb.15.0.0git.dylib:arm64+0x971db8)
    #1 IOHandlerProcessSTDIO::Run() Process.cpp:4339 (liblldb.15.0.0git.dylib:arm64+0x5ddc7c)
    #2 lldb_private::Debugger::RunIOHandlers() Debugger.cpp:982 (liblldb.15.0.0git.dylib:arm64+0x3cb48c)
    #3 lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) CommandInterpreter.cpp:3298 (liblldb.15.0.0git.dylib:arm64+0x506478)
    #4 lldb::SBDebugger::RunCommandInterpreter(bool, bool) SBDebugger.cpp:1166 (liblldb.15.0.0git.dylib:arm64+0x53604)
    #5 Driver::MainLoop() Driver.cpp:634 (lldb:arm64+0x100006294)
    #6 main Driver.cpp:853 (lldb:arm64+0x100007344)

Differential revision: https://reviews.llvm.org/D120762
2022-03-02 15:55:49 -08:00
Stanislav Mekhanoshin b05918f2f7 [AMDGPU] Removed XFAIL from hsa-gfx940-v3.s. NFC.
Handling of big endian was fixed in D88858.
2022-03-02 15:38:14 -08:00
Aakanksha 840695814a [AMDGPU] Add gfx1036 target
Differential Revision: https://reviews.llvm.org/D120846
2022-03-02 23:26:38 +00:00
Peter Klausler 93f42491a5 [flang] Extend ProvenanceRange::Suffix() to handle crash case
Suffix() can be called from AllSources::IntersectionWithSourceFiles()
when a contiguous range of source provenance overlaps a macro expansion.
It skips over the macro expansion and recurses on the remainder of
the range, which might end with a bit that does overlap with a
source file.  However, in the case where the original range is
entirely within the expanded macro, Suffix() crashes when called
with a skip offset greater than the size of the range.

Rather than add logic around this and other calls to Suffix() to
avoid passing an out-of-range skip, it's better to accommodate it
in Suffix() and return an empty result.

Differential Revision: https://reviews.llvm.org/D120843
2022-03-02 15:24:35 -08:00
Peter Klausler 79f8e909ed [flang] Avoid bogus warning from MSVC build
And expand common::BitSet from 64 to 128 maximum elements.

Differential Revision: https://reviews.llvm.org/D120848
2022-03-02 15:23:45 -08:00
Stanislav Mekhanoshin ad786f5a5c [AMDGPU] Fix 3 tests with expensive checks. NFC.
Image instructions are now not available for all targets anymore,
so a generic target cannot use it.
2022-03-02 14:56:48 -08:00
Arthur O'Dwyer dc1c67624b [libc++] Preliminary cleanups to ranges::iter_move. NFC.
This is just getting some non-functional cleanups out of the way
prior to the meat of the change in D120417.
2022-03-02 17:51:17 -05:00
Zequan Wu 302d7179e1 [LLDB] Add error message when using --show-variable-ranges without -v 2022-03-02 14:20:14 -08:00
Stanislav Mekhanoshin 35ec58d8c0 [AMDGPU] gfx940 removes all image instructions
Differential Revision: https://reviews.llvm.org/D120763
2022-03-02 13:55:26 -08:00
Stanislav Mekhanoshin 2e2e64df4a [AMDGPU] Add gfx940 target
This is target definition only.

Differential Revision: https://reviews.llvm.org/D120688
2022-03-02 13:54:48 -08:00
David Blaikie 59262d2d4b Attempt fix for Bazel build from
3ba66435d9
2022-03-02 21:47:25 +00:00
Zequan Wu 15983c28aa [LLDB] Dump valid ranges of variables
This allows `image lookup -a ... -v` to print variables only if the given
address is covered by the valid ranges of the variables. Since variables created
in dwarf plugin always has empty scope range, print the variable if it has
empty scope.

Differential Revision: https://reviews.llvm.org/D119963
2022-03-02 13:44:19 -08:00
Sanjay Patel c33dbc2a2d [SDAG] refactor foldSetCCWithRotate; NFC
There are more potential optimizations to make here,
so rearrange to make it easier to append those.
2022-03-02 16:42:05 -05:00
Sanjay Patel 68069f27d9 [x86] add nounwind attribute to test; NFC
This will avoid some noise in case the register allocation changes.
2022-03-02 16:42:04 -05:00
Pavel Labath 4977da2c55 [lldb] Explicitly declare the default constructor in PlatformAndroidRemoteGDBServer
MSVC does not seem to like the inheriting constructor.
2022-03-02 22:35:54 +01:00
Martin Storsjö 142501117a [libcxx] [test] Fix en_US money locale formatting tests on Windows
In the en_US locale on Windows, negative currency amounts is formatted
as "($0.01)" instead of "-$0.01".

Adjust the test references accordingly, making these tests pass.

Differential Revision: https://reviews.llvm.org/D120798
2022-03-02 23:24:37 +02:00
River Riddle 3ba66435d9 [mlir][SPIRV] Split up StandardToSPIRV now that the Standard dialect is gone
StandardToSPIRV currently contains an assortment of patterns converting from
different dialects to SPIRV. This commit splits up StandardToSPIRV into separate
conversions for each of the dialects involved (some of which already exist).

Differential Revision: https://reviews.llvm.org/D120767
2022-03-02 13:14:36 -08:00
spupyrev f2ade65fb2 [CSSPGO] Even flow distribution
Differential Revision: https://reviews.llvm.org/D118640
2022-03-02 13:12:05 -08:00