Commit Graph

436209 Commits

Author SHA1 Message Date
Vitaly Buka 2cf9b25aa9 [test][msan] Use implicit-check-not 2022-09-14 18:44:22 -07:00
Sheng bea33f75e2 [M68k] Fix the crash of fast register allocator
`MOVEM` is used to spill the register, which will cause problem with 1 byte data, since it only supports word (2 bytes) and long (4 bytes) size.

We change to use the normal `move` instruction to spill 1 byte data.

Fixes #57660

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D133636
2022-09-15 09:24:22 +08:00
Jeff Niu 9c7ba57e70 [mlir] Allow `Attribute::print` to elide the type
This patch adds a flag to `Attribute::print` that prints the attribute
without its type.

Fixes #57689

Reviewed By: rriddle, lattner

Differential Revision: https://reviews.llvm.org/D133822
2022-09-14 18:17:30 -07:00
Jeff Niu 9eec5284c7 [mlir][ods] Add cppClassName to ConfinedType
So ODS can generate `OneTypedResult` when a ConfinedType is used as a
result type.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D133893
2022-09-14 18:16:07 -07:00
Giorgis Georgakoudis 7539e9cf81 [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert, jhuber6, ABataev

Differential Revision: https://reviews.llvm.org/D102107
2022-09-15 00:54:05 +00:00
Stanislav Mekhanoshin ef4b9c33f5 Fix crash while printing MMO target flags
MachineMemOperand::print can dereference a NULL pointer if TII
is not passed from the printMemOperand. This does not happen while
dumping the DAG/MIR from llc but crashes the debugger if a dump()
method is called from gdb.

Differential Revision: https://reviews.llvm.org/D133903
2022-09-14 17:29:48 -07:00
Craig Topper 5888c157a7 [RISCV] Simplify some code in RISCVInstrInfo::verifyInstruction. NFCI
This code was written as if it lived in the MC layer instead of
the CodeGen layer. We get the MCInstrDesc directly from MachineInstr.
And we can use RISCVSubtarget::is64Bit instead of going to the
Triple.

Differential Revision: https://reviews.llvm.org/D133905
2022-09-14 17:07:21 -07:00
Sam Clegg 8273ca1421 [MC] Fix typo in getSectionAddressSize comment. NFC
The comment was refering to a now non-existant function that was removed
in 93e3cf0ebd.

Differential Revision: https://reviews.llvm.org/D133098
2022-09-14 15:15:41 -07:00
Craig Topper 50a699e362 [IR][VP] Remove IntrArgMemOnly from vp.gather/scatter.
IntrArgMemOnly is only valid for intrinsics that use a scalar
pointer argument. These intrinsics use a vector of pointer.

Alias analysis will try to find a scalar pointer argument and
will return incorrect alias results when it doesn't find one.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D133898
2022-09-14 15:00:07 -07:00
Craig Topper 6384044df4 [GVN][VP] Add test case for incorrect removal of a vp.gather. NFC
Pre-commit for D133898

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D133899
2022-09-14 15:00:07 -07:00
Jez Ng 118bfde90a [lld-macho] Have ICF dedup explicitly-defined selrefs
This is what ld64 does (though it doesn't use ICF to do this; instead it
always dedups selrefs by default).

We'll want to dedup implicitly-defined selrefs as well, but I will leave
that for future work.

Additionally, I'm not *super* happy with the current LLD implementation
because I think it is rather janky and inefficient. But at least it
moves us toward the goal of closing the size gap with ld64. I've
described ideas for cleaning up our implementation here:
https://github.com/llvm/llvm-project/issues/57714

Differential Revision: https://reviews.llvm.org/D133780
2022-09-14 17:59:22 -04:00
Jez Ng 8d4ca09d06 [lld-macho][nfc] Clean up ICF code
Split these changes out from https://reviews.llvm.org/D133780.
2022-09-14 17:59:22 -04:00
Vitaly Buka bf204881b6 [msan] Change logic of ClInstrumentationWithCallThreshold
According to logs, ClInstrumentationWithCallThreshold is workaround
for slow backend with large number of basic blocks.
However, I can't reproduce that one, but I see significant slowdown
after ClCheckConstantShadow. Without ClInstrumentationWithCallThreshold
compiler is able to eliminate many of the branches.

So maybe we should drop ClInstrumentationWithCallThreshold completly.

For now I just change the logic to ignore constant shadow so it will
not trigger callback fallback too early.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D133880
2022-09-14 14:58:12 -07:00
Craig Topper 6106a6d7fe [RISCV] Update error message to not call 'RV32' and 'RV64' an extension.
I used RV32 so I didn't have to write RV32I and RV32E. Ideally
these builtins will be wrapped in a header someday so long term I don't
expect users to see these errors.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D133444
2022-09-14 14:51:37 -07:00
Jim Ingham f3d0bda534 Revert "Revert "Be more careful to maintain quoting information when parsing commands.""
This reverts commit ac05bc0524.

I had incorrectly removed one set of checks in the option handling in
Options::ParseAlias because I couldn't see what it is for.  It was a
bit obscure, but it handled the case where you pass "-something=other --"
as the input_line, which caused the built-in "run" alias not to return
the right value for IsDashDashCommand, causing TestHelp.py to fail.
2022-09-14 14:49:51 -07:00
Philip Reames e395915ac0 [RISCV] Verify SEW/VecPolicy immediate values
Copy the asserts from the printing code, and turn them into actual verifier rules. Doing this revealed an existing bug - see 0a14551.

Differential Revision: https://reviews.llvm.org/D133869
2022-09-14 14:45:16 -07:00
Philip Reames 0a145516a2 [RISCV] Fix a silent miscompile in copyPhysReg
Found this when adding verifier rules. The case which arises is that we have a DefMBBI which has a VecPolicy operand. The code was not expecting this, and the unconditional copy of the last two operands resulted in the SEW and VecPolicy fields being added to the VMV_V_V as AVL and SEW respectively.

Oddly, this appears to be a silent in practice. There's no test change despite verifier changes proving that we definitely hit this in existing tests.

Differential Revision: https://reviews.llvm.org/D133868
2022-09-14 14:45:01 -07:00
Kazu Hirata cb21b7d274 [mlir] Fix warnings
This patch fixes three warnings of the form:

  mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp:1436:5: error:
  default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]
2022-09-14 14:35:19 -07:00
Lei Zhang 8a5cb939e7 [mlir][vector] Check minor identity map in FoldExtractSliceIntoTransferRead
vecotr.transfer_read ops with minor identity indexing map is rank
reducing, with implicit leading unit dimensions. This should be
a natural extension to support in addition to full identity indexing
maps.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D133883
2022-09-14 17:24:02 -04:00
Siva Chandra Reddy 6e675fba3a [libc] Add POSIX functions pread and pwrite.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D133888
2022-09-14 20:52:20 +00:00
Arthur Eubanks ccc9107ad6 [OptBisect] Add flag to print IR when opt-bisect kicks in
-opt-bisect-print-ir-path=foo will dump the IR to foo when opt-bisect-limit starts skipping passes.

Currently we don't print the IR if the opt-bisect-limit is higher than the total number of times opt-bisect is called.

This makes getting the IR right before a bad transform easier.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D133809
2022-09-14 13:48:03 -07:00
Leonard Grey ed2c3f46f5 [lsan][Darwin] Scan libdispatch and Foundation memory regions
libdispatch uses its own heap (_dispatch_main_heap) for some allocations, including the dispatch_continuation_t that holds a dispatch source's event handler.
Objective-C block trampolines (creating methods at runtime with a block as the implementations) use the VM_MEMORY_FOUNDATION region (see 8701d5672d/runtime/objc-block-trampolines.mm (L371)).

This change scans both regions to fix false positives. See tests for details; unfortunately I was unable to reduce the trampoline example with imp_implementationWithBlock on a new class, so I'm resorting to something close to the bug as seen in the wild.

Differential Revision: https://reviews.llvm.org/D129385
2022-09-14 16:46:40 -04:00
Vitaly Buka c69b269111 [pipelines] Require GlobalsAA after sanitizers
Restore GlobalsAA if sanitizers inserted at early optimize callback.
The analysis can be useful for the following FunctionPassManager.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D133537
2022-09-14 13:33:53 -07:00
Vitaly Buka 270c843005 [NFC][CodeGen] Remove empty line 2022-09-14 13:29:15 -07:00
Jeff Niu e63b574ff6 [mlir][LLVMIR] Add lifetime start and end marker instrinsics
This patch adds the `llvm.intr.lifetime.start` and `llvm.intr.lifetime.end`
intrinsics which are used to indicate to LLVM the lifetimes of allocated
memory.

These ops have the requirement that the first argument (the size) be an
"immediate argument". I added an OpTrait to check this, but it is
possible that an approach like GEPArg would work too.

Reviewed By: rriddle, dcaballe

Differential Revision: https://reviews.llvm.org/D133867
2022-09-14 13:15:14 -07:00
Stanley Winata ea68588ee6 [mlir][linalg] fix switch case for conv-vec to have brackets
Windows build requires brackets on switch-cases that initializes
variables.

Reviewed By: hanchung

Differential Revision: https://reviews.llvm.org/D133889
2022-09-14 13:08:28 -07:00
Akira Hatanaka 157f6fc8ec [compiler-rt][builtins] Enable more warnings in add_security_warnings
Enable -Wsizeof-array-div and -Wsizeof-pointer-divcompiler.

Also, replace -Wmemset-transposed-args with -Wsuspicious-memaccess. The
latter automatically enables the former and a few other warnings.

Differential Revision: https://reviews.llvm.org/D133783
2022-09-14 12:55:56 -07:00
John Ericson 3a1c81e327 [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2
A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by `add_subdirectory`; since the directory name in the source tree is fixed without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. We therefore do not replace it but leave it as-is.

This picks up where D133828 left off, getting the occurrences with*out* `CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in the (retroactively) previous diff.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D132316
2022-09-14 15:48:58 -04:00
Roland Froese 207228c1d6 [DAGCombiner] More load-store forwarding for big-endian
Get some load-store forwarding cases for big-endian where a larger store covers
a smaller load, and the offset would be 0 and handled on little-endian but on
big-endian the offset is adjusted to be non-zero. The idea is just to shift the
data to make it look like the offset 0 case.

Differential Revision: https://reviews.llvm.org/D130115
2022-09-14 15:36:35 -04:00
Fangrui Song 25394c9d10 [llvm-objdump] Change printSymbolVersionDependency to use ELFFile API
When .gnu.version_r is empty (allowed by readelf but warned by objdump),
llvm-objdump -p may decode the next section as .gnu.version_r and may crash due
to out-of-bounds C string reference. ELFFile<ELFT>::getVersionDependencies
handles 0-entry .gnu.version_r gracefully. Just use it.

Fix https://github.com/llvm/llvm-project/issues/57707

Differential Revision: https://reviews.llvm.org/D133751
2022-09-14 12:30:34 -07:00
Fangrui Song 55a72dae1f [llvm-objdump][test] Add verneed-invalid.test 2022-09-14 12:27:30 -07:00
Nico Weber cd7ffa2e52 lld: Include name of output file in "failed to write output" diag
Differential Revision: https://reviews.llvm.org/D133110
2022-09-14 14:57:47 -04:00
Michael Buch 3b44c9af8e [lldb][tests] Move C++ gmodules tests into new gmodules/ subdirectory
This is in preparation for adding more gmodules
tests.

Differential Revision: https://reviews.llvm.org/D133876
2022-09-14 14:45:35 -04:00
Tue Ly e6226e6b72 [libc][math] Improve exp2f performance.
Reduce the number of subintervals that need lookup table and optimize
the evaluation steps.

Currently, `exp2f` is computed by reducing to `2^hi * 2^mid * 2^lo` where
`-16/32 <= mid <= 15/32` and `-1/64 <= lo <= 1/64`, and `2^lo` is then
approximated by a degree 6 polynomial.

Experiment with Sollya showed that by using a degree 6 polynomial, we
can approximate `2^lo` for a bigger range with reasonable errors:
```
> P = fpminimax((2^x - 1)/x, 5, [|D...|], [-1/64, 1/64]);
> dirtyinfnorm(2^x - 1 - x*P, [-1/64, 1/64]);
0x1.e18a1bc09114def49eb851655e2e5c4dd08075ac2p-63

> P = fpminimax((2^x - 1)/x, 5, [|D...|], [-1/32, 1/32]);
> dirtyinfnorm(2^x - 1 - x*P, [-1/32, 1/32]);
0x1.05627b6ed48ca417fe53e3495f7df4baf84a05e2ap-56
```
So we can optimize the implementation a bit with:
# Reduce the range to `mid = i/16` for `i = 0..15` and `-1/32 <= lo <= 1/32`
# Store the table `2^mid` in bits, and add `hi` directly to its exponent field to compute `2^hi * 2^mid`
# Rearrange the order of evaluating the polynomial approximating `2^lo`.

Performance benchmark using perf tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp2f
GNU libc version: 2.35
GNU libc release: stable
CORE-MATH reciprocal throughput   : 9.534
System LIBC reciprocal throughput : 6.229

BEFORE:
LIBC reciprocal throughput        : 21.405
LIBC reciprocal throughput        : 15.241    (with `-msse4.2` flag)
LIBC reciprocal throughput        : 11.111    (with `-mfma` flag)

AFTER:
LIBC reciprocal throughput        : 18.617
LIBC reciprocal throughput        : 12.852    (with `-msse4.2` flag)
LIBC reciprocal throughput        : 9.253     (with `-mfma` flag)

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp2f --latency
GNU libc version: 2.35
GNU libc release: stable
CORE-MATH latency   : 40.869
System LIBC latency : 30.580

BEFORE
LIBC latency        : 64.888
LIBC latency        : 61.027    (with `-msse4.2` flag)
LIBC latency        : 48.778    (with `-mfma` flag)

AFTER
LIBC latency        : 48.803
LIBC latency        : 45.047    (with `-msse4.2` flag)
LIBC latency        : 37.487    (with `-mfma` flag)
```

Reviewed By: sivachandra, orex

Differential Revision: https://reviews.llvm.org/D133870
2022-09-14 14:44:25 -04:00
Fangrui Song 32e1ceb49b [CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on *BSD
Similar to D107799 but for *BSD (DragonFlyBSD, FreeBSD, NetBSD, OpenBSD, etc).
This Linux default has been in main and release/15.x for a while.

`CMAKE_SYSTEM_PROCESSOR MATCHES "^arm"` is excluded for now.

Link: https://discourse.llvm.org/t/rfc-time-to-drop-legacy-runtime-paths/64628

Reviewed By: dim

Differential Revision: https://reviews.llvm.org/D110126
2022-09-14 11:24:00 -07:00
Stanley Winata 026fac2a14 [mlir][linalg] Vectorization for conv_1d_ncw_fcw
Most computer vision torch models uses nchw/ncw convolution. In a previous patch we added decomposition conv2dNchw to conv1dNcw. To enhance the performance on torch models we add this vectorization pattern for conv1dNcw which would consquently also improve the performance on conv2dNchw.

On IREE + Intel Xeon 8360 + Resnet50, we were able to get ~7x speed up ~880ms to 126ms.

Reviewed By: nicolasvasilache, hanchung

Differential Revision: https://reviews.llvm.org/D133675
2022-09-14 11:07:53 -07:00
Piotr Sobczak abd927e5a8 [AMDGPU] Check for num elts in SelectVOP3PMods
The rest of the code section assumes there are exactly two elements
in the vector (Lo, Hi), so add the check before entering the section.

Differential Revision: https://reviews.llvm.org/D133852
2022-09-14 20:00:19 +02:00
Julius 49e7ef2c09 [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode
When running in MSVC compatibility mode, previously no deprecated copy
operation warnings (enabled by -Wdeprecated-copy) were raised. This
restriction was already in place when the deprecated copy warning was
first introduced.

This patch removes said restriction so that deprecated copy warnings, if
enabled, are also raised in MSVC compatibility mode. The reasoning here
being that these warnings are still useful when running in MSVC
compatibility mode and also have to be semi-explicitly enabled in the
first place (using -Wdeprecated-copy, -Wdeprecated or -Wextra).

Differential Revision: https://reviews.llvm.org/D133354
2022-09-14 19:48:08 +02:00
Florian Hahn 7f3ff9d3c0
[ConstraintElimination] Track if variables are positive in constraint.
Keep track if variables are known positive during constraint
decomposition, aggregate the information when building the constraint
object and encode the extra information as constraints to be used during
reasoning.
2022-09-14 18:43:54 +01:00
Thomas Raoux 4abb9e5d20 [mlir][vector] Clean up and generalize lowering of warp_execute to scf
Simplify the lowering of warp_execute_on_lane0 of scf.if by making the
logic more generic. Also remove the assumption that the most inner
dimension is the dimension distributed.

Differential Revision: https://reviews.llvm.org/D133826
2022-09-14 17:36:16 +00:00
Matt Arsenault c9ef7d49ab llvm-reduce: Do not insert replacement IMPLICIT_DEFs for dead defs
Also skip dead defs when looking for a previous vreg with the same
class. This helps avoid some mid-reduction verifier errors when
LiveIntervals computation starts introducing dead flags everywhere.
2022-09-14 13:21:14 -04:00
Matt Arsenault 0e1ee738f1 llvm-reduce: Restrict test to only test relevant reductions
Avoids breaking this test in a future change.
2022-09-14 13:21:01 -04:00
Joseph Huber 23bc343855 [Libomptarget] Change device free routines to accept the allocation kind
Previous support for device memory allocators used a single free
routine and did not provide the original kind of the allocation. This is
problematic as some of these memory types required different handling.
Previously this was worked around using a map in runtime to record the
original kind of each pointer. Instead, this patch introduces new free
routines similar to the existing allocation routines. This allows us to
avoid a map traversal every time we free a device pointer.

The only interfaces defined by the standard are `omp_target_alloc` and
`omp_target_free`, these do not take a kind as `omp_alloc` does. The
standard dictates the following:

"The omp_target_alloc routine returns a device pointer that references
the device address of a storage location of size bytes. The storage
location is dynamically allocated in the device data environment of the
device specified by device_num."

Which suggests that these routines only allocate the default device
memory for the kind. So this has been changed to reflect this. This
change is somewhat breaking if users were using `omp_target_free` as
previously shown in the tests.

Reviewed By: JonChesterfield, tianshilei1992

Differential Revision: https://reviews.llvm.org/D133053
2022-09-14 12:14:07 -05:00
Nico Weber 5631d20bfc Revert "[clang] fix generation of .debug_aranges with LTO"
This reverts commit 6bf6730ac5.
Breaks tests if LLD isn't being built, see comments on
https://reviews.llvm.org/D133092
2022-09-14 12:43:24 -04:00
revunov.denis@huawei.com 553c238952 [BOLT] Preserve original LSDA type encoding
In non-pie binaries BOLT unconditionally converted type encoding
from indirect to absptr, which broke std exceptions since pointers
to their typeinfo were only assigned at runtime in .data section.
In this patch we preserve original encoding so that indirect
remains indirect and can be resolved at runtime, and absolute remains absolute.

Reviewed By: rafauler, maksfb

Differential Revision: https://reviews.llvm.org/D132484
2022-09-14 16:33:47 +00:00
Ashay Rane f1848b0a0e
[clang] fix linker executable path in test
A previous patch (https://reviews.llvm.org/D132810) introduced a test
that fails on systems where the linker executable (`ld`) has a `.exe`
extension.  This patch updates the regex in the test so that lit can
look for both `ld` as well as `ld.exe`.

Reviewed By: stella.stamenova

Differential Revision: https://reviews.llvm.org/D133773
2022-09-14 11:35:37 -05:00
Stella Stamenova da459043f8 Revert "[lldb][DWARF5] Enable macro evaluation"
This reverts commit a0fb69d17b.

This broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/23666
2022-09-14 09:30:49 -07:00
Nico Weber db6a53450f Revert "[test][clang] run test for lld emitting dwarf-aranages only if lld is presented"
This reverts commit 44075cc34a.
Broke check-clang, see comments on https://reviews.llvm.org/D133841
2022-09-14 12:17:41 -04:00
Eman Copty 54bd8bb452 [mlir] Add accessor methods for I[2|4|16] types to Builder.
Adds the accessor methods for I[2|4|16] types to the Builder.

Differential Revision: https://reviews.llvm.org/D133793
2022-09-14 09:06:00 -07:00
Peiming Liu 55a1d50fb9 [mlir][sparse] Make sparse compiler more admissible.
Previously, the iteration graph is computed without priority. This patch add a heuristic when computing the iteration graph by starting with Reduction iterator when doing topo sort, which makes Reduction iterators (likely) appear as late in the sorted array as possible.

The current sparse compiler also failed to compile the newly added case.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133738
2022-09-14 15:59:47 +00:00