bixia1 [Wed, 11 Jan 2023 16:59:00 +0000 (08:59 -0800)]
[mlir][sparse] Refactor the code that reshapes the values buffer for annotated all dense tensors.
Move the functionality to codegen utils for sharing with the codegen path.
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D141514
Sami Tolvanen [Wed, 11 Jan 2023 23:06:20 +0000 (23:06 +0000)]
[ModuleUtils][KCFI] Set patchable-function-prefix for synthesized functions
When -fpatchable-function-entry is used to emit prefix nops
before functions, KCFI assumes all indirectly called functions
have the same number of prefix nops, because the nops are emitted
between the KCFI type hash and the function entry. However, as
patchable-function-prefix is a function attribute set by Clang,
functions later synthesized by LLVM don't inherit this attribute
and end up not having prefix nops. One of these functions
is asan.module_ctor, which the Linux kernel ends up calling
indirectly when KASAN is enabled.
In order to avoid tripping KCFI, save the expected prefix offset
to a module flag, and use it when we're setting KCFI type for the
relevant synthesized functions.
Link: https://github.com/ClangBuiltLinux/linux/issues/1742
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D141172
Alex Brachet [Wed, 11 Jan 2023 23:42:19 +0000 (23:42 +0000)]
[GWP-ASan] Fix 6413872
Use testing not zxtest in non-Fuchsia case
Yaxun (Sam) Liu [Tue, 10 Jan 2023 20:58:57 +0000 (15:58 -0500)]
[HIP] Use .hipi as preprocessor output extension
so that clang can recognize it and handle it automatically
without -x hip-cpp-output.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D141437
Fangrui Song [Wed, 11 Jan 2023 23:33:50 +0000 (15:33 -0800)]
[llvm-lto2] Remove unused include after D123126
Fangrui Song [Wed, 11 Jan 2023 23:30:54 +0000 (15:30 -0800)]
[bazel] Fix some --features=layering_check issues
Francis Visoiu Mistrih [Mon, 28 Nov 2022 20:26:54 +0000 (15:26 -0500)]
[Matrix] Optimize matrix transposes around additions
First, sink the transposes to the operands to simplify redudant
ones. Then, lift them to reduce the number of realized transposes.
```
(A + B)^T -> A^T + B^T -> (A + B)^T
```
See tests for more examples.
Differential Revision: https://reviews.llvm.org/D133657
Fangrui Song [Wed, 11 Jan 2023 23:18:10 +0000 (15:18 -0800)]
[llvm-profdata] Remove an unused include after D115915
Alex Brachet [Wed, 11 Jan 2023 23:16:19 +0000 (23:16 +0000)]
[GWP-ASan] Fix test to work with Fuchsia's zxtest
Alexander Yermolovich [Wed, 11 Jan 2023 23:06:42 +0000 (15:06 -0800)]
[llvm][dwwarf] Change CU/TU index to 64-bit
Changed contribution data structure to 64 bit. I added the 32bit and 64bit
accessors to make it explicit where we use 32bit and where we use 64bit. Also to
make sure sure we catch all the cases where this data structure is used.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D139379
Sami Tolvanen [Fri, 6 Jan 2023 20:54:09 +0000 (20:54 +0000)]
[GCOV] Set !kcfi_type metadata for indirectly called functions
With CONFIG_GCOV_KERNEL, the Linux kernel indirectly calls the
__llvm_gcov_* functions generated by LLVM. With -fsanitize=kcfi,
these calls are made from instrumented code and fail indirect
call checks as they don't have !kcfi_type metadata. Similarly
to D138945, set type metadata for these functions to allow GCOV
and KCFI to be both enabled.
Link: https://github.com/ClangBuiltLinux/linux/issues/1778
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D141444
Alexander Yermolovich [Wed, 11 Jan 2023 22:40:54 +0000 (14:40 -0800)]
Revert "[llvm][dwwarf] Change CU/TU index to 64-bit"
This reverts commit
fa3fa4d0d42326005dfd5887bf047b86904d3be6.
spupyrev [Mon, 12 Dec 2022 19:29:02 +0000 (11:29 -0800)]
[BOLT] using jump weights in profi
We want to use profile inference (profi) in BOLT for stale profile matching.
This is the second change for existing usages of profi (e.g., CSSPGO):
(i) Added the ability to provide (estimated) jump weights for the algorithm. The
goal of the algorithm is to create a valid control flow for a given function
(that is, one in which incoming counts equal outgoing counts for every basic
block while minimally modifying the original input block and jump weights). The
input jump weights will be provided based on collected LBR profiles in BOLT.
(ii) Added the corresponding options to ProfiParams.
(iii) Slightly modified / simplified the construction of the flow network in profi
so as it utilizes fewer auxiliary nodes. This is done by introducing parallel
edges to the network (which is supported by MMF) and reduces the size of the
network from 3*|V| to 2*|V|, where |V| is the number of basic blocks in the
function.
**Inference (profile quality) impact:**
The diff is supposed to be a no-op for the inferred counts. However, our
implementation of MCF is not fully deterministic and might return different
results depending on the input network model. Since we changed the model
construction, there are a few differences in comparison to the original
implementation. I checked manually on an internal benchmark and see a minor
difference (+/- 1 count for certain basic blocks) in just a dozen of instances
(out of 10000+ input functions). Hence, the diff is highly unlikely to have an
impact for existing prod workloads.
**Runtime impact:**
I measure up to 10% speedup for block-only (ie CSSPGO/AutoFDO) inference and up
to 50% speedup for block+jump inference (ie BOLT) in comparison to the original
unoptimized version.
Reviewed By: hoy
Differential Revision: https://reviews.llvm.org/D139870
Stanislav Mekhanoshin [Wed, 11 Jan 2023 21:27:11 +0000 (13:27 -0800)]
[AMDGPU] Mark wmma intrinsics as source of divergence
I do not believe any code can hit this, but these do not give
a uniform answer with all unifirm sources.
Differential Revision: https://reviews.llvm.org/D141544
Jez Ng [Wed, 11 Jan 2023 22:13:33 +0000 (17:13 -0500)]
[lld-macho][nfc] Use alignToPowerOf2 instead of alignTo when possible
Skips the divide operation which is generally expensive. Not that it
matters in this diff, the code changed is not particularly hot, but just
for principle & consistency...
Reviewed By: #lld-macho, oontvoo, MaskRay
Differential Revision: https://reviews.llvm.org/D141461
Arthur O'Dwyer [Tue, 10 Jan 2023 18:29:35 +0000 (13:29 -0500)]
[libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit
Releasing the mutex before the call to notify_all is an optimization.
This optimization cannot be used here. The thread waiting on the
condition might destroy the associated resources — mutex + condition
variable — and the notifier thread will access an destroyed variable
— the condition variable. In fact, notify_all_at_thread_exit is meant
exactly to join on detached threads, and the waiting thread doesn't
expect for the notifier thread to access any further shared resources,
making this scenario very likely to happen. The waiting thread might
awake spuriously on the release of the mutex lock. The reorder is
necessary to prevent this race.
Further details can be found at https://cplusplus.github.io/LWG/issue3343.
Differential Revision: https://reviews.llvm.org/D105758
Paul Kirth [Thu, 5 Jan 2023 00:26:36 +0000 (00:26 +0000)]
"Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.
Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a .local suffix to the alias
name just as we do for relative vtables aliases.
This should be safe to land after an incorrect LLD assertion was removed
in https://reviews.llvm.org/rG20894a478da224bdd69c91a22a5175b28bc08ed9
which caused assertion failures in LLD on Mac.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D137982
Hanhan Wang [Fri, 6 Jan 2023 00:54:34 +0000 (16:54 -0800)]
[mlir][tensor] Add patterns that fold ops into pack and unpack ops.
The tensor.pack ops have pad semantic, so we can fold pad + pack into
pack when
1. They have the same padding values or the pack op does not have
padding values.
2. The pad op does not have low paddings.
The tensor.unpack ops have extract_slice semantic, so we can fold unpack
+ extract_slice into unpack when
1. All the offsets are 0s.
2. All the strides are 1s.
Reviewed By: tyb0807
Differential Revision: https://reviews.llvm.org/D141099
Alex Langford [Sat, 17 Dec 2022 00:19:40 +0000 (16:19 -0800)]
[debugserver] Clear memory allocations after exec
After an exec, the inferior is a new process and none of these memory
regions are still allocated. Clear them out.
Differential Revision: https://reviews.llvm.org/D140253
Owen Pan [Wed, 11 Jan 2023 20:15:16 +0000 (12:15 -0800)]
[clang-format][doc] Fix C++ code blocks for IntegerLiteralSeparator
Mitch Phillips [Wed, 11 Jan 2023 20:55:38 +0000 (12:55 -0800)]
[GWP-ASan] Add recoverable mode.
The GWP-ASan recoverable mode allows a process to continue to function
after a GWP-ASan error is detected. The error will continue to be
dumped, but GWP-ASan now has APIs that a signal handler (like the
example optional crash handler) can call in order to allow the
continuation of a process.
When an error occurs with an allocation, the slot used for that
allocation will be permanently disabled. This means that free() of that
pointer is a no-op, and use-after-frees will succeed (writing and
reading the data present in the page).
For heap-buffer-overflow/underflow, the guard page is marked as accessible
and buffer-overflows will succeed (writing and reading the data present
in the now-accessible guard page). This does impact adjacent
allocations, buffer-underflow and buffer-overflows from adjacent
allocations will no longer touch an inaccessible guard page. This could
be improved in future by having two guard pages between each adjacent
allocation, but that's out of scope of this patch.
Each allocation only ever has a single error report generated. It's
whatever came first between invalid-free, double-free, use-after-free or
heap-buffer-overflow, but only one.
Reviewed By: eugenis, fmayer
Differential Revision: https://reviews.llvm.org/D140173
James Y Knight [Wed, 11 Jan 2023 20:53:03 +0000 (15:53 -0500)]
[Libcxx] Add <source_location> header.
This requires the __builtin_source_location() builtin, as implemented
by GCC and Clang.
Fixes https://github.com/llvm/llvm-project/issues/56363
Differential Revision: https://reviews.llvm.org/D120634
Casey Carter [Wed, 11 Jan 2023 01:49:53 +0000 (17:49 -0800)]
[libc++][test] cleanup in formatter.h
* Silence warnings for unused parameters / variables
* There's no reason to output unexpected exceptions only for libc++
Differential Revision: https://reviews.llvm.org/D141453
Markus Böck [Wed, 11 Jan 2023 19:54:56 +0000 (20:54 +0100)]
[llvm] Refactor leftover ThreadLocal usage in MinGW code
This code was accidently left over after https://reviews.llvm.org/D141349 and now leads to compilation failure due to missing declaration (since the class has been removed)
Just migrate it by making use of `LLVM_THREAD_LOCAL` instead.
Differential Revision: https://reviews.llvm.org/D141535
Markus Böck [Tue, 10 Jan 2023 20:27:18 +0000 (21:27 +0100)]
[mlir][NFC] Migrate rest of the dialects to the new fold API
Markus Böck [Tue, 10 Jan 2023 19:33:48 +0000 (20:33 +0100)]
[mlir][MemRef][NFC] Migrate MemRef dialect to the new fold API
See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context
Differential Revision: https://reviews.llvm.org/D141529
Markus Böck [Tue, 10 Jan 2023 19:05:49 +0000 (20:05 +0100)]
[mlir][Index][NFC] Migrate index dialect to the new fold API
See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context
Similar to the patch for the arith dialect, the index dialects fold implementations make heavy use of generic fold functions, hence the change being comparatively mechanical and mostly changing the function signature.
Differential Revision: https://reviews.llvm.org/D141502
Alex Langford [Fri, 16 Dec 2022 22:29:11 +0000 (14:29 -0800)]
[lldb] Do not deallocate memory after exec
After an exec has occured, resources used to manage the state of a
Process are cleaned up. One such resource is the AllocatedMemoryCache
which keeps track of memory allocations made in the process for things
like expression evaluation. After an exec is performed, the allocated
memory regions in the process are gone, so it does not make sense to try
to deallocate those regions.
rdar://
103188106
Differential Revision: https://reviews.llvm.org/D140249
Jeff Niu [Wed, 11 Jan 2023 18:03:10 +0000 (10:03 -0800)]
[mlir][llvm] Add a convenience builder to BrOp
This builder takes no successor arguments.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D141522
Thomas Raoux [Tue, 10 Jan 2023 21:56:15 +0000 (21:56 +0000)]
[mlir]][linalg] Add named op for matmul_transpose_b
matmul where the RHS operand is transposed allows better memory access
patterns on several architectures including common GPUs. Having a named
op for it allows to handle this kind of matmul in a more explicit way.
Differential Revision: https://reviews.llvm.org/D141430
Nikolas Klauser [Wed, 28 Dec 2022 14:10:27 +0000 (15:10 +0100)]
[libc++] Rename transform_view::{__iterator, __sentinel} to __transform_view_{iterator, sentinel}
This makes it a lot easier to specialize traits types, like __segmented_iterator_traits.
Reviewed By: var-const, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D140728
Thurston Dang [Wed, 11 Jan 2023 19:34:34 +0000 (19:34 +0000)]
tsan_shadow_test: add const qualifier
Fix build error in https://lab.llvm.org/buildbot/#/builders/57/builds/23839/steps/7/logs/stdio
that I had introduced in https://reviews.llvm.org/D141445
Differential Revision: https://reviews.llvm.org/D141534
Caroline Tice [Wed, 11 Jan 2023 19:11:25 +0000 (11:11 -0800)]
[Bazel] Fix typo (missing comma) in previous commit.
Commit
b4477dd8c5d1f9b27cc6d8f52106359e4f0afe66,
"[Bazel] Add //llvm:TargetParser depenendency to clang driver for RISCVTargetParserDef.inc",
was missing a comma. This fixes that.
Caroline Tice [Wed, 11 Jan 2023 19:07:08 +0000 (11:07 -0800)]
[Bazel] Add //llvm:TargetParser depenendency to clang driver for RISCVTargetParserDef.inc
Recent update missed this dependency.
Haowei Wu [Wed, 11 Jan 2023 00:56:07 +0000 (16:56 -0800)]
[CMake][Fuchsia] Include llvm-ml in Fuchsia toolchain
This change includes llvm-ml tool in Fuchsia toolchain.
Differential Revision: https://reviews.llvm.org/D141448
Jakub Kuderski [Wed, 11 Jan 2023 18:55:39 +0000 (13:55 -0500)]
[mlir][spirv] Migrate to new fold API
Fixes: https://github.com/llvm/llvm-project/issues/59938
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D141524
Florian Hahn [Wed, 11 Jan 2023 18:52:50 +0000 (18:52 +0000)]
[AArch64] Set MaxInterleaveFactor for Apple A14, A15, A16.
Those CPUs can benefit from additional interleaving.
Reviewed By: jroelofs
Differential Revision: https://reviews.llvm.org/D141499
Ed Maste [Wed, 21 Dec 2022 21:06:02 +0000 (16:06 -0500)]
[libc++] Add FreeBSD exceptions.nonew ABI list
This matches the configuration used by the prospective FreeBSD CI runner.
Remove the (unused) ABI list created in my local environment.
This reverts commit
eca9196dc8826b9455a2cdb57c52d51403cb742c.
Reviewed by: Mordante
Differential Revision: https://reviews.llvm.org/D141496
Aaron Ballman [Wed, 11 Jan 2023 18:26:21 +0000 (13:26 -0500)]
Another round of speculative fixes for Clang sphinx
It seems that changing Format.h is insufficient to get the docs to
rebuild? Changing the .rst file directly to at least see if that gets
the bot back to green finally.
Slava Zakharin [Tue, 10 Jan 2023 18:24:48 +0000 (10:24 -0800)]
[flang] Added coarse grained alias analysis for FIR.
These are experimental changes in Flang AA to provide
at least some means to disambiguate memory accesses in some
simple cases. This AA is still not used by any transformation,
so the LIT tests are the only way to trigger it currently.
I will further look into applying this AA within Flang
to address some of the known performance issues in the benchmarks.
Credits to @Renaud-K for the initial implementation.
Differential Revision: https://reviews.llvm.org/D141410
Thurston Dang [Wed, 11 Jan 2023 00:42:02 +0000 (00:42 +0000)]
tsan: add kBrokenAliasedMetas condition and test
This fills in a gap in the tsan_shadow_test coverage:
it is possible that the meta regions are aliased
(e.g., the heap meta region overlaps the high app meta
region). Indeed, the Aarch64_39 mapping has been
silently broken in this way for quite some time.
This CL checks whether the individual meta regions
(for low/mid/high/heap) overlap. Note that
(!kBrokenAliasedMetas && !kBrokenLinearity) implies
that MemToMeta is invertible; we cannot directly
test MetaToMem because that function does not exist.
Differential Revision: https://reviews.llvm.org/D141445
Aaron Ballman [Wed, 11 Jan 2023 18:09:16 +0000 (13:09 -0500)]
Speculatively fix the Clang sphinx build
This is another attempt at getting the Sphinx build back to green. It
seems Sphinx on the build server does not like any of these, likely due
to the digit separators.
Craig Topper [Wed, 11 Jan 2023 17:38:41 +0000 (09:38 -0800)]
[RISCV] Remove uses of Register::isPhysicalRegister/isVirtualRegister. NFC
Use isPhysical/isVirtual methods.
Jay Foad [Tue, 10 Jan 2023 13:24:40 +0000 (13:24 +0000)]
[AMDGPU] Temporarily disable FeatureBackOffBarrier for GFX11
Enabling this feature exposed some incorrect codegen, where a workgroup-
scope barrier fails to properly synchronise two waves from the same
workgroup running on different SIMDs of the same CU.
Disabling FeatureBackOffBarrier causes an s_waitcnt to be emitted before
the barrier which works around the problem.
Differential Revision: https://reviews.llvm.org/D141379
Florian Hahn [Wed, 11 Jan 2023 17:26:12 +0000 (17:26 +0000)]
[LoopUnroll] Add additional DT verification test for D141487.
Terry Wilmarth [Tue, 13 Dec 2022 18:54:24 +0000 (12:54 -0600)]
[OpenMP] Fix for smaller team sizes inside teams construct.
When a team nested inside a teams construct is allocated, it is
allocated to a size specified by the teams thread_limit. In the case
where any mechanism that might not grant the full thread_limit is in
use, we may get a smaller team. This possibility was not reflected in
the code when using the th_teams_size.nth value stored on the master
thread for the team. This value was never updated even when t_nproc on
the team itself was different. I added a line to update it shortly
before the team is forked.
Added a simple teams test that uses KMP_DYNAMIC_MODE=random to mimic
allocating teams with sizes <= thread_limit. Eventually, this
will segfault without the fix in this commit.
Differential Revision: https://reviews.llvm.org/D139960
Nico Weber [Wed, 11 Jan 2023 17:18:36 +0000 (12:18 -0500)]
[gn build] Port
ac1ffd3caca1
Markus Böck [Tue, 10 Jan 2023 18:52:56 +0000 (19:52 +0100)]
[mlir][math][NFC] Migrate math dialect to the new fold API
See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context
Similar to the patch for the arith dialect, the math dialects fold implementations make heavy use of generic fold functions, hence the change being comparatively mechanical and mostly changing the function signature.
Differential Revision: https://reviews.llvm.org/D141500
Joseph Huber [Wed, 11 Jan 2023 17:05:01 +0000 (11:05 -0600)]
[OpenMP] Fix unused capature and name
Summary:
This capture isn't used, get rid of it and change the name since it's
more generic now.
Sam McCall [Wed, 11 Jan 2023 17:03:58 +0000 (18:03 +0100)]
[clangd] Respect clang-tidy SystemHeaders option if specified
(Previous commit assumed it was always off, which is the default)
Joseph Huber [Wed, 11 Jan 2023 17:02:36 +0000 (11:02 -0600)]
[Clang] Add requires flags to test using Linux command line
Summary:
This test uses command line tools but I forgot to add the requires
clauses. Fix it.
bixia1 [Tue, 10 Jan 2023 20:33:10 +0000 (12:33 -0800)]
[mlir][sparse] Generate AOS subviews on-demand.
Previously, we generate AOS subviews for indices buffers when constructing an
immutable sparse tensor descriptor. We now only generate such subviews when
getIdxMemRefOrView is requested.
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D141325
Siu Chi Chan [Wed, 11 Jan 2023 16:48:20 +0000 (11:48 -0500)]
[AMDGCN] Update search path for device libraries
- Add support for finding device libraries in new ROCm directory
structure
- Simplify and remove the handling of legacy ROCm directory structure
Change-Id: I04da3bc9da85ced4b56b0225efb6b94448b8c5a1
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D140315
Guillaume Chatelet [Wed, 11 Jan 2023 16:48:35 +0000 (16:48 +0000)]
[NFC] Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
David Green [Wed, 11 Jan 2023 16:49:20 +0000 (16:49 +0000)]
[ARM] Limit and+csinc fold to a single use.
With glue nodes between the CMP and the CSINC, generating multiple
uses of the CMP can fail when scheduling the DAG. This limits the fold
from
90f24bef47227d58f2ccd to a single use on the CSINC, to prevent the
CMP being needed by two nodes.
Mark de Wever [Sun, 1 Jan 2023 16:17:47 +0000 (17:17 +0100)]
[libc++][format] Fixes escaping string literals.
D140653 has the same fix, without the extra tests.
Fixes PR59763
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D140819
OCHyams [Wed, 11 Jan 2023 15:51:32 +0000 (15:51 +0000)]
[Assignment Tracking] Do not verify against an empty metadata address operand
This copies existing behaviour from other debug intrinsics to `dbg.assign`s.
Reviewed By: scott.linder
Differential Revision: https://reviews.llvm.org/D141140
Guillaume Chatelet [Wed, 11 Jan 2023 16:34:43 +0000 (16:34 +0000)]
[NFC] Use TypeSize::getKnownMinValue() instead of TypeSize::getKnownMinSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
Joseph Huber [Tue, 10 Jan 2023 22:47:50 +0000 (16:47 -0600)]
[OpenMP] Adjust phases for AMDGPU offloading for OpenMP in save-temps mode
Currently, the behaviour of `-save-temps` changes the generated output
when offloading to AMDGPU. This is because we only have a single phase
and it contains the `-disable-llvm-passes` flags which results in
unoptimized bitcode. We need to make sure we generate another phase that
produces both the optimized and unoptimized bitcode. There used to be a
check that turned these phases into a no-op. But I believe it is more
correct to not generate them this way in the first place. Doing this
requires a bit of a hack, replacing an already generated phase action,
but it should be fine.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D141440
Joseph Huber [Fri, 6 Jan 2023 03:01:26 +0000 (21:01 -0600)]
[OpenMP] Add support for '--offload-arch=native' to OpenMP offloading
This patch adds support for '--offload-arch=native' to OpenMP
offloading. This will automatically generate the toolchains required to
fulfil whatever GPUs the user has installed. Getting this to work
requires a bit of a hack. The problem is that we need the ToolChain to
launch its searching program. But we do not yet have that ToolChain
built. I had to temporarily make the ToolChain and also add some logic
to ignore regular warnings & errors.
Depends on D141078
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D141105
Joseph Huber [Thu, 5 Jan 2023 18:42:41 +0000 (12:42 -0600)]
[CUDA][HIP] Support '--offload-arch=native' for the new driver
This patch applies the same handling for the `--offload-arch=native'
string to the new driver. The support for OpenMP will require some extra
logic to infer the triples from the derived architecture strings.
Depends on D141051
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D141078
Joseph Huber [Thu, 5 Jan 2023 04:18:41 +0000 (22:18 -0600)]
[CUDA][HIP] Add support for `--offload-arch=native` to CUDA and refactor
This patch adds basic support for `--offload-arch=native` to CUDA. This
is done using the `nvptx-arch` tool that was introduced previously. Some
of the logic for handling executing these tools was factored into a
common helper as well. This patch does not add support for OpenMP or the
"new" driver. That will be done later.
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D141051
Guillaume Chatelet [Wed, 11 Jan 2023 16:25:52 +0000 (16:25 +0000)]
[NFC] Use TypeSize::getKnownMinValue() instead of TypeSize::getKnownMinSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
bixia1 [Tue, 10 Jan 2023 17:49:24 +0000 (09:49 -0800)]
[mlir][sparse] Improve the rewriting for dense-to-sparse conversion.
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D141335
Anshil Gandhi [Wed, 11 Jan 2023 15:59:21 +0000 (16:59 +0100)]
[InstCombine] Handle PHI nodes in isOnlyCopiedFromConstantMemory()
As long as the memcpy occurs on a phi input (rather than the phi
output), we can look through phi nodes in
isOnlyCopiedFromConstantMemory().
This is split out of D136201, to only handle the case where the
address spaces are the same, and no pointer rewrite is necessary.
Guillaume Chatelet [Wed, 11 Jan 2023 16:17:21 +0000 (16:17 +0000)]
[mlir][NFC] Use TypeSize::getFixedValue() instead of TypeSize::getFixedSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
Nikita Popov [Wed, 11 Jan 2023 16:17:46 +0000 (17:17 +0100)]
[InstCombine] Limit use walk in copied from constant fold
This fold currently performs an unbounded recursive use walk.
Make sure that we don't visit too many instructions (the limit is
chosen arbitrarily).
This is with an eye on also handling phi nodes, which will further
extend the considered use graph.
Nikita Popov [Wed, 11 Jan 2023 16:10:51 +0000 (17:10 +0100)]
[InstCombine] Add Visited set to isOnlyCopiedFromConstantMemory()
I don't think this matters right now (because InstCombine cleans
up unreachable code early), but this will help to make sure that
we don't infinite loop once we handle phi nodes. The added test
is an example where this would happen.
Matt Arsenault [Wed, 11 Jan 2023 14:57:21 +0000 (09:57 -0500)]
Revert "llvm-reduce: Try to kill parallel workitems once we have a result."
This reverts commit
4f575620d51032cf98424c9defafe4dfc8d66f45.
I realized the test wasn't very good and when fixed, shows the
reduction doesn't work correctly. Revert the change and keep the fixed
version of the test.
Guillaume Chatelet [Wed, 11 Jan 2023 15:54:34 +0000 (15:54 +0000)]
[clang][NFC] Use the TypeSize::getXXXValue() instead of TypeSize::getXXXSize)
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
David Green [Wed, 11 Jan 2023 15:58:38 +0000 (15:58 +0000)]
[ARM] Don't treat arguments as producesFalseLanesZero
Invalid tail predicated loops could be formed by treating function
arguments as FalseLanesZero due to getGlobalReachingDefs not returning
any values. Make sure we check that the list of Defs is empty and if so
treat it like a unknown value.
Differential Revision: https://reviews.llvm.org/D141399
OCHyams [Wed, 11 Jan 2023 15:38:01 +0000 (15:38 +0000)]
[Assignment Tracking][Docs] Add new metadata to LangRef.rst
And link to the AssignmentTracking.md document which goes into more detail.
Reviewed By: jryans
Differential Revision: https://reviews.llvm.org/D141131
Anshil Gandhi [Wed, 11 Jan 2023 15:43:55 +0000 (16:43 +0100)]
[InstCombine] Add tests for alloca removal with phi nodes (NFC)
Tests for D136201.
Markus Böck [Wed, 11 Jan 2023 15:13:14 +0000 (16:13 +0100)]
[flang][NFC] Enable and migrate to new fold API
See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context
This simply ports all dialects in flang to use the new fold API. These were relatively little and basically just a function signature change, since in-tree folds did not make use of any of the constant operands values.
Differential Revision: https://reviews.llvm.org/D141488
Louis Dionne [Wed, 11 Jan 2023 15:30:33 +0000 (10:30 -0500)]
[libc++][NFC] Improve consistency in status csv files
Philip Reames [Wed, 11 Jan 2023 15:18:11 +0000 (07:18 -0800)]
[CodeGen] Introduce a generic MEMBARRIER instruction [mostly-nfc]
This is a follow up to D141317 which extends the common code to include a target independent pseudo instruction. This is an alternative to (subset of) D92842 which tries to be as close to NFC as possible.
A couple things to call out.
* The test change in X86 is because we loose the scheduling information on the instruction. However, I think this was actually a bug in x86 since no instruction was emitted for a MEMBARRIER. Concluding that a meta instruction has latency just seems wrong?
* I intentionally left some parts of D92842 out. Specifically, several of the changes in the X86 code (data independence and outlining) appear functional, and likely worthy of their own review. Additionally, I'm not handling ARM/AArch64 at all. Those targets need the ordering whereas none of the others do. I want to get this in and tested before retrofitting in ordering to support those targets.
Differential Revision: https://reviews.llvm.org/D141408
Markus Böck [Tue, 10 Jan 2023 18:49:08 +0000 (19:49 +0100)]
[mlir][Arith][NFC] Migrate Arith dialect to the new fold API
This is the dialect in-tree with the most `fold` method implementations by far. This patch simply changes all implementations to make use of the new signature.
Admittedly, the code readability does not get a lot better in this case, simply due to most methods making use of `constFoldBinaryOp`. I did not modify that function or its interface as part of this patch, but might be something to consider in the future.
Differential Revision: https://reviews.llvm.org/D141490
Markus Böck [Tue, 10 Jan 2023 18:03:12 +0000 (19:03 +0100)]
[mlir][NFC] Switch dialects with no fold methods to the new fold API
These are the trivial cases which do not require any other code changes.
Changing the default might not have any semantic changes but at least guarantees that no new fold methods may be added to these dialects while migrating.
This commit is also revertible at the end of the migration
Differential Revision: https://reviews.llvm.org/D141489
Louis Dionne [Wed, 10 Aug 2022 21:27:00 +0000 (17:27 -0400)]
[libc++] Improve the implementation of std::unreachable
First, use __builtin_unreachable unconditionally. It is implemented by
all the compilers that we support. Clang started supporting it around
Clang 4, and GCC around GCC 4.10.
Also add _LIBCPP_ASSERT so that we will actually get a guaranteed crash
if we reached `std::unreachable()` and assertions have been enabled,
since that's UB that's extremely easy to catch.
Differential Revision: https://reviews.llvm.org/D131620
Sam McCall [Wed, 11 Jan 2023 14:46:03 +0000 (15:46 +0100)]
[clangd] Suppress clang-tidy warnings for code spelled in system macros
This aligns with the default behavior of clang-tidy (which we offer no
way to override).
Fixes https://github.com/clangd/clangd/issues/1448
Differential Revision: https://reviews.llvm.org/D141495
Florian Hahn [Tue, 10 Jan 2023 13:19:00 +0000 (13:19 +0000)]
[AArch64] Add tests for selecting interleave counts for different CPUs.
Add extra tests for interleaving heuristics for different AArch64 CPUs.
NAKAMURA Takumi [Wed, 11 Jan 2023 14:15:20 +0000 (23:15 +0900)]
[Bazel] Enable LoongArch by default, corresponding to llvmorg-16-init-16825-g85865f965d57
NAKAMURA Takumi [Wed, 11 Jan 2023 14:13:45 +0000 (23:13 +0900)]
[Bazel] Create LoongArch target.
Peixin Qiao [Wed, 11 Jan 2023 14:35:13 +0000 (22:35 +0800)]
[flang] Support lowering of IS_CONTIGUOUS
This supports the lowering of intrinsic IS_CONTIGUOUS for array argument.
The argument of assumed rank is not supported since it is not implemented
yet as the procedure argument. Add TODO for it.
Reviewed By: PeteSteinfeld, jeanPerier
Differential Revision: https://reviews.llvm.org/D141212
Simon Pilgrim [Wed, 11 Jan 2023 14:19:23 +0000 (14:19 +0000)]
[X86] combinePredicateReduction - ensure non-i8 scalar type is a multiple of 8 bits
For the "all_of(setcc(x,y,eq)) -> PMOVMSKB(PCMPEQB())" fold, we failed to ensure that we could safely bitcast to <X x i8>, which in particular failed with boolean types
Thanks to @lerno for catching this and providing the test case
Paul Walker [Wed, 4 Jan 2023 11:45:54 +0000 (11:45 +0000)]
[IRBuilder] Use canonical i64 type for insertelement index used by vector splats.
Instcombine prefers this canonical form (see getPreferredVectorIndex),
as does IRBuilder when passing the index as an integer so we may as
well use the prefered form from creation.
NOTE: All test changes are mechanical with nothing else expected
beyond a change of index type from i32 to i64.
Differential Revision: https://reviews.llvm.org/D140983
NAKAMURA Takumi [Wed, 11 Jan 2023 13:54:58 +0000 (22:54 +0900)]
[Bazel] Update `//llvm:TargetParser` for `RISCVTargetParserDef.inc`
It has been introduced since llvmorg-16-init-16838-gac1ffd3caca1
Dinar Temirbulatov [Wed, 11 Jan 2023 14:06:01 +0000 (14:06 +0000)]
[AArch64][SVE] Avoid AND operation if both side are splat of i1 or PTRUE
If both sides of AND operations are i1 splat_vectors or PTRUE node then we can
produce just i1 splat_vector as the result.
Differential Revision: https://reviews.llvm.org/D141043
Nikita Popov [Wed, 11 Jan 2023 14:04:17 +0000 (15:04 +0100)]
[GVNHoist] Convert test to opaque pointers (NFC)
Adjust the GEPs to be non-trivial, to preserve test intent.
Nikita Popov [Wed, 11 Jan 2023 13:38:08 +0000 (14:38 +0100)]
[Attributor] Convert some tests to opaque pointers (NFC)
Check lines were regenerated for these.
The alignment changes in byval-2. look suspicious at first glance,
but actually only propagate pre-existing UB.
Matt Arsenault [Tue, 29 Nov 2022 21:22:16 +0000 (16:22 -0500)]
llvm-reduce: Try to kill parallel workitems once we have a result.
The current reduction logic tries to reproduce what a serial reduction
would produce, and just takes the first one that is still
interesting. We still have to wait for all others to complete though,
which at that point is just a waste.
This helps speed things up with long running reducers, which I
frequently have. e.g. for the added sleep test on my system, it took
about 8 seconds before this change and about 4 after.
https://reviews.llvm.org/D138953
Sam McCall [Wed, 11 Jan 2023 11:05:59 +0000 (12:05 +0100)]
[include-cleaner] Improve header spelling in the presence of links
HeaderSearch uses FileEntry::getName() to determine the best spelling of a
header. FileEntry::getName() is now the name of the *last* retrieved ref.
This means that when FileManager::getFile() hits an existing inode through a new
path, it changes the spelling of that header.
In the absence of explicit logic to track the preferred name(s) of header files,
we should avoid gratuitously calling getFile() with paths different than how
the header was originally included, such as the result of realpath().
The originally-specified path should be fine here:
- if the same filemanager is being used for record/analysis, we'll hit the
filename cache
- if a different filemanager is being used e.g. preamble scenario, we should
get the same result unless either the working directory has changed (which it
shouldn't, else many other things will fail) or the file has gone/changed
inode (in which case the old method doesn't work either)
Needless to say this is fragile, but talking to @kadircet offline, it's good
enough for our purposes for now.
Differential Revision: https://reviews.llvm.org/D141478
Nikita Popov [Wed, 11 Jan 2023 13:36:22 +0000 (14:36 +0100)]
[CodeExtractor] Convert tests to opaque pointers (NFC)
Keeping bitcasts to preserve test behavior.
Markus Böck [Sun, 25 Dec 2022 18:29:31 +0000 (19:29 +0100)]
[mlir] Add a new fold API using Generic Adaptors
This is part of the RFC for a better fold API: https://discourse.llvm.org/t/rfc-a-better-fold-api-using-more-generic-adaptors/67374
This patch implements the required foldHook changes and the TableGen machinery for generating `fold` method signatures using `FoldAdaptor` for ops, based on the value of `useFoldAPI` of the dialect. It may be one of 2 values, with convenient named constants to create a quasi enum. The new `fold` method will then be generated if `kEmitFoldAdaptorFolder` is used.
Since the new `FoldAdaptor` approach is strictly better than the old signature, part of this patch updates the documentation and all example to encourage use of the new `fold` signature.
Included are also tests exercising the new API, ensuring proper construction of the `FoldAdaptor` and proper generation by TableGen.
Differential Revision: https://reviews.llvm.org/D140886
Markus Böck [Sun, 25 Dec 2022 14:07:49 +0000 (15:07 +0100)]
[mlir][tblgen] Generate generic adaptors for Ops
This is part of the RFC for a better fold API: https://discourse.llvm.org/t/rfc-a-better-fold-api-using-more-generic-adaptors/67374
This patch implements the generation of generic adaptors through TableGen. These are essentially a generalization of Adaptors, as implemented previously, but instead of indexing into a `mlir::ValueRange`, they may index into any container, regardless of the element type. This allows the use of the convenient getter methods of Adaptors to be reused on ranges that are the result of some kind of mapping functions of an ops operands.
In the case of the fold API in the RFC, this would be `ArrayRef<Attribute>`, which is a mapping of the operands to their possibly-constant values.
Implementation wise, some special care was taken to not cause a compile time regression, nor to break any kind of source compatibility.
For that purpose, the current adaptor class was split into three:
* A generic adaptor base class, within the detail namespace as it is an implementation detail, which implements all APIs independent of the range type used for the operands. This is all the attribute and region related code. Since it is not templated, its implementation does not have to be inline and can be put into the cpp source file
* The actual generic adaptor, which has a template parameter for the range that should be indexed into for retrieving operands. It implements all the getters for operands, as they are dependent on the range type. It publicly inherits from the generic adaptor base class
* A class named as adaptors have been named so far, inheriting from the generic adaptor class with `mlir::ValueRange` as range to index into. It implements the rest of the API, specific to `mlir::ValueRange` adaptors, which have previously been part of the adaptor. This boils down to a constructor from the Op type as well as the verify function.
The last class having the exact same API surface and name as Adaptors did previously leads to full source compatibility.
Differential Revision: https://reviews.llvm.org/D140660
Nikita Popov [Wed, 11 Jan 2023 13:27:05 +0000 (14:27 +0100)]
[GVNHoist] Regenerate test checks (NFC)
Thomas Symalla [Wed, 11 Jan 2023 13:23:41 +0000 (14:23 +0100)]
[NFC][AMDGPU] Pre-commit BFI test.
Jay Foad [Wed, 11 Jan 2023 13:16:34 +0000 (13:16 +0000)]
[AMDGPU] Use MCInstrDesc::getSize. NFC.
Nikita Popov [Wed, 11 Jan 2023 13:12:23 +0000 (14:12 +0100)]
[GVN] Convert tests to opaque pointers (NFC)
wanglei [Wed, 11 Jan 2023 13:16:38 +0000 (21:16 +0800)]
[LoongArch] Fix undefined behavior: left shift of negative value
Fix undefined behavior in `decodeSImmOperand` where we were left shifting
a signed value.