Nikita Popov [Tue, 1 Feb 2022 09:42:34 +0000 (10:42 +0100)]
[ArgPromotion] Add alignment test (NFC)
This shows a miscompile in the current argpromotion implementation:
We may speculatively execute overaligned loads.
Jay Foad [Mon, 31 Jan 2022 16:56:32 +0000 (16:56 +0000)]
[StructurizeCFG] Clean up some boolean not instructions
In some cases StructurizeCFG inserts i1 xor instructions to invert
predicates. Add a quick loop to clean these up afterwards if we can get
away with modifying an existing compare instruction instead.
(StructurizeCFG is generally run late in the pipeline so instcombine
does not clean them up for us.)
Differential Revision: https://reviews.llvm.org/D118623
Nikita Popov [Tue, 1 Feb 2022 09:34:02 +0000 (10:34 +0100)]
[ArgPromotion] Regenerate test checks (NFC)
Nikita Popov [Tue, 1 Feb 2022 09:32:58 +0000 (10:32 +0100)]
[ArgPromotion] Use range-based for loop (NFC)
David Green [Tue, 1 Feb 2022 09:21:49 +0000 (09:21 +0000)]
[LV][AArch64] Add test for scalar interleaving with predication. NFC
Siva Chandra [Tue, 1 Feb 2022 06:17:44 +0000 (22:17 -0800)]
[libc] Add a few missing deps, includes, and fix a few typos.
This allows us to enable rmdir, mkdir, mkdirat, unlink and unlinkat for
aarch64.
Johannes Doerfert [Tue, 1 Feb 2022 08:23:55 +0000 (02:23 -0600)]
[Attributor][FIX] Relax assertion in IRPosition::verify
A call base can be a floating value if we talk about the instruction and
not the return value. This distinction was not made before but is
important for liveness, e.g., a call site return value might be unused
(=dead) but the call site is not.
Markus Lavin [Tue, 1 Feb 2022 08:16:50 +0000 (09:16 +0100)]
[llvm-reduce] Set ShouldPreserveUseListOrder=true
When exporting textual IR during reduction the ShouldPreserveUseListOrder
parameter of the IR printer should be set to get predictable results.
Differential Revision: https://reviews.llvm.org/D118585
Johannes Doerfert [Tue, 1 Feb 2022 08:18:02 +0000 (02:18 -0600)]
[UpdateTestChecks][FIX] Expected output changed with Attributor
Marek Kurdej [Tue, 1 Feb 2022 08:05:26 +0000 (09:05 +0100)]
[clang-format] Fix AlignConsecutiveAssignments breaking lambda formatting.
Fixes https://github.com/llvm/llvm-project/issues/52772.
This patch fixes the formatting of the code:
```
auto
aaaaaaaaaaaaaaaaaaaaa = {};
auto b = g([] {
return;
});
```
which should be left as is, but before this patch was formatted to:
```
auto
aaaaaaaaaaaaaaaaaaaaa = {};
auto b = g([] {
return;
});
```
Reviewed By: MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D115972
Fangrui Song [Tue, 1 Feb 2022 08:16:42 +0000 (00:16 -0800)]
[ELF] Change vector<Symbol *> to SmallVector. NFC
Siva Chandra Reddy [Tue, 1 Feb 2022 08:13:43 +0000 (08:13 +0000)]
[libc] Adjust few fcntl macros for aarch64.
Fangrui Song [Tue, 1 Feb 2022 08:14:21 +0000 (00:14 -0800)]
[ELF] Change vector<InputSection *> to SmallVector. NFC
My x86-64 lld executable is 8KiB smaller.
Johannes Doerfert [Tue, 1 Feb 2022 08:13:01 +0000 (02:13 -0600)]
[Attributor][FIX] Repair broken unit test
Fangrui Song [Tue, 1 Feb 2022 08:09:30 +0000 (00:09 -0800)]
[ELF] Switch split-stack to use SmallVector. NFC
My x86-64 lld executable is 1.1KiB smaller.
Marek Kurdej [Mon, 31 Jan 2022 17:39:00 +0000 (18:39 +0100)]
[clang-format] Don't break block comments when sorting includes.
Fixes https://github.com/llvm/llvm-project/issues/34626.
Before, the include sorter would break the code:
```
#include <stdio.h>
#include <stdint.h> /* long
comment */
```
and change it into:
```
#include <stdint.h> /* long
#include <stdio.h>
comment */
```
This commit handles only the most basic case of a single block comment on an include line, but does not try to handle all the possible edge cases with multiple comments.
Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D118627
Johannes Doerfert [Mon, 31 Jan 2022 22:45:17 +0000 (16:45 -0600)]
[Attributor] Introduce the `AA::isPotentiallyReachable` helper APIs
To make usage easier (compared to the many reachability related AAs),
this patch introduces a helper API, `AA::isPotentiallyReachable`, which
performs all the necessary steps. It also does the "backwards"
reachability (see D106720) as that simplifies the AA a lot (backwards
queries were somewhat different from the other query resolvers), and
ensures we use cached values in every stage.
To test inter-procedural reachability in a reasonable way this patch
includes an extension to `AAPointerInfo::forallInterferingWrites`.
Basically, we can exclude writes if they cannot reach a load "during the
lifetime" of the allocation. That is, we need to go up the call graph to
determine reachability until we can determine the allocation would be
dead in the caller. This leads to new constant propagations (through
memory) in `value-simplify-pointer-info-gpu.ll`.
Note: The new code contains plenty debug output to determine how
reachability queries are resolved.
Parts extracted from D110078.
Differential Revision: https://reviews.llvm.org/D118673
Johannes Doerfert [Mon, 31 Jan 2022 20:16:43 +0000 (14:16 -0600)]
[Attributor] Introduce the concept of query AAs
D106720 introduced features that did not work properly as we could add
new queries after a fixpoint was reached and which could not be answered
by the information gathered up to the fixpoint alone.
As an alternative to D110078, which forced eager computation where we
want to continue to be lazy, this patch fixes the problem.
QueryAAs are AAs that allow lazy queries during their lifetime. They are
never fixed if they have no outstanding dependences and always run as
part of the updates in an iteration. To determine if we are done, all
query AAs are asked if they received new queries, if not, we only need
to consider updated AAs, as before. If new queries are present we go for
another iteration.
Differential Revision: https://reviews.llvm.org/D118669
Johannes Doerfert [Tue, 1 Feb 2022 01:16:45 +0000 (19:16 -0600)]
[Attributor] Pre-commit test case
This test shows how we can use alloca position and kernel+AS information
to improve reachability queries and consequently store-load forwarding.
The thirst argument passed to the @use function can be determined
statically (a constant). The others cannot and are there for
verification.
Kuter Dinel [Mon, 31 Jan 2022 20:29:09 +0000 (14:29 -0600)]
[Attributor] AAFunctionReachability, Instruction reachability.
This patch implement instruction reachability for AAFunctionReachability
attribute. It is used to tell if a certain instruction can reach a function
transitively.
NOTE: I created a new commit based of D106720 and set the author back to
Kuter. Other metadata, etc. is wrong. I also addressed the
remaining review comments and fixed the unit test.
Differential Revision: https://reviews.llvm.org/D106720
Johannes Doerfert [Mon, 20 Sep 2021 19:41:52 +0000 (14:41 -0500)]
[Attributor] Use AAFunctionReachability to determine AANoRecurse
We missed out on AANoRecurse in the module pass because we had no call
graph. With AAFunctionReachability we can simply ask if the function may
reach itself.
Differential Revision: https://reviews.llvm.org/D110099
Johannes Doerfert [Sun, 30 Jan 2022 22:40:34 +0000 (16:40 -0600)]
[Attributor] Make interprocedural value explicit in genericValueTraversal
genericValueTraversal can look through arguments and allow value
simplification across function boundaries. In fact, the latter already
happened unchecked. With this change we allow the user of
genericValueTraversal to opt-out of interprocedural traversal if
required. We explicitly look through arguments now which helps to do
various things, incl. the propagation of constants into OpenMP parallel
regions (on the host).
Christian Sigg [Tue, 1 Feb 2022 06:15:35 +0000 (07:15 +0100)]
[MLIR][arith] Mark addf/mulf as commutative
Following the discussion in D118318, mark `arith.addf/mulf` commutative.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D118600
Mogball [Tue, 1 Feb 2022 06:58:02 +0000 (06:58 +0000)]
[mlir][ods] Unify Attr/TypeDef and Operation Format Parsing
Part 2 of 3 of unifying the assembly formats of attributes/types and operations.The last patch that introduced attribute/type formats (D111594) factored out the format lexer entirely. This patch factors out most of the format parsers such that the attribute/type and op parsers only need to implement handling for specific elements.
Certain things could be factored better (element verification, 'seen' variables) but the primary goal of factoring is so that features can be used across both assembly formats.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D117971
Johannes Doerfert [Tue, 1 Feb 2022 02:23:18 +0000 (20:23 -0600)]
[Attributor][FIX] Liveness handling in the isAssumedDead helpers
This fixes a conceptual problem with our AAIsDead usage which conflated
call site liveness with call site return value liveness. Without the
fix tests would obviously miscompile as we make genericValueTraversal
more powerful (in a follow up). The effects on the tests are mixed but
mostly marginal. The most prominent one is the lack of `noreturn` for
functions. The reason is that we make entire blocks live at the same
time (for time reasons). Now that we actually look at the block
liveness, which we need to do, the return instructions are live and
will survive. As an example, `noreturn_async.ll` has been modified
to retain the `noreturn` even with block granularity. We could address
this easily but there is little need in practice.
Johannes Doerfert [Mon, 31 Jan 2022 13:55:11 +0000 (07:55 -0600)]
[Attributor] Use edge liveness rather than block liveness
We moved to the edge API a while back, not all uses were adjusted.
Edge liveness is more precise.
Johannes Doerfert [Mon, 31 Jan 2022 13:53:31 +0000 (07:53 -0600)]
[Attributor][FIX] Address two oversights in AAIsDead
No tests as these were found browsing the code and I'm not sure how to
test them properly.
Johannes Doerfert [Mon, 31 Jan 2022 13:52:19 +0000 (07:52 -0600)]
[Attributor][NFCI] Improve debug diagnostic
Johannes Doerfert [Sun, 30 Jan 2022 21:51:14 +0000 (15:51 -0600)]
[Attributor] Provide convenient helpers for isAssumedRead{None,Only}
We have two attributes that can answer readnone queries. While there is
a dependence between them, it seems best to not force the users to know
what AA to ask. The helpers also allow to check for readonly nicely.
Test changes show where we now deduce readnone but haven't before,
mostly because we only asked AAMemoryBehavior and not AAMemoryLocation.
AANoAlias has not been ported to the new API yet.
Johannes Doerfert [Sat, 17 Jul 2021 06:54:43 +0000 (01:54 -0500)]
[Attributor] Use CFG reasoning to filter potentially interfering writes
Since D104432 we can look through memory by analyzing all writes that
might interfere with a load. This patch provides some logic to exclude
writes that cannot interfere with a location, due to CFG reasoning.
We make sure to avoid multi-thread write-read situations properly while
we ignore writes that cannot reach a load or writes that will be
overwritten before the load is reached.
Differential Revision: https://reviews.llvm.org/D106397
Johannes Doerfert [Sun, 30 Jan 2022 21:21:27 +0000 (15:21 -0600)]
[Attributor][NFC] Make debug output more useful and concise
Johannes Doerfert [Wed, 26 Jan 2022 21:53:39 +0000 (15:53 -0600)]
[OpenMP][FIX] Explicit barriers in SPMD mode are not aligned
Due to num_threads (probably also other reasons) we cannot assume
explicit barriers are always executed by all threads in an aligned
fashion. We can optimize them if that property can be proven but
that is different.
Johannes Doerfert [Sun, 23 Jan 2022 20:06:22 +0000 (14:06 -0600)]
[Attributor][NFCI] Expose some nosync reasoning to outside users.
No-sync is a property that we need in more places as complex
transformations emerge. To simplify the query we provide an
`AA::isNoSyncInst` helper now and expose two existing helpers through
the `AANoSync` class.
Johannes Doerfert [Sun, 23 Jan 2022 20:08:06 +0000 (14:08 -0600)]
[Attributor][NFCI] Remove anonymous namespaces
The namespaces made it more complicate to implement static helpers,
among other things. We should not need them at all.
Johannes Doerfert [Sat, 22 Jan 2022 22:24:52 +0000 (16:24 -0600)]
[OpenMP] Eliminate redundant barriers in the same block
Patch originally by Giorgis Georgakoudis (@ggeorgakoudis), typos and
bugs introduced later by me.
This patch allows us to remove redundant barriers if they are part
of a "consecutive" pair of barriers in a basic block with no impacted
memory effect (read or write) in-between them. Memory accesses to
local (=thread private) or constant memory are allowed to appear.
Technically we could also allow any other memory that is not used to
share information between threads, e.g., the result of a malloc that
is also not captured. However, it will be easier to do more reasoning
once the code is put into an AA. That will also allow us to look through
phis/selects reasonably. At that point we should also deal with calls,
barriers in different blocks, and other complexities.
Differential Revision: https://reviews.llvm.org/D118002
Johannes Doerfert [Fri, 21 Jan 2022 21:47:56 +0000 (15:47 -0600)]
[OpenMP] Ensure to remove noinline from all runtime functions eventually
We used to remove noinline from known OpenMP runtime functions (which
are declared in OMPKinds.td). Now we remove noinline from all functions
with the proper prefixes: __kmpc, _ZN4_OMP (= namespace omp), omp_
Amir Ayupov [Mon, 31 Jan 2022 06:02:51 +0000 (22:02 -0800)]
[BOLT][CMAKE] Add extra BOLT_INCLUDE_TESTS condition for merge-fdata emit-relocs option
Only enable --emit-relocs linker option for merge-fdata target if tests are enabled.
Reviewed By: maksfb
Differential Revision: https://reviews.llvm.org/D118580
Siva Chandra Reddy [Mon, 31 Jan 2022 17:32:07 +0000 (17:32 +0000)]
[libc] Add implementations of POSIX mkdir, mkdirat, rmdir, unlink and unlinkat.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D118641
Jez Ng [Tue, 1 Feb 2022 04:45:19 +0000 (23:45 -0500)]
[lld-macho][test] Add test for UUID format
Reviewed By: keith
Differential Revision: https://reviews.llvm.org/D118646
Serguei Katkov [Thu, 27 Jan 2022 05:21:09 +0000 (12:21 +0700)]
[RS4GC] Make PointerToBase mapping be independent on call site. NFC.
PointerToBase is a mapping between potentially derived pointer to its base.
As soon as we are in SSA form if there is a base of derived pointer and it
is available at def of derived pointer, the same base will be available at any
point where derived pointer is alive.
So the mapping of derived pointer to base pointer is not a property
of a call site but the same on function level.
Reviewers: reames, yrouban
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D118604
Joseph Huber [Tue, 1 Feb 2022 04:32:33 +0000 (23:32 -0500)]
[OpenMP] Remove new driver tests for AMDGPU
Some of the new driver tests are flaky on AMDGPU, remove for now.
Joseph Huber [Mon, 31 Jan 2022 19:31:54 +0000 (14:31 -0500)]
[Libomptarget] Run GPU offloading tests using the new drvier
This patch adds a new target to the tests to run using the new driver as
the method for generating offloading code.
Depends on D116541
Differential Revision: https://reviews.llvm.org/D118637
Joseph Huber [Fri, 21 Jan 2022 20:43:20 +0000 (15:43 -0500)]
[PassBuilder] Add OpenMPOpt to default LTO pipeline
The LTO support for OpenMP offloading allows us to run the OpenMPOpt
pass during the LTO pipeline. This patch introduces an early run of the
Module pass and a late run of the CGSCC pass. These are quick no-ops if
there is no OpenMP in the module.
Depends on D118198
Differential Revision: https://reviews.llvm.org/D118611
Joseph Huber [Tue, 25 Jan 2022 22:46:01 +0000 (17:46 -0500)]
[OpenMP] Remove call to 'clang-offload-wrapper' binary
Summary:
This patch removes the system call to the `clang-offload-wrapper` tool
by replicating its functionality in a new file. This improves
performance and makes the future wrapping functionality easier to
change.
Differential Revision: https://reviews.llvm.org/D118198
Joseph Huber [Tue, 25 Jan 2022 19:25:39 +0000 (14:25 -0500)]
[OpenMP] Replace sysmtem call to `llc` with target machine
Summary:
This patch replaces the system call to the `llc` binary with a library
call to the target machine interface. This should be faster than
relying on an external system call to compile the final wrapper binary.
Differential Revision: https://reviews.llvm.org/D118197
Joseph Huber [Tue, 25 Jan 2022 16:23:27 +0000 (11:23 -0500)]
[OpenMP] Cleanup the Linker Wrapper
Summary:
Various changes and cleanup for the Linker Wrapper tool.
Joseph Huber [Tue, 18 Jan 2022 15:56:12 +0000 (10:56 -0500)]
[OpenMP] Include the executable name in the temporary files
Summary:
This parses the executable name out of the linker arguments so we can
use it to give more informative temporary file names and so we don't
accidentally use it for device linking.
Joseph Huber [Sun, 16 Jan 2022 21:06:59 +0000 (16:06 -0500)]
[OpenMP] Implement save temps functionality in linker wrapper
Summary:
This patch implements the `-save-temps` flag for the linker wrapper.
This allows the user to inspect the intermeditary outpout that the
linker wrapper creates.
Joseph Huber [Sun, 16 Jan 2022 04:10:52 +0000 (23:10 -0500)]
[OpenMP] Embed bitcode after optimizations instead of linking
Summary:
Various changes to the linker wrapper, and the bitcode embedding is not
done after the optimizations have run rather than after linking is done.
This saves time when doing JIT.
Joseph Huber [Fri, 14 Jan 2022 03:59:05 +0000 (22:59 -0500)]
[OpenMP] Improve symbol resolution for OpenMP Offloading LTO
This patch improves the symbol resolution done for LTO with offloading
applications. The symbol resolution done here allows the LTO backend to
internalize more functions. The symbol resoltion done is a simplified
view that does not take into account various options like `--wrap` or
`--dyanimic-list` and always assumes we are creating a shared object.
The actual target may be an executable, but semantically it is used as a
shared object because certain objects need to be visible outside of the
executable when they are read by the OpenMP plugin.
Depends on D117246
Differential Revision: https://reviews.llvm.org/D118155
Joseph Huber [Thu, 13 Jan 2022 17:42:02 +0000 (12:42 -0500)]
[OpenMP] Add support for linking AMDGPU images
This patch adds support for linking AMDGPU images using the LLD binary.
AMDGPU files are always bitcode images and will always use the LTO
backend. Additionally we now pass the default architecture found with
the `amdgpu-arch` tool to the argument list.
Depends on D117156
Differential Revision: https://reviews.llvm.org/D117246
Joseph Huber [Wed, 12 Jan 2022 21:14:52 +0000 (16:14 -0500)]
[OpenMP] Add extra flag handling to linker wrapper
This patch adds support for a few extra flags in the linker wrapper,
such as debugging flags, verbose output, and passing arguments to ptxas. We also
now forward pass remarks to the LLVM backend so they will show up in the LTO
passes.
Depends on D117049
Differential Revision: https://reviews.llvm.org/D117156
Joseph Huber [Tue, 11 Jan 2022 20:50:39 +0000 (15:50 -0500)]
[OpenMP] Add support for embedding bitcode images in wrapper tool
Summary;
This patch adds support for embedding device images in the linker
wrapper tool. This will be used for performing JIT functionality in the
future.
Depends on D117048
Differential Revision: https://reviews.llvm.org/D117049
Joseph Huber [Tue, 11 Jan 2022 15:53:59 +0000 (10:53 -0500)]
[OpenMP] Link the bitcode library late for device LTO
Summary:
This patch adds support for linking the OpenMP device bitcode library
late when doing LTO. This simply passes it in as an additional device
file when doing the final device linking phase with LTO. This has the
advantage that we don't link it multiple times, and the device
references do not get inlined and prevent us from doing needed OpenMP
optimizations when we have visiblity of the whole module.
Fix some failings where the implicit conversion of an Error to an
Expected triggered the deleted copy constructor.
Depends on D116675
Differential revision: https://reviews.llvm.org/D117048
Joseph Huber [Fri, 7 Jan 2022 22:12:51 +0000 (17:12 -0500)]
[OpenMP] Initial Implementation of LTO and bitcode linking in linker wrapper
This patch implements the fist support for handling LTO in the
offloading pipeline. The flag `-foffload-lto` is used to control if
bitcode is embedded into the device. If bitcode is found in the device,
the extracted files will be sent to the LTO pipeline to be linked and
sent to the backend. This implementation does not separately link the
device bitcode libraries yet.
Depends on D116675
Differential Revision: https://reviews.llvm.org/D116975
Joseph Huber [Wed, 5 Jan 2022 18:21:03 +0000 (13:21 -0500)]
[OpenMP] Search for static libraries in offload linker tool
This patch adds support for searching through the linker library paths
to identify static libraries that may contain device code. If device
code is present it will be extracted. This should ideally fully support
static linking with OpenMP offloading.
Depends on D116627
Differential Revision: https://reviews.llvm.org/D116675
Joseph Huber [Tue, 4 Jan 2022 22:20:04 +0000 (17:20 -0500)]
[Clang] Initial support for linking offloading code in tool
This patch adds the initial support for linking NVPTX offloading code
using the clang-linker-wrapper tool. This uses the extracted device
files and runs `nvlink` on them. Currently this is then passed to the
existing toolchain for creating linkable OpenMP offloading programs
using `clang-offload-wrapper` and compiling it manually using `llc`.
More work is required to support LTO, Bitcode linking, AMDGPU, and x86
offloading.
Depends on D116545
Differential Revision: https://reviews.llvm.org/D116627
Joseph Huber [Mon, 3 Jan 2022 17:31:52 +0000 (12:31 -0500)]
[OpenMP] Add support for extracting device code in linker wrapper
This patchs add support for extracting device offloading code from the
linker's input files. If the file contains a section with the name
`.llvm.offloading.<triple>.<arch>` it will be extracted to a new
temporary file to be linked. Addtionally, the host file containing it
will have the section stripped so it does not remain in the executable
once linked.
Depends on D116544
Differential Revision: https://reviews.llvm.org/D116545
Sam Clegg [Mon, 12 Oct 2020 13:59:51 +0000 (06:59 -0700)]
llvm-readobj: support globals in initializer expressions
Differential Revision: https://reviews.llvm.org/D117747
River Riddle [Fri, 21 Jan 2022 08:38:30 +0000 (00:38 -0800)]
[mlir] Add isa/dyn_cast support for dialect interfaces
This matches the same API usage as attributes/ops/types. For example:
```c++
Dialect *dialect = ...;
// Instead of this:
if (auto *interface = dialect->getRegisteredInterface<DialectInlinerInterface>())
// You can do this:
if (auto *interface = dyn_cast<DialectInlinerInterface>(dialect))
```
Differential Revision: https://reviews.llvm.org/D117859
Fangrui Song [Tue, 1 Feb 2022 03:16:11 +0000 (19:16 -0800)]
[AArch64] Temporarily use getPointerElementType to fix -Wdeprecated-declarations. NFC
Tanya Lattner [Tue, 1 Feb 2022 03:03:29 +0000 (19:03 -0800)]
Add status of migration.
Mircea Trofin [Tue, 1 Feb 2022 02:59:47 +0000 (18:59 -0800)]
[nfc][mlgo][regalloc] 'hasPreferredPhys' out of feature components
It isn't cacheable, it can be updated by other events than live interval
resizing.
Geoffrey Martin-Noble [Tue, 1 Feb 2022 01:50:59 +0000 (17:50 -0800)]
[Bazel] Don't fail the build on usage of deprecated APIs
Build failures are not a particularly helpful way to enforce not using
deprecated APIs and that isn't the point of the Bazel build.
At the same time, this removes `-Wno-unused` this is a check that we do
enforce in the Google internal build and so are ok maintaining in our
maintenance of the upstream Bazel build (the comment about not wanting
to do so was from a time when this was in a separate repository and I was
the only one maintaining it).
Differential Revision: https://reviews.llvm.org/D118671
Changpeng Fang [Tue, 1 Feb 2022 02:07:47 +0000 (18:07 -0800)]
AMDGPU {NFC}: Add code object v5 support and generate metadata for implicit kernel args
Summary:
Add code object v5 support (deafult is still v4)
Generate metadata for implicit kernel args for the new ABI
Set the metadata version to be 1.2
Reviewers:
t-tye, b-sumner, arsenm, and bcahoon
Fixes:
SWDEV-307188, SWDEV-307189
Differential Revision:
https://reviews.llvm.org/D118272
Chris Bieneman [Tue, 1 Feb 2022 01:44:37 +0000 (19:44 -0600)]
Fix memory leak I introduced in
2d66ed370a40
This should fix the asan issue identified on the Linux asan bot.
David Blaikie [Tue, 1 Feb 2022 01:32:31 +0000 (17:32 -0800)]
Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"
Some functions can end up non-externally visible despite not being
declared "static" or in an unnamed namespace in C++ - such as by having
parameters that are of non-external types.
Such functions aren't mistakenly intended to be defining some function
that needs a declaration. They could be maybe more legible (except for
the `operator new` example) with an explicit static, but that's a
stylistic thing outside what should be addressed by a warning.
Jonas Devlieghere [Tue, 1 Feb 2022 00:51:07 +0000 (16:51 -0800)]
[lldb] Use the build's python interpreter in the shell tests
Make sure that the shell tests use the same python interpreter as the
rest of the build instead of picking up `python` from the PATH.
It would be nice if we could use the _disallow helper, but that triggers
on invocations that specify python as the scripting language.
Fangrui Song [Tue, 1 Feb 2022 00:46:11 +0000 (16:46 -0800)]
[BitcodeWriter] Fix cases of some functions
`WriteIndexToFile` is used by external projects so I do not touch it.
Fangrui Song [Tue, 1 Feb 2022 00:33:56 +0000 (16:33 -0800)]
[ModuleUtils] Move EmbedBufferInModule to LLVMTransformsUtils
D116542 adds EmbedBufferInModule which introduces a layer violation
(https://llvm.org/docs/CodingStandards.html#library-layering).
See
2d5f857a1eaf5f7a806d12953c79b96ed8952da8 for detail.
EmbedBufferInModule does not use BitcodeWriter functionality and should be moved
LLVMTransformsUtils. While here, change the function case to the prevailing
convention.
It seems that EmbedBufferInModule just follows the steps of
EmbedBitcodeInModule. EmbedBitcodeInModule calls WriteBitcodeToFile but has IR
update operations which ideally should be refactored to another library.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D118666
Joseph Huber [Mon, 31 Jan 2022 23:58:35 +0000 (18:58 -0500)]
[LLVM] Resolve layer violation in BitcodeWriter
Summary:
The changes introduced in D116542 added a dependency on TransformUtils
to use the `appendToCompilerUsed` method. This created a circular
dependency. This patch simply copies the needed function locally to
remove the dependency.
Keith Smiley [Sat, 29 Jan 2022 04:06:51 +0000 (20:06 -0800)]
[llvm-objcopy][MachO] Ignore LC_LINKER_OPTION when redefining symbols
Previously you would get this error:
```
error: unsupported load command (cmd=0x2d)
```
If the binary you were redefining the symbols of contained a
LC_LINKER_OPTION load command. This command does not need to be changed
when redefining symbols so we can ignore it like many others.
Differential Revision: https://reviews.llvm.org/D118526
Fangrui Song [Mon, 31 Jan 2022 23:41:45 +0000 (15:41 -0800)]
[Bazel] Add include/llvm/Transforms/Utils/ModuleUtils.h to work around layer violation after D116542
There is a layer violation and can break clang -fmodule-name=X -fmodules-strict-decluse builds:
* LLVMTransformUtils has `#include "llvm/Bitcode/BitcodeWriterPass.h"`
* LLVMBitWriter depends on LLVMTransformUtils after D116542
Temporarily work around the issue.
Michael Kruse [Mon, 31 Jan 2022 15:49:44 +0000 (09:49 -0600)]
[Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.
When the stepsize does not evenly divide the range's end, round-up to ensure that that last multiple of the stepsize before the reaching the upper boud is reached. For instance, the trip count of
for (int i = 0; i < 7; i+=5)
is two (i=0 and i=5), not (7-0)/5 == 1.
Reviewed By: peixin
Differential Revision: https://reviews.llvm.org/D118542
Peter Klausler [Wed, 26 Jan 2022 17:53:12 +0000 (09:53 -0800)]
[flang] Make NEWUNIT= use a range suitable for INTEGER(KIND=1) and recycle unit numbers
Use a bit-set to manage runtime-generated I/O unit numbers, recycle
them after they're closed, and use a range of values that fits in
a minimal-sized integer.
Differential Revision: https://reviews.llvm.org/D118651
Mircea Trofin [Mon, 31 Jan 2022 22:43:03 +0000 (14:43 -0800)]
[mlgo][regalloc] Factor live interval feature calculation
Factoring it out so we can subsequently cache it. This should be a NFC,
however, for the float quantities, we see small errors in the least
significant digits. This is because, before, we were summing up one by
one. Now, we sum up results of sums.
This shouldn't matter for ML, and will require rework when we do
quantization (avoiding floats altogether), but meanwhile, it did require
an update to the reference file used for testing.
The patch also bumps the precision of the variables involved in this, to
reduce the error (note they are casted back to float at the end by the
SET macro, since we only work with float and not double in TF)
Differential Revision: https://reviews.llvm.org/D118659
Snehasish Kumar [Mon, 31 Jan 2022 22:15:36 +0000 (14:15 -0800)]
[instrprof][NFC] Refactor out the common logic for getProfileKind.
The logic for getProfileKind for RawInstrProfReader and
InstrProfReaderIndex is similar. To avoid duplication, move the logic
from the header to InstrProfReader.cpp and introduce a static method
which implements the common code.
Differential Revision: https://reviews.llvm.org/D118656
Snehasish Kumar [Wed, 29 Dec 2021 23:31:11 +0000 (15:31 -0800)]
[memprof] Move the meminfo block struct to MemProfData.inc.
The definition of the MemInfoBlock is shared between the memprof
compiler-rt runtime and llvm/lib/ProfileData/. This change removes the
memprof_meminfoblock header and moves the struct to the shared include
file. To enable this sharing, the Print method is moved to the
memprof_allocator (the only place it is used) and the remaining uses are
updated to refer to the MemInfoBlock defined in the MemProfData.inc
file.
Also a couple of other minor changes which improve usability of the
types in MemProfData.inc.
* Update the PACKED macro to handle commas.
* Add constructors and equality operators.
* Don't initialize the buildid field.
Differential Revision: https://reviews.llvm.org/D116780
Peter Klausler [Thu, 20 Jan 2022 22:09:05 +0000 (14:09 -0800)]
[flang] runtime perf: larger I/O buffer growth increments
When reallocating an I/O buffer to accommodate a large record,
ensure that the amount of growth is at least as large as the
minimum initial record size (64KiB). The previous policy was
causing input buffer reallocation for each byte after the minimum
buffer size when scanning input data for record termination
newlines.
Differential Revision: https://reviews.llvm.org/D118649
Dávid Bolvanský [Mon, 31 Jan 2022 22:45:56 +0000 (23:45 +0100)]
[Clang][NFC] Added testcase from #49549
The issue is fixed in trunk, so add testcase to avoid regression in the future.
Konstantin Varlamov [Mon, 31 Jan 2022 22:44:53 +0000 (14:44 -0800)]
[libc++][ranges][NFC] Fix formatting on newly-added links on the Ranges status page.
Sam Clegg [Sun, 30 Jan 2022 03:09:06 +0000 (19:09 -0800)]
[clang][WebAssembly] Imply -fno-threadsafe-static when threading is disabled
When we don't enable atomics we completely disabled threading in
which case there is no point in generating thread safe code for
static initialization.
This should always be safe because, in WebAssembly, it is not
possible to link object compiled without the atomics feature into a
mutli-threaded program.
See https://github.com/emscripten-core/emscripten/pull/16152
Differential Revision: https://reviews.llvm.org/D118571
Chris Bieneman [Mon, 31 Jan 2022 21:44:55 +0000 (15:44 -0600)]
[NFC] Skip PassBuilderCTests if no default triple
This fixes the unit tests so that it is skipped if there is no default
target triple set. Unset default target triple is a supported build
configuration for LLVM.
Mircea Trofin [Mon, 31 Jan 2022 22:01:43 +0000 (14:01 -0800)]
[NFC][regalloc] Move evict advisor initialization before VRAI
This is because a subsequent patch will propose obtaining the VRAI from
the advisor, which will enable feature caching for the ML advisor, for
better compile time. Making this change first as it's both innocuous and
keeps the future patch to be reviewed small.
Joachim Protze [Mon, 31 Jan 2022 21:53:01 +0000 (22:53 +0100)]
[OpenMP][tests][NFC] Pin debug info to DWARF v4 for libarcher tests
Temporary solution for #53467, since debian test machines do not support
DWARF v5.
Kirill Stoimenov [Mon, 31 Jan 2022 20:51:03 +0000 (20:51 +0000)]
[ASan] Fixed null pointer bug introduced in D112098.
Also added some more test to cover the "else if" part.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D118645
Joseph Huber [Mon, 31 Jan 2022 21:46:00 +0000 (16:46 -0500)]
[OpenMP] Remove hard-coded triple in new driver test
Summary:
Previously this test used a hard-coded triple value in the check lines
wihch failed on other architectures. This patch changes that to accept
any host triple.
Itay Bookstein [Sat, 29 Jan 2022 11:05:17 +0000 (13:05 +0200)]
[clang][CodeGen][NFC] Remove unused CodeGenModule fields
Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D118619
Mircea Trofin [Mon, 31 Jan 2022 21:42:47 +0000 (13:42 -0800)]
[nfc][mlgo] De-const a parameter
We plan to pass the MachineFunction& to APIs that expect it non-const
(for legitimate reasons). The advisor still holds the ref as a const
ref, though, so we keep most of the maintainability value of that.
Peter Klausler [Wed, 26 Jan 2022 17:54:58 +0000 (09:54 -0800)]
[flang] Distinguish intrinsic from non-intrinsic modules
For "USE, INTRINSIC", search only for intrinsic modules;
for "USE, NON_INTRINSIC", do not recognize intrinsic modules.
Allow modules of both kinds with the same name to be used in
the same source file (but not in the same scoping unit, a
constraint of the standard that is now enforced).
The symbol table's scope tree now has a single instance of
a scope with a new kind, IntrinsicModules, whose children are
the USE'd intrinsic modules (explicit or not). This separate
"top-level" scope is a child of the single global scope and
it allows both intrinsic and non-intrinsic modules of the same
name to exist in the symbol table. Intrinsic modules' scopes'
symbols now have the INTRINSIC attribute set.
The search path directories need to make a distinction between
regular directories and the one(s) that point(s) to intrinsic
modules. I allow for multiple intrinsic module directories in
the second search path, although only one is needed today.
Differential Revision: https://reviews.llvm.org/D118631
William S. Moses [Sun, 17 Oct 2021 22:31:00 +0000 (18:31 -0400)]
[LoopIdiom] Keep TBAA when creating memcpy/memmove
When upgrading a loop of load/store to a memcpy, the existing pass does not keep existing aliasing information. This patch allows existing aliasing information to be kept.
Reviewed By: jeroen.dobbelaere
Differential Revision: https://reviews.llvm.org/D108221
Nico Weber [Mon, 31 Jan 2022 21:15:48 +0000 (16:15 -0500)]
[gn build] (manually) port
551b1774524
Martin Storsjö [Wed, 12 Jan 2022 09:26:49 +0000 (09:26 +0000)]
[libcxx] [Windows] Pick a unique bit for __regex_word
The old `__regex_word` aliased the mask for `xdigit`, causing stray
test failures.
The diff may look surprising, as if the previous faulty value had
been set specifically for Windows - but this is due to a restructuring
in
411c630bae0e0d50697651797709987e2cfea92d. Prior to that, there
were OS specific settings for some OSes, and one fallback used for
the rest (which turns out to not work for Windows).
Differential Revision: https://reviews.llvm.org/D118188
David Greene [Mon, 31 Jan 2022 15:06:08 +0000 (07:06 -0800)]
[UpdateTestChecks] Re-add --filter and --filter-out options
Re-add filtering options with fixes for failed tests. We were not passing the
is_filtered argument in all check generator calls in update_cc_test_checks.py
Enhance the various update_*_test_checks.py tools to allow filtering the tool
output with regular expressions. The --filter option will emit only tool output
lines matching the given regular expression while the --filter-out option will
emit only tools output lines not matching the given regular expression. Filters
are applied in order of appearance on the command line (or in UTC_ARGS) and the
first matching filter terminates the search.
This allows test authors to create more focused tests by removing irrelevant
tool output and checking only the pieces of output necessary to test the desired
functionality.
Differential Revision: https://reviews.llvm.org/D117694
tyb0807 [Thu, 20 Jan 2022 11:28:19 +0000 (11:28 +0000)]
[AArch64] Removing redundant PAuth flag
This removes `HasPAUTH` from `AArch64SubTarget`, as it seems to be a
redundant, unused copy of `HasPAuth`.
Differential Revision: https://reviews.llvm.org/D117782
tyb0807 [Wed, 19 Jan 2022 10:19:58 +0000 (10:19 +0000)]
[AArch64][SelectionDAG] CodeGen for Armv8.8/9.3 MOPS
New target SDNodes are added: AArch64ISD::MOPS_MEMSET, etc.
Each intrinsic is translated to one of these in SelectionDAGBuilder
via EmitTargetCodeForMOPS.
A custom lowering routine for INTRINSIC_W_CHAIN is added to handle
llvm.aarch64.mops.memset.tag. This takes a separate path from the common
intrinsics but ultimately ends up in the same EmitMOPS().
This is part 4/4 of a series of patches split from
https://reviews.llvm.org/D117405 to facilitate reviewing.
Patch by Tomas Matheson, Lucas Prates and Son Tuan Vu.
Differential Revision: https://reviews.llvm.org/D117764
Joseph Huber [Thu, 30 Dec 2021 21:41:36 +0000 (16:41 -0500)]
[Clang] Introduce Clang Linker Wrapper Tool
This patch introduces a linker wrapper tool that allows us to preprocess
files before they are sent to the linker. This adds a dummy action and
job to the driver stage that builds the linker command as usual and then
replaces the command line with the wrapper tool.
Depends on D116543
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D116544
Joseph Huber [Wed, 29 Dec 2021 21:29:13 +0000 (16:29 -0500)]
[OpenMP] Embed device files into the host IR
This patch adds support for embedding the device object files into the
host IR to create a fat binary. Each offloading file will be inserted
into a section with the following naming format
`.llvm.offloading.<triple>.<arch>.<filename>`.
Depends on D116542
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D116543
Joseph Huber [Fri, 3 Dec 2021 20:48:36 +0000 (15:48 -0500)]
[OpenMP] Add a flag for embedding a file into the module
This patch adds support for a flag `-fembed-offload-binary` to embed a
file as an ELF section in the output by placing it in a global variable.
This can be used to bundle offloading files with the host binary so it
can be accessed by the linker. The section is named using the
`-fembed-offload-section` option.
Depends on D116541
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D116542
Joseph Huber [Thu, 16 Dec 2021 17:40:13 +0000 (12:40 -0500)]
[OpenMP] Introduce new flag to change offloading driver pipeline
This patch introduces the `-fopenmp-new-driver` option which instructs
the compiler to use a new driver scheme for producing offloading code.
In this scheme we create a complete offloading object file and then pass
it as input to the host compilation phase. This will allow us to embed
the object code in the backend phase.
This is the start of a series of commits to rework the OpenMP offloading driver
pipeline. The goal of this is to simplify the steps required for creating an
offloading program. This patch changes the driver's configuration to simply pass
the device file back to the host as an input so it can be embedded as an LLVM IR
global during the backend, then simply passes that object file to the linker.
This driver implementation will currently create the following phases,
```
$ clang input.c -fopenmp -fopenmp-targets=nvptx64 -fopenmp-new-driver -ccc-print-phases
+- 0: input, "input.c", c, (host-openmp)
+- 1: preprocessor, {0}, cpp-output, (host-openmp)
+- 2: compiler, {1}, ir, (host-openmp)
| | +- 3: input, "input.c", c, (device-openmp)
| | +- 4: preprocessor, {3}, cpp-output, (device-openmp)
| |- 5: compiler, {4}, ir, (device-openmp)
| +- 6: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (nvptx64)" {5}, ir
| +- 7: backend, {6}, assembler, (device-openmp)
|- 8: assembler, {7}, object, (device-openmp)
+- 9: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (nvptx64)" {8}, ir
+- 10: backend, {9}, assembler, (host-openmp)
+- 11: assembler, {10}, object, (host-openmp)
12: clang-linker-wrapper, {11}, image, (host-openmp)
```
Which will map to the following bindings
```
# "x86_64-unknown-linux-gnu" - "clang", inputs: ["input.c"], output: "/tmp/input-bae62e.bc"
# "nvptx64" - "clang", inputs: ["input.c", "/tmp/input-bae62e.bc"], output: "/tmp/input-76784e.s"
# "nvptx64" - "NVPTX::Assembler", inputs: ["/tmp/input-76784e.s"], output: "/tmp/input-8f29db.o"
# "x86_64-unknown-linux-gnu" - "clang", inputs: ["/tmp/input-bae62e.bc", "/tmp/input-8f29db.o"], output: "/tmp/input-545450.o"
# "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["/tmp/input-545450.o"], output: "a.out"
```
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D116541