Commit Graph

368037 Commits

Author SHA1 Message Date
Roman Lebedev 03bd5198b6
[OldPM] Pass manager: run SROA after (simple) loop unrolling
I have stumbled into this pretty accidentally, when rewriting
some spaghetti-like code into something more structured,
which involved using some `std::array<>`s. And to my surprise,
the `alloca`s remained, causing about `+160%` perf regression.

https://llvm-compile-time-tracker.com/compare.php?from=bb6f4d32aac3eecb51909f4facc625219307ee68&to=d563e66f40f9d4d145cb2050e41cb961e2b37785&stat=instructions
suggests that this has geomean compile-time cost of `+0.08%`.

Note that D68593 / cecc0d27ad
already did this chage for NewPM, but left OldPM in a pessimized state.

This fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40011 | PR40011 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=42794 | PR42794 ]] and probably some other reports.

Reviewed By: nikic, xbolva00

Differential Revision: https://reviews.llvm.org/D87972
2020-10-04 11:53:50 +03:00
Alexey Baturo 51beb0c80d [RISCV][ASAN] unwind fixup
[8/11] patch series to port ASAN for riscv64

Depends On D87577

Reviewed By: eugenis, vitalybuka

Differential Revision: https://reviews.llvm.org/D87579
2020-10-04 11:13:12 +03:00
Jonas Devlieghere 0f08a1a5b1 [lldb] [test/Register] Mark new FP reg tests XFAIL on Darwin
This is failing on GreenDragon:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/24066/
2020-10-03 22:36:28 -07:00
Craig Topper ae2e51597f [X86] LOADIWKEY, ENCODEKEY128 and ENCODEKEY256 clobber EFLAGS. 2020-10-03 21:55:03 -07:00
Craig Topper a7e45ea30d [X86] Add memory operand to AESENC/AESDEC Key Locker instructions.
This removes FIXMEs from selectAddr.
2020-10-03 21:42:16 -07:00
Craig Topper 39fc4a0b0a [X86] Move ENCODEKEY128/256 handling from lowering to selection.
We should avoid emitting MachineSDNodes from lowering.

We can use the the implicit def handling in InstrEmitter to avoid
manually copying from each xmm result register. We only need to
manually emit the copies for the implicit uses.
2020-10-03 18:44:53 -07:00
Craig Topper 7f3da48885 [X86] Remove X86ISD::MWAITX_DAG. Just match the intrinsic to the custom inserter pseudo instruction during isel. 2020-10-03 18:44:53 -07:00
Stephen Neuendorffer e9b87f43bd [RFC] Factor out repetitive cmake patterns for llvm-style projects
New projects (particularly out of tree) have a tendency to hijack the existing
llvm configuration options and build targets (add_llvm_library,
add_llvm_tool).  This can lead to some confusion.

1) When querying a configuration variable, do we care about how LLVM was
configured, or how these options were configured for the out of tree project?
2) LLVM has lots of defaults, which are easy to miss
(e.g. LLVM_BUILD_TOOLS=ON).  These options all need to be duplicated in the
CMakeLists.txt for the project.

In addition, with LLVM Incubators coming online, we need better ways for these
incubators to do things the "LLVM way" without alot of futzing.  Ideally, this
would happen in a way that eases importing into the LLVM monorepo when
projects mature.

This patch creates some generic infrastructure in llvm/cmake/modules and
refactors MLIR to use this infrastructure.  This should expand to include
add_xxx_library, which is by far the most complicated bit of building a
project correctly, since it has to deal with lots of shared library
configuration bits.  (MLIR currently hijacks the LLVM infrastructure for
building libMLIR.so, so this needs to get refactored anyway.)

Differential Revision: https://reviews.llvm.org/D85140
2020-10-03 17:12:35 -07:00
Craig Topper adccc0bfa3 [X86] Add X86ISD opcodes for the Key Locker AESENC*KL and AESDEC*KL instructions
Instead of emitting MachineSDNodes during lowering, emit X86ISD
opcodes. These opcodes will either be selected by tablegen
patterns or custom selection code.

Emitting MachineSDNodes during lowering is uncommon so this makes
things more consistent. It also allows selectAddr to be called to
perform address matching during instruction selection.

I had trouble getting tablegen to accept XMM0-XMM7 as results in
an isel pattern for the WIDE instructions so I had to use custom
instruction selection.
2020-10-03 16:55:19 -07:00
Jacques Pienaar 9b851527d5 Add indented raw_ostream class
Class simplifies keeping track of the indentation while emitting. For every new line the current indentation is simply prefixed (if not at start of line, then it just emits as normal). Add a simple Region helper that makes it easy to have the C++ scope match the emitted scope.

Use this in op doc generator and rewrite generator.

This reverts revert commit be185b6a73 addresses shared lib failure by fixing up cmake files.

Differential Revision: https://reviews.llvm.org/D84107
2020-10-03 15:17:38 -07:00
Alexander Shaposhnikov d20c602aad [Object][MachO] Refactor MachOUniversalWriter
This diff refactors writeUniversalBinary and adds writeUniversalBinaryToBuffer.
This is a preparation for adding support for universal binaries to llvm-objcopy.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D88372
2020-10-03 14:18:38 -07:00
Mircea Trofin 0a3523299d [MC] Assert that MCRegUnitIterator operates over MCRegisters
The signature of the ctor expects a MCRegister, but currently any
unsigned value can be converted to a MCRegister.

This patch checks that indeed the provided value is a physical register
only. We want to eventually stop implicitly converting unsigned or
Register to MCRegister (which is incorrect). The next step after this
patch is changing uses of MCRegUnitIterator to explicitly cast Register
or unsigned values to MCRegister. To that end, this patch also
introduces 2 APIs that make that conversion checked and explicit.

Differential Revision: https://reviews.llvm.org/D88705
2020-10-03 13:18:25 -07:00
Michał Górny 508ac0ec13 [lldb] [test/Register] Mark new FP reg tests XFAIL on Windows 2020-10-03 22:16:29 +02:00
Florian Hahn 82dcd383c4 [VPlan] Properly update users when updating operands.
When updating operands of a VPUser, we also have to adjust the list of
users for the new and old VPValues. This is required once we start
transitioning recipes to become VPValues.
2020-10-03 20:54:58 +01:00
Roman Lebedev cd20c26622
[NFC][InstCombine] Autogenerate a few tests being affected by an upcoming patch 2020-10-03 22:49:58 +03:00
Roman Lebedev 1038ce4b6b
[NFC][PhaseOrdering] Add a test showing new inttoptr casts after SROA due to InstCombine (PR47592)
We could either try to make SROA more picky to the new type
and/or prevent InstCombine from creating the original problem (converting load-stores to operate on ints),
and/or make InstCombine recover the situation by cleaning up all that cruft.
2020-10-03 22:49:58 +03:00
Florian Hahn ef72591de9 [LV] Add another test case with unsinkable first-order recurrences. 2020-10-03 20:41:41 +01:00
Martin Storsjö 7d07405761 [AArch64] Prefer prologues with sp adjustments merged into stp/ldp for WinCFI, if optimizing for size
This makes the prologue match the windows canonical layout, for
cases without a frame pointer.

This can potentially be a slower (a longer dependency chain of the
sp register, and potentially one arithmetic operation more on some
cores), but gives notable size improvements.

The previous two commits shrinks a 166 KB xdata section by 49 KB,
and if the change from this commit is enabled, it shrinks the xdata
section by another 25 KB.

In total, since the start of the recent arm64 unwind info cleanups
and optimizations (since before commit 37ef743cbf), the xdata+pdata
sections of the same test DLL has shrunk from 407 KB in total
originally, to 163 KB now.

Differential Revision: https://reviews.llvm.org/D88701
2020-10-03 21:37:22 +03:00
Martin Storsjö 890af2f003 [AArch64] Allow pairing lr with other GPRs for WinCFI
This saves one instruction per prologue/epilogue for any function with
an odd number of callee-saved GPRs, but more importantly, allows such
functions to match the packed unwind format.

Differential Revision: https://reviews.llvm.org/D88699
2020-10-03 21:37:22 +03:00
Martin Storsjö 3780a4e568 [AArch64] Match the windows canonical callee saved register order
On windows, the callee saved registers in a canonical prologue are
ordered starting from a lower register number at a lower stack
address (with the possible gap for aligning the stack at the top);
this is the opposite order that llvm normally produces.

To achieve this, reverse the order of the registers in the
assignCalleeSavedSpillSlots callback, to get the stack objects
laid out by PrologEpilogInserter in the right order, and adjust
computeCalleeSaveRegisterPairs to lay them out from the bottom up.

This allows generated prologs more often to match the format that
allows the unwind info to be written as packed info.

Differential Revision: https://reviews.llvm.org/D88677
2020-10-03 21:37:22 +03:00
Nico Weber ba60dc0aa7 Revert "[Driver] Move detectLibcxxIncludePath to ToolChain"
This reverts commit e25bf25920.
Breaks tests on Windows, see comments on https://reviews.llvm.org/D88452
2020-10-03 14:22:53 -04:00
Nathan Lanza fcb0ab5933 [clang][NFC] Change a mention of `objc_static_protocol` to `non_runtime` 2020-10-03 14:04:14 -04:00
Michał Górny 381bdc75ee [lldb] [test/Register] Add read/write tests for x87 regs
Add a partial read/write tests for x87 FPU registers.  This includes
reading and writing ST registers, control registers and floating-point
exception data registers (fop, fip, fdp).

The tests assume the current (roughly incorrect) behavior of reporting
the 'abridged' 8-bit ftag state as 16-bit ftag.  They also assume Linux
plugin behavior of reporting fip/fdp split into halves as (fiseg, fioff)
and (foseg, fooff).

Differential Revision: https://reviews.llvm.org/D88583
2020-10-03 19:54:38 +02:00
Michał Górny 9821632056 [lldb] [Process/NetBSD] Fix crash on unsupported i386 regs
Multiple fixes related to bugs discovered while debugging a crash
when reading all registers on i386.

The underlying problem was that GetSetForNativeRegNum() did not account
for MPX registers on i386, and since it only compared against upper
bounds of each known register set, the MPX registers were classified
into the wrong set and therefore considered supported.  However, they
were not expected in RegNumX86ToX86_64() and caused the assertion
to fail.

This includes:

- adding (unused) i386 → x86_64 translations for MPX registers
- fixing GetSetForNativeRegNum() to check both lower and upper bound
  for register sets, to avoid wrongly classifying unhandled register
  sets
- adding missing range check for MPX registers on i386
- renaming k_last_mpxr to k_last_mpxr_i386 for consistency
- replacing return-assertions with llvm_unreachable() and adding more
  checks for unexpected parameters

Differential Revision: https://reviews.llvm.org/D88682
2020-10-03 19:54:38 +02:00
Michał Górny 80b108f404 [lldb] [Process/NetBSD] Fix reading FIP/FDP registers
Fix reading FIP/FDP registers to correctly return segment and offset
parts.  On amd64, this roughly matches the Linux behavior of splitting
the 64-bit FIP/FDP into two halves, and putting the higher 32 bits
into f*seg and lower into f*off.  Well, actually we use only 16 bits
of higher half but the CPUs do not seem to handle more than that anyway.

Differential Revision: https://reviews.llvm.org/D88681
2020-10-03 19:54:38 +02:00
Michał Górny 66e493f81e [asan] Stop instrumenting user-defined ELF sections
Do not instrument user-defined ELF sections (whose names resemble valid
C identifiers).  They may have special use semantics and modifying them
may break programs.  This is e.g. the case with NetBSD __link_set API
that expects these sections to store consecutive array elements.

Differential Revision: https://reviews.llvm.org/D76665
2020-10-03 19:54:38 +02:00
Simon Pilgrim 53fc426088 [InstCombine] Add tests for or(shl(x,c1),lshr(y,c2)) patterns that could fold to funnel shifts
Some initial test coverage toward fixing PR46896 - these are just copied from rotate.ll
2020-10-03 18:32:47 +01:00
Simon Pilgrim dca4b7130d [Analysis] resolveAllCalls - fix use after std::move warning. NFCI.
We can't use Use.Calls after its std::move()'d to TmpCalls as it will be in an undefined state. Instead, swap with the known empty map in TmpCalls so we can then safely emplace_back into the now empty Use.Calls.

Fixes clang static analyzer warning.
2020-10-03 17:52:20 +01:00
Jacques Pienaar be185b6a73 Revert "Add indented raw_ostream class"
This reverts commit 78530ce653.

Fails on shared_lib build.
2020-10-03 09:41:35 -07:00
Simon Pilgrim b82a7486d1 [InstCombine] Add or(shl(v,and(x,bw-1)),lshr(v,bw-and(x,bw-1))) rotate tests
If we know the shift amount is less than the bitwidth we should be able to convert this to a rotate/funnel shift
2020-10-03 17:17:42 +01:00
Jacques Pienaar 78530ce653 Add indented raw_ostream class
Class simplifies keeping track of the indentation while emitting. For every new line the current indentation is simply prefixed (if not at start of line, then it just emits as normal). Add a simple Region helper that makes it easy to have the C++ scope match the emitted scope.

Use this in op doc generator and rewrite generator.

Differential Revision: https://reviews.llvm.org/D84107
2020-10-03 08:53:43 -07:00
David Green 7feafa0286 [ARM] Fix pointer offset when splitting stores from VMOVDRR
We were not accounting for the pointer offset when splitting a store from
a VMOVDRR node, which could lead to incorrect aliasing info. In this
case it is the fneg via integer arithmetic that gives us a store->load
pair that we started getting wrong.

Differential Revision: https://reviews.llvm.org/D88653
2020-10-03 16:47:50 +01:00
Simon Pilgrim aacfe2be53 [InstCombine] recognizeBSwapOrBitReverseIdiom - add vector support
Add basic vector handling to recognizeBSwapOrBitReverseIdiom/collectBitParts - this works at the element level, all vector element operations must match (splat constants etc.) and there is no cross-element support (insert/extract/shuffle etc.).
2020-10-03 16:26:46 +01:00
Aaron Ballman 089e628b61 Add a break statement to appease the build bots; NFC 2020-10-03 11:10:26 -04:00
Simon Pilgrim 347fd9955a [InstCombine] recognizeBSwapOrBitReverseIdiom - use generic CreateIntegerCast
Try to appease buildbots breakages due to D88578
2020-10-03 15:29:22 +01:00
Andrzej Warzynski 35a2a042dd [flang][NFC] Fix build errors for clang-10
This patch fixes one worning. Since Flang sets `-Werror`, that's
sufficient for a build to fail. As per flang/README.md, Clang-10 is one
of the officially supported compilers.

Differential Revision: https://reviews.llvm.org/D88723
2020-10-03 15:10:17 +01:00
Bernhard Manfred Gruber 07028cd5db modernize-use-trailing-return-type fix for PR44206
Prevent rewrite when an unqualified id in a typedef type collides
with a function argument name. Fixes PR44206.
2020-10-03 10:08:44 -04:00
Simon Pilgrim 3aa93f690b [InstCombine] recognizeBSwapOrBitReverseIdiom - support for 'partial' bswap patterns (PR47191) (Reapplied)
If we're bswap'ing some bytes and zero'ing the remainder we can perform this as a bswap+mask which helps us match 'partial' bswaps as a first step towards folding into a more complex bswap pattern.

Reapplied with early-out if recognizeBSwapOrBitReverseIdiom collects a source wider than the result type.

Differential Revision: https://reviews.llvm.org/D88578
2020-10-03 14:52:42 +01:00
Roman Lebedev 1596cc8350
[NFCI][clang-tidy] FunctionCognitiveComplexityCheck::check(): try to fix windows arm build bots
http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/1482/steps/build-llvm-project/logs/stdio
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/3285/steps/build-llvm-project/logs/stdio
2020-10-03 16:02:19 +03:00
Mark de Wever 0ce6d6b46e [Sema] List conversion validate character array.
The function `TryListConversion` didn't properly validate the following
part of the standard:

    Otherwise, if the parameter type is a character array [... ]
    and the initializer list has a single element that is an
    appropriately-typed string literal (8.5.2 [dcl.init.string]), the
    implicit conversion sequence is the identity conversion.

This caused the following call to `f()` to be ambiguous.
    void f(int(&&)[1]);
    void f(unsigned(&&)[1]);

    void g(unsigned i) {
      f({i});
    }

This issue only occurs when the initializer list had one element.

Differential Revision: https://reviews.llvm.org/D87561
2020-10-03 14:33:28 +02:00
David Green 49e34e239b [ARM] Test to show incorrect pointer info. NFC 2020-10-03 12:25:34 +01:00
Nikita Popov fbf818724f [MemCpyOpt] Make moveUp() a member method (NFC)
So we don't have to pass through more parameters in the future.
2020-10-03 11:28:49 +02:00
Nikita Popov baaada39c2 [MemCpyOpt] Remove unnecessary -dse from test (NFC)
This one doesn't even have any dead stores to eliminate...
2020-10-03 11:28:49 +02:00
Craig Topper e2dd86bbfc [X86] Key Locker instructions should use VR128 regclass not VR128X. 2020-10-02 21:55:07 -07:00
Evandro Menezes a0a8f83718 [PATCH] Fix typo (NFC) 2020-10-02 21:19:14 -05:00
Petr Hosek e25bf25920 [Driver] Move detectLibcxxIncludePath to ToolChain
This helper method is useful even outside of Gnu toolchains, so move
it to ToolChain so it can be reused in other toolchains such as Fuchsia.

Differential Revision: https://reviews.llvm.org/D88452
2020-10-02 18:37:20 -07:00
Craig Topper 8ae4842669 [X86] Move MWAITX_DAG ISD opcode so it is not in the strict FP range.
Add a comment to hopefully prevent anyone else from making the
same mistake.
2020-10-02 18:22:02 -07:00
Craig Topper 63fc8499f3 [X86] Add missing intrinsic test for aesdecwide128kl and aesdecwide256kl. Capture all output values in keylocker tests. NFC
The aesdec/enc instructions produce a flag output and one or eight
xmm regsiter outputs. The test were not capturing the xmm outputs.

Also add nounwind to tests to remove .cfi directives
2020-10-02 18:16:26 -07:00
Roland McGrath 5b0cfe93b6 Revert "[lsan] Share platform allocator settings between ASan and LSan"
This reverts commit 1c897e9d72.

It broke builds for 32-bit targets.

Differential Revision: https://reviews.llvm.org/D88768
2020-10-02 18:14:57 -07:00
Roland McGrath 1c897e9d72 [lsan] Share platform allocator settings between ASan and LSan
This moves the platform-specific parameter logic from asan into
lsan_common.h to lsan can share it.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D87795
2020-10-02 17:55:46 -07:00