Erich Keane [Tue, 4 Oct 2022 21:33:36 +0000 (14:33 -0700)]
[NFC] Fix warning wiht parens in assert from 1376c7
Keith Smiley [Tue, 4 Oct 2022 20:41:01 +0000 (13:41 -0700)]
[lld-macho][test] Add -lSystem to all lld invocations
This is a requirement from ld64, so this mirrors that expectation. Most
of these changes were just offsets from adding the library, or adding
dyld_stub_binder which is always added when linking ld64. This also adds
`%no-lsystem-lld` for the few cases where we're explicitly testing
things without that.
Fixes: https://github.com/llvm/llvm-project/issues/54184
Differential Revision: https://reviews.llvm.org/D135193
Gulfem Savrun Yeniceri [Tue, 4 Oct 2022 20:37:39 +0000 (20:37 +0000)]
Revert "Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify"
This reverts commit
e1dd2cd063785ea3a6004c8d173f13113b1b8265 because
the original commit
b20e34b39f72f2be035dfb7367b6880fd2cf213a had
a dramatic increase in the build time of RTfuzzer, which caused Fuchsia
Clang toolchain builders to timeout:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/
b8801248587754572961/overview
Nico Weber [Tue, 4 Oct 2022 19:53:18 +0000 (15:53 -0400)]
[lld/mac] With -demangle, strip leading _ from non-mangled names
For
void f();
int main() { f(); }
`lld -demangle` now produces
ld64.lld: error: undefined symbol: f
>>> referenced by path/to/main.o:(symbol main+0x8)
instead of
ld64.lld: error: undefined symbol: _f
>>> referenced by path/to/main.o:(symbol _main+0x8)
previously. (Without `-demangle`, it still prints `_f` and `_main`.)
This does *not* match ld64's behavior, but it does match e.g. lld/COFF's
behaviour.
This is arguably easier to understand: clang prepends symbol names with `_`
on macOS, so it seems friendly if the linker removes it again in its
diagnostics. It also makes the `extern "C"` insertion diagnostics we added
recently look more self-consistent.
Differential Revision: https://reviews.llvm.org/D135189
Daniel Thornburgh [Tue, 20 Sep 2022 17:51:14 +0000 (10:51 -0700)]
[llvm-objdump] Add --build-id flag for debuginfod lookups without binary.
Adding a --build-id flag allows handling binaries that are referenced in
logs from remote systems, but that aren't necessarily present on the
local machine. These are fetched via debuginfod and handled as if they
were input filenames.
Reviewed By: jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D133992
Nico Weber [Tue, 4 Oct 2022 20:39:41 +0000 (16:39 -0400)]
[gn build] port
77945a344c3d
Lang Hames [Tue, 4 Oct 2022 18:31:09 +0000 (11:31 -0700)]
[ExecutionEngine] Enable ExecutionEngine regression tests on AArch64.
Florian Hahn [Tue, 4 Oct 2022 20:35:41 +0000 (21:35 +0100)]
[LoopVersioning,LLE] Clear LoopAccessInfoManager after making changes.
Loop versioning changes the control-flow, which may impact SCEVs cached
by for other loops in LoopAccessInfoManager. Clear the manager after
making changes.
Fixes #57825.
Depends on D134609.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D134611
Michael Jones [Tue, 4 Oct 2022 18:59:55 +0000 (11:59 -0700)]
[libc] implement basic rand and srand
This provides the reference implementation of rand and srand. In future
this will likely be upgraded to something that supports full ints.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D135187
Slava Zakharin [Mon, 3 Oct 2022 23:54:12 +0000 (16:54 -0700)]
[flang][tco] Engineering option for running only CodeGen passes.
This option allows running only CodeGen passes and then translating
FIR to LLVM IR. I am using it to fetch optimized FIR after bbc,
hand-modify it and then produce LLVM IR that can be fed to clang.
David Blaikie [Thu, 8 Sep 2022 20:22:39 +0000 (20:22 +0000)]
MSVC ABI: Looks like even non-aarch64 uses the MSVC/14 definition for pod/aggregate passing
Details posted here: https://reviews.llvm.org/D119051#3747201
3 cases that were inconsistent with the MSABI without this patch applied:
https://godbolt.org/z/GY48qxh3G - field with protected member
https://godbolt.org/z/Mb1PYhjrP - non-static data member initializer
https://godbolt.org/z/sGvxcEPjo - defaulted copy constructor
I'm not sure what's suitable/sufficient testing for this - I did verify
the three cases above. Though if it helps to add them as explicit tests,
I can do that too.
Also, I was wondering if the other use of isTrivialForAArch64MSVC in
isPermittedToBeHomogenousAggregate could be another source of bugs - I
tried changing the function to unconditionally call
isTrivialFor(AArch64)MSVC without testing AArch64 first, but no tests
fail, so it looks like this is undertested in any case. But I had
trouble figuring out how to exercise this functionality properly to add
test coverage and then compare that to MSVC itself... - I got very
confused/turned around trying to test this, so I've given up enough to
send what I have out for review, but happy to look further into this
with help.
Differential Revision: https://reviews.llvm.org/D133817
David Green [Tue, 4 Oct 2022 20:18:30 +0000 (21:18 +0100)]
[AArch64] Ensure condition (SUBS) has no uses of value in performCONDCombine
performCONDCombine removes and 0xff in patterns of
SUBS (and (add(..), 0xff), C)
under certain complex conditions. It doesn't come up often,
but in the lowering of usub.sat where the SUBS is both used as a
condition and as a value, the And is removed where it would only be
valid for the condition.
Fixes #58109.
Differential Revision: https://reviews.llvm.org/D135043
David Blaikie [Fri, 23 Sep 2022 23:32:05 +0000 (23:32 +0000)]
MSVC AArch64 ABI: Homogeneous aggregates
Fixes:
Protected members, HFA: https://godbolt.org/z/zqdK7vdKc
Private members, HFA: https://godbolt.org/z/zqdK7vdKc
Non-empty base, HFA: https://godbolt.org/z/PKTz59Wev
User-provided ctor, HFA: https://godbolt.org/z/sfrTddcW6
Existing correct cases:
Empty base class, NonHFA: https://godbolt.org/z/4veY9MWP3
- correct by accident of not allowing bases at all (see non-empty base
case/fix above for counterexample)
Polymorphic: NonHFA: https://godbolt.org/z/4veY9MWP3
Trivial copy assignment, HFA: https://godbolt.org/z/Tdecj836P
Non-trivial copy assignment, NonHFA: https://godbolt.org/z/7c4bE9Whq
Non-trivial default ctor, NonHFA: https://godbolt.org/z/Tsq1EE7b7
- correct by accident of disallowing all user-provided ctors (see
user-provided non-default ctor example above for counterexample)
Trivial dtor, HFA: https://godbolt.org/z/nae999aqz
Non-trivial dtor, NonHFA: https://godbolt.org/z/69oMcshb1
Empty field, NonHFA: https://godbolt.org/z/8PTxsKKMK
- true due to checking for the absence of padding (see comment in code)
After a bunch of testing, this fixes a bunch of cases that were
incorrect. Some of the tests verify the nuances of the existing
behavior/code checks that were already present.
This was mostly motivated by cleanup from/in D133817 which itself was
motivated by D119051.
By removing the incorrect use of isTrivialForAArch64MSVC here & adding
more nuance to the homogeneous testing we can more safely/confidently
make changes to the isTrivialFor(AArch64)MSVC to more properly align
with its usage anyway.
Differential Revision: https://reviews.llvm.org/D134688
Michał Górny [Mon, 3 Oct 2022 07:59:34 +0000 (09:59 +0200)]
[clang-tools-extra] [clangd] Respect llvm_shlib_dir in tests
Add llvm_shlib_dir to variables used in clangd test suite, consistently
to how it is used in the test suites of clang, clang-tools-extra
and a few other components. This is necessary to ensure that
the correct shared libraries are used when building clang standalone --
otherwise, use_clang() sets LD_LIBRARY_PATH to the directory containing
the earlier system installation of clang rather than the just-built
library.
Differential Revision: https://reviews.llvm.org/D135062
Azat Khuzhin [Tue, 4 Oct 2022 19:55:19 +0000 (19:55 +0000)]
[clang] fix generation of .debug_aranges with LTO
Right now in case of LTO the section is not emited:
$ cat test.c
void __attribute__((optnone)) bar()
{
}
void __attribute__((optnone)) foo()
{
bar();
}
int main()
{
foo();
}
$ clang -flto=thin -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out | fgrep -c -e foo -e bar
0
$ clang -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out | fgrep -c -e foo -e bar
2
Fix this by passing explicitly --plugin-opt=-generate-arange-section.
Suggested-by: OCHyams <orlando.hyams@sony.com>
Reviewed By: dblaikie, MaskRay
Differential Revision: https://reviews.llvm.org/D133092
Nick Desaulniers [Tue, 4 Oct 2022 18:59:29 +0000 (11:59 -0700)]
[Clang] fix -Wvoid-ptr-dereference for gnu89
Follow up to D134702; it looks like we were still warning for gnu89
mode.
Link: https://reviews.llvm.org/D134702
Link: https://github.com/ClangBuiltLinux/linux/issues/1720#issuecomment-1265738778
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D135090
Benjamin Kramer [Tue, 4 Oct 2022 16:16:39 +0000 (18:16 +0200)]
[sparse] Make GenericOpSparsifier not crash on multi-output dense linalg.generic
The actual transformation doesn't support multi-output GenericOps, but
if we encounter one without sparse annotations we can just leave it
alone.
Differential Revision: https://reviews.llvm.org/D135176
Jan Svoboda [Tue, 4 Oct 2022 19:19:18 +0000 (12:19 -0700)]
[clang][deps] NFC: Respect working directory on construction
This patch provides `FileManager` with the CWD on construction in the worker, rather than later in the action.
Depends on D134976.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D134977
Jan Svoboda [Tue, 4 Oct 2022 19:19:01 +0000 (12:19 -0700)]
[clang][deps] Abolish FileManager sharing
This patch removes the ability of a dependency scanning worker to share a `FileManager` instance between individual scans. It's not sound and doesn't provide performance benefits (due to the underlying caching VFS).
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D134976
Sam McCall [Tue, 4 Oct 2022 19:37:27 +0000 (21:37 +0200)]
[clangd] Don't print locations of anonymous tags
These are usually not interesting when clangd presents results in
context, and the file paths are noisy.
Valentin Clement [Tue, 4 Oct 2022 19:29:28 +0000 (21:29 +0200)]
[flang] Lower TYPE(*) as fir.box<none>
This patch lowers `TYPE(*)` correctly to fir.box<none>.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D135141
jeff [Tue, 6 Sep 2022 19:54:53 +0000 (19:54 +0000)]
[DAGCombiner] [AMDGPU] Allow vector loads in MatchLoadCombine
Since SROA chooses promotion based on reaching load / stores of allocas, we may run into scenarios in which we alloca a vector, but promote it to an integer. The result of which is the familiar LoadCombine pattern (i.e. ZEXT, SHL, OR). However, instead of coming directly from distinct loads, the elements to be combined are coming from ExtractVectorElements which stem from a shared load.
This patch identifies such a pattern and combines it into a load.
Change-Id: I0bc06588f11e88a0a975cde1fd71e9143e6c42dd
Siva Chandra Reddy [Tue, 4 Oct 2022 06:43:59 +0000 (06:43 +0000)]
[libc] Add a minimal implementation of the POSIX fork function.
A very simple and minimal implementation of fork is added. Future
changes will add more functionality to satisfy POSIX and Linux
requirements.
An implementation of wait and a few support macros in sys/wait.h
have also been added to help with testing the fork function.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D135131
Jakub Kuderski [Tue, 4 Oct 2022 18:59:54 +0000 (14:59 -0400)]
[mlir][arith] Mark unknown types legal in WIE
Allow unknown types to pass through without being marked as illegal.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D135123
Christian Sigg [Tue, 4 Oct 2022 18:56:49 +0000 (20:56 +0200)]
[mlir][gpu] Fix GCC -Wparenthesis warning
Yuanfang Chen [Tue, 4 Oct 2022 18:15:03 +0000 (11:15 -0700)]
[Clang] make canonical AutoType constraints-free
As @mizvekov suggested in D134772. This works great for D128750 when
dealing with AutoType's.
Reviewed By: mizvekov, erichkeane
Differential Revision: https://reviews.llvm.org/D135088
Ram-NK [Tue, 4 Oct 2022 18:51:07 +0000 (14:51 -0400)]
[NFC][LoopInterchange] Clean up of irrelevent dependency checking with
isOuterMostDepPositive()
The function isOuterMostDepPositive() is checked after negative dependence
vectors are normalized to be non-negative, so there will not be any negative
dependency ('>' as the outermost non-equal sign) after normalization. And
therefore the check in isOuterMostDepPositive() is irrelevent and redundant.
Reviewed By: congzhe
Differential Revision: https://reviews.llvm.org/D132982
Peiming Liu [Tue, 4 Oct 2022 18:16:58 +0000 (18:16 +0000)]
[mlir][sparse] support singleton in loop emitter.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D135185
serge-sans-paille [Wed, 28 Sep 2022 06:36:41 +0000 (08:36 +0200)]
[clang] Unify Sema and CodeGen implementation of isFlexibleArrayMemberExpr
Turn it into a single Expr::isFlexibleArrayMemberLike method, as discussed in
https://discourse.llvm.org/t/rfc-harmonize-flexible-array-members-handling
Keep different behavior with respect to macro / template substitution, and
harmonize sharp edges: ObjC interface now behave as C struct wrt. FAM and
-fstrict-flex-arrays.
This does not impact __builtin_object_size interactions with FAM.
Differential Revision: https://reviews.llvm.org/D134791
Eli Friedman [Tue, 4 Oct 2022 18:41:59 +0000 (11:41 -0700)]
[AArch64] Don't form paired loads from epilogue operations on Windows
AArch64LoadStoreOptimizer has a bunch of different guards to avoid
corrupting Windows SEH prologues/epilogues, but apparently we missed the
case of merging two instructions where the first instruction isn't part
of the epilogue, but the second instruction is.
Fixes issue discovered at https://reviews.llvm.org/D130049#3704064
Differential Revision: https://reviews.llvm.org/D134992
Daniel Thornburgh [Fri, 15 Jul 2022 21:14:13 +0000 (14:14 -0700)]
[llvm-objdump] [debuginfod] Fetch for very-stripped binaries.
When a binary is missing section headers or symbols, objdump can't
provide as good of a disassembly. This change makes objdump try to fetch
a better verion of the binary by its build ID.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D132887
Jim Ingham [Tue, 4 Oct 2022 18:36:25 +0000 (11:36 -0700)]
Turn off the warning that the undefined behavior I am using in
a test generates. The green dragon bot compiler is treating this
warning as an error for some reason, hopefully this will calm its
worries.
Nathan James [Tue, 4 Oct 2022 18:38:09 +0000 (19:38 +0100)]
[clang] Add fix-it note to defaulted-function-deleted warning
Adds a fix to the diagnostic of replacing the `= default` to `= delete`
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D134549
Alex Langford [Thu, 29 Sep 2022 21:40:57 +0000 (14:40 -0700)]
[clang][DebugInfo] Respect fmodule-file-home-is-cwd in skeleton CUs for clang modules
When -fmodule-file-home-is-cwd and the path to the PCM is relative, we
shouldn't assume that the path to the PCM is relative to the modulemap
that produced it. To respect the option -fmodule-file-home-is-cwd, we
should assume the path is relative to the current working directory.
Reviewed By: rmaz
Differential Revision: https://reviews.llvm.org/D134911
Jim Radford [Tue, 4 Oct 2022 17:40:35 +0000 (10:40 -0700)]
[objdump] Support finding --source via --dsym files
Add support for auto-detecting or specifying dSYM files/directories to
allow interleaving source with disassembly.
Differential Revision: https://reviews.llvm.org/D135117
Patch by Jim Radford.
Aart Bik [Tue, 4 Oct 2022 18:11:50 +0000 (11:11 -0700)]
[mlir][sparse] fixed typo in fix of bazel fix
Reviewed By: cota
Differential Revision: https://reviews.llvm.org/D135184
Michał Górny [Tue, 4 Oct 2022 14:36:15 +0000 (16:36 +0200)]
[clang-tools-extra] [test] Use CLANG_NO_DEFAULT_CONFIG=1
Set CLANG_NO_DEFAULT_CONFIG=1 for clang-tools-extra tests to prevent
the system configuration files for clang from affecting the test
results.
Differential Revision: https://reviews.llvm.org/D135159
Erich Keane [Tue, 4 Oct 2022 18:07:03 +0000 (11:07 -0700)]
Remove accidentially left assertion
Aart Bik [Tue, 4 Oct 2022 17:57:34 +0000 (10:57 -0700)]
[mlir][sparse] fix bazel breakage
Reviewed By: cota
Differential Revision: https://reviews.llvm.org/D135183
Michael Buch [Tue, 4 Oct 2022 16:50:12 +0000 (17:50 +0100)]
[lldb][test] Skip import-std-module/vector tests
These tests have begun failing starting with commit
`
69a6417406a1b0316a1fa6aeb63339d0e1d2abbd`, which
added a new `import` to `ASTNodeImporter::VisitTypedefType`.
This trips an assertion in following way:
1. When creating a persistent variable for the result we call `CopyType`
(in `DeportType`) under a `CompleteTagDeclsScope` (which is supposed to complete all
decls newly imported in the `CopyType` call).
2. During `CopyType` we call `ASTNodeImporter::VisitTypedefType`
3. This now has a second import call on the desugared type
4. In `ASTImporterDelegate::ImportImpl` we will now try to import a decl
that we originally got from the `std` module (which means it has no valid origin).
But since we’re doing this under a CompleteTagDeclsScope, the
`NewDeclListener::NewDeclImported` adds the decl to the list of decls to
complete after the `CopyType` call. But this list shouldn’t contain decls
with invalid origins because we assert this in `~CompleteTagDeclsScope`, which
is where the tests crash.
We suspect that we previously didn’t see this assert trigger because by the time
we create the result variable we are using an AST whose decls all have
a valid debug-info origin (constructed with the help of the std module).
So we never expected decls from modules to be imported under
`CompleteTagDeclsScope` without a m_sema available (which is the case by
the time we get to `DeportType`). Since there is no `m_sema` available,
`CxxModuleHandler::Import` trivially returns and the decls don’t get added
to the `m_decls_to_ignore` list and count as "newly imported decls".
Skip this test for now until we have a fix or the origin tracking gets
refactored (see https://reviews.llvm.org/D101950).
Differential Revision: https://reviews.llvm.org/D135178
Chris Bieneman [Mon, 3 Oct 2022 18:04:13 +0000 (13:04 -0500)]
[DirectX] Generate `dx.resources` metadata entry
This code adds initial support for generating the HLSL resources
metadata entries. It has a lot of `FIXMEs` laying around because there
is a lot more work to do here, but this lays a solid groundwork and can
accurately handle some trivial cases.
I've filed a swath of issues covering the deficiencies here and left the
issues in comments so that we can easily follow them.
One big change to make sooner rather than later is to move some of this
code into a new libLLVMFrontendHLSL so that we can share it with the
Clang CodeGen layer.
Reviewed By: python3kgae
Differential Revision: https://reviews.llvm.org/D134682
Erich Keane [Thu, 29 Sep 2022 18:38:52 +0000 (11:38 -0700)]
Implement DR2565: Invalid types in the parameter-declaration-clause of a
requires-expression
As reported: https://github.com/llvm/llvm-project/issues/57487
We properly treated a failed instantiation of a concept as a
unsatisified constraint, however, we need to do this at the 'requires
clause' level as well. This ensures that the parameters on a requires
clause that fail instantiation will cause a satisfaction failure.
This patch implements this by running requires parameter clause
instantiation under a SFINAE trap, then stores any such failure as a
requirement failure, so it can be diagnosed later.
Alex Lorenz [Tue, 4 Oct 2022 06:06:56 +0000 (23:06 -0700)]
[clang][driver][darwin] Ensure that the SDK version passed to -platform_version has a minor version number 0
The linker requires at least a "major.minor" for the SDK version, so it will fail when we don't have
a minor version in the case we don't actually have an SDK info.
Sanjay Patel [Tue, 4 Oct 2022 17:15:01 +0000 (13:15 -0400)]
[SDAG] don't hoist div/rem through a select with neutral constant
This bug was introduced with D134966.
Sanjay Patel [Tue, 4 Oct 2022 17:08:35 +0000 (13:08 -0400)]
[x86] add test for select + sdiv neutral constant; NFC
Fangrui Song [Tue, 4 Oct 2022 17:01:30 +0000 (10:01 -0700)]
[llvm-objdump] Add --no-addresses as an alias for --no-leading-addr
The output is similar to objdump --no-addresses since binutils 2.35.
Depends on D135039
Close #58088
Differential Revision: https://reviews.llvm.org/D135040
Fangrui Song [Tue, 4 Oct 2022 17:00:21 +0000 (10:00 -0700)]
[llvm-objdump] --no-leading-addr: hide inline relocation offsets
It seems to make sense to omit offsets when --no-leading-addr is specified. The output is now closer
to objdump -dr --no-addresses (non-wide output).
Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D135039
Nathaniel McVicar [Tue, 4 Oct 2022 16:42:43 +0000 (09:42 -0700)]
[mlir][sparse] Restore case coverage warning fix
This restores the fix from D134925 to make MSVC and clang happy.
Reviewed By: stella.stamenova
Differential Revision: https://reviews.llvm.org/D135126
Mark de Wever [Sat, 17 Sep 2022 10:57:01 +0000 (12:57 +0200)]
[libc++][format] Updates to Unicode 15.
This adds support for the new code points in the Extended Grapheme
Cluster algorithm. The algorithm itself has remained unchanged.
The width estimation still follows the rules of the Standard.
@cor3ntin filed
LWG3780 format's width estimation is too approximate and not forward compatible
to improve the estimate.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D134106
Daniel Rodríguez Troitiño [Tue, 4 Oct 2022 16:27:11 +0000 (09:27 -0700)]
[ObjectYAML] Support for basic data in code.
This is a split of D134250.
Supports for parsing and dumping the LC_DATA_IN_CODE contents (as binary
data).
This allows more complete testing of llvm-objdump in D133974.
Reviewed By: Higuoxing
Differential Revision: https://reviews.llvm.org/D134569
Craig Topper [Tue, 4 Oct 2022 16:15:13 +0000 (09:15 -0700)]
[RISCV] Refactor and improve eliminateFrameIndex.
There are few changes mixed in here.
-Try to reuse the destination register from ADDI instead of always
creating a virtual register. This way we lean on the register
scavenger in fewer case.
-Explicitly reuse the primary virtual register when possible. There's
still a case where both getVLENFactoredAmount and handling large
fixed offsets can both create a secondary virtual register.
-Combine similar BuildMI calls by manipulating the Register variables.
There are still a couple early outs for ADDI, but overall I tried to
arrange the code into steps.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D135009
Craig Topper [Tue, 4 Oct 2022 16:14:41 +0000 (09:14 -0700)]
[RISCV] Restructure eliminateFrameIndex to share more code. NFC
The old code took two different paths based on whether there is
a scalable offset, but these two paths had some code in common.
The main difference between the two code paths was whether we needed
to create a GPR or not for the ADDI that gets created for RVVSpill.
If we had a scalable offset, the same GPR was used as the destination
for adding the scalable offset and the ADDI. To manage this, we now
cache the scratch register and reuse it if it has already been created.
This is a pre-patch for D135009.
Reviewed By: reames, frasercrmck
Differential Revision: https://reviews.llvm.org/D135092
Nicolas Vasilache [Tue, 4 Oct 2022 12:34:12 +0000 (05:34 -0700)]
[mlir][Linalg] NFC - Add result and bbArg pretty printing to linalg.reduce
Differential Revision: https://reviews.llvm.org/D135152
Daniel Rodríguez Troitiño [Tue, 4 Oct 2022 00:46:42 +0000 (17:46 -0700)]
[ObjectYAML][MachO] Encode export trie address as ULEB128, not as SLEB128
The `dumpExportEntry` was dumping everything using signed LEB128, but
the format seems to use unsigned LEB128. This can be cross-checked with
the implementation in MachOObjectFile.cpp, the implementation in LLD's
ExportTrie.cpp, and the implementation in macho2yaml.cpp, which all use
ULEB128 functions..
The difference is only apparent when encoding some values with specific
bit patterns (bit active in the 7th, 14th, ... bits of the binary). The
encoding was not always creating problems in the resulting binaries
because if the extra byte was part of the padding, the result of
decoding it as ULEB128 is the same as decoding as SLEB128, however, the
code of MachOObjectFile.cpp (used by llvm-objdump) checks the buffer
decoding position against the reported length, which triggered an error.
Modified a test that used an address with this pattern (0x3FA0, the 14th
bit is active), to show that a round trip still produces the same
results, and added a check using llvm-objdump to use their extra checks
to verify this implementation.
Reviewed By: pete
Differential Revision: https://reviews.llvm.org/D134563
Nicolas Vasilache [Tue, 4 Oct 2022 09:24:00 +0000 (02:24 -0700)]
[mlir][Tensor] NFC - Add result pretty printing to TensorOps
Differential Revision: https://reviews.llvm.org/D135135
Aaron Ballman [Tue, 4 Oct 2022 16:12:49 +0000 (12:12 -0400)]
Modify the qualified/unqualified getter for TypeOfType; NFC
Post-commit feedback observed that returning the TypeOfKind from the
type instead of a Boolean cleans up code using that interface.
Tom Honermann [Fri, 6 May 2022 20:55:05 +0000 (13:55 -0700)]
[clang] Correct handling of lambdas in lambda default arguments in dependent contexts.
Previously, a lambda expression in a dependent context with a default argument
containing an immediately invoked lambda expression would produce a closure
class object that, if invoked such that the default argument was used, resulted
in a compiler crash or one of the following assertion failures during code
generation. The failures occurred regardless of whether the lambda expressions
were dependent.
clang/lib/CodeGen/CGCall.cpp:
Assertion `(isGenericMethod || Ty->isVariablyModifiedType() || Ty.getNonReferenceType()->isObjCRetainableType() || getContext() .getCanonicalType(Ty.getNonReferenceType()) .getTypePtr() == getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && "type mismatch in call argument!"' failed.
clang/lib/AST/Decl.cpp:
Assertion `!Init->isValueDependent()' failed.
Default arguments in declarations in local context are instantiated along with
their enclosing function or variable template (since such declarations can't
be explicitly specialized). Previously, such instantiations were performed at
the same time that their associated parameters were instantiated. However, that
approach fails in cases like the following in which the context for the inner
lambda is the outer lambda, but construction of the outer lambda is dependent
on the parameters of the inner lambda. This change resolves this dependency by
delyaing instantiation of default arguments in local contexts until after
construction of the enclosing context.
template <typename T>
auto f() {
return [](T = []{ return T{}; }()) { return 0; };
}
Refactoring included with this change results in the same code now being used
to instantiate default arguments that appear in local context and those that
are only instantiated when used at a call site; previously, such code was
duplicated and out of sync.
Fixes https://github.com/llvm/llvm-project/issues/49178
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D133500
Sanjay Patel [Tue, 4 Oct 2022 14:42:59 +0000 (10:42 -0400)]
[InstSimplify] try harder to fold fmul with 0.0 operand
https://alive2.llvm.org/ce/z/oShzr3
This was noted as a missing fold in D134876 (with additional
examples based on issue #58046).
I'm assuming that fmul with a zero operand is rare enough
that the use of ValueTracking will not noticeably increase
compile-time.
This adjusts a PowerPC codegen test that was added with D88388
because it would get folded away and no longer provide coverage
for the bug fix.
Alexey Bataev [Wed, 21 Sep 2022 17:19:43 +0000 (10:19 -0700)]
[SLP]Try to emit canonical shuffle with undef operand.
In the canonical form of the shuffle the poison/undef operand is the
second operand, the patch tries to emit canonical form for partial
vectorization of the buildvector sequence.
Also, this patch starts emitting freeze instruction for shuffles with undef indices if the second shuffle operan is undef, not poison. It is an initial step to D93818, where undef mask element are treated as returning poison value.
Differential Revision: https://reviews.llvm.org/D134377
Pierre van Houtryve [Tue, 4 Oct 2022 14:14:56 +0000 (14:14 +0000)]
[AMDGPU][DAG] Fix insert_vector_elt lowering for 8 bit elements
The bitmask used to extract the bits assumed 16 bit elements and wasn't taking the size of the elements into account.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D135156
Sanjay Patel [Tue, 4 Oct 2022 13:25:56 +0000 (09:25 -0400)]
[InstSimplify] add tests for fmul with 0.0 operand; NFC
Sanjay Patel [Mon, 3 Oct 2022 21:36:55 +0000 (17:36 -0400)]
[InstSimplify] reduce code duplication for fmul folds; NFC
This is a modification of the earlier attempt from:
7b7940f9da80
For fma callers, we only want to swap a 0.0 or 1.0 constant.
Pierre van Houtryve [Fri, 30 Sep 2022 14:56:04 +0000 (14:56 +0000)]
[AMDGPU] Always lower SHUFFLE_VECTOR
Make it illegal, remove InstructionSelector logic for it
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D134967
Jay Foad [Tue, 4 Oct 2022 10:24:19 +0000 (11:24 +0100)]
[ISel] Fix crash in new FMA DAG combine
Fix a crash in the FMA combine added by D132837 and amended by D134810.
In cases where the newly created node could be folded, the combiner
would fail this assertion:
llc: DAGCombiner.cpp:268: void (anonymous namespace)::DAGCombiner::AddToWorklist(llvm::SDNode *): Assertion `N->getOpcode() != ISD::DELETED_NODE && "Deleted Node added to Worklist"' failed.
Differential Revision: https://reviews.llvm.org/D135150
Amara Emerson [Tue, 4 Oct 2022 13:45:48 +0000 (14:45 +0100)]
[AArch64] Re-generate some checks for itofp and min/max legalization.
Dominik Adamski [Fri, 16 Sep 2022 09:01:17 +0000 (04:01 -0500)]
[OpenMP][OMPIRBuilder] Add support for order(concurrent) to OMPIRBuilder for SIMD directive
If 'order(concurrent)' clause is specified, then the iterations of SIMD loop
can be executed concurrently.
This patch adds support for LLVM IR codegen via OMPIRBuilder for SIMD loop
with 'order(concurrent)' clause. The functionality added to OMPIRBuilder is
similar to the functionality implemented in 'CodeGenFunction::EmitOMPSimdInit'.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D134046
Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
Florian Hahn [Tue, 4 Oct 2022 13:28:04 +0000 (14:28 +0100)]
[LoopVersioning,LLE] Add -S option to runlines.
Pierrick Bouvier [Tue, 4 Oct 2022 13:21:44 +0000 (15:21 +0200)]
Detect errors in Windows packaging script
- Detect VS devcmd error (missing VS)
- Detect missing python install
- Show commands executed
- Removed pause (blocking CI usage)
Differential revision: https://reviews.llvm.org/D135138
Nikita Popov [Fri, 30 Sep 2022 10:13:40 +0000 (12:13 +0200)]
Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify
Reapply with a fix for the case where an operand simplified back
to the original phi: We need to map this case to the new phi node.
-----
foldOpIntoPhi() currently only folds operations into the phi if all
but one operands constant-fold. The two exceptions to this are freeze
and select, where we allow more general simplification.
This patch makes foldOpIntoPhi() generally simplification based and
removes all the instruction-specific logic. We just try to simplify
the instruction for each operand, and for the (potentially) one
non-simplified operand, we move it into the new block with adjusted
operands.
This fixes https://github.com/llvm/llvm-project/issues/57448, which
was my original motivation for the change.
Alex Richardson [Tue, 4 Oct 2022 11:51:36 +0000 (11:51 +0000)]
[SimplifyLibCalls] Retain attributes added by Builder.CreateMem*
This currently does not make much of a difference (only one tests is
affected), but it is helpful e.g. for the out-of-tree CHERI target where
Builder.CreateMemCpy() can add attributes other than parameter alignment.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D135075
Nikita Popov [Tue, 4 Oct 2022 13:09:04 +0000 (15:09 +0200)]
[InstCombine] Add test where op of phi simplifies to phi (NFC)
Degenerate case for D134954.
Louis Dionne [Wed, 21 Sep 2022 13:50:53 +0000 (09:50 -0400)]
[llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS
This is a breaking change. If you were passing one of those three runtimes
in LLVM_ENABLE_PROJECTS, you need to start passing them in LLVM_ENABLE_RUNTIMES
instead. The runtimes in LLVM_ENABLE_RUNTIMES will start being built using
the "bootstrapping build" instead, which means that they will be built
using the just-built Clang. This is usually what you wanted anyway.
If you were using LLVM_ENABLE_PROJECTS=all with the explicit goal of
building these three runtimes, you can now use LLVM_ENABLE_RUNTIMES=all
and these runtimes will be built using the bootstrapping build.
NOTE: This is a re-application of
887b8bd733ea which had been reverted
in
6b03a4fea0b4 because it broke the Sphinx documentation publishers.
The Sphinx documentation publishers have now been moved to using
the runtimes build, so this should not be an issue anymore.
Differential Revision: https://reviews.llvm.org/D132480
Denys Shabalin [Tue, 4 Oct 2022 10:58:38 +0000 (10:58 +0000)]
[mlir] Add fully dynamic constructor to StridedLayoutAttr bindings
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D135139
Uday Bondhugula [Mon, 26 Sep 2022 05:23:16 +0000 (10:53 +0530)]
[MLIR] Simplify affine maps + operands exploiting IV info
Simplify affine expressions and maps while exploiting simple range and
step info of any IVs that are operands. This simplification is local,
O(1) and practically useful in several scenarios. Accesses with
floordiv's and mod's where the LHS is non-negative and bounded or is a
known multiple of a constant can often be simplified. This is
implemented as a canonicalization for all affine ops in a generic way:
all affine.load/store, vector_load/store, affine.apply, affine.min/max,
etc. ops.
Eg: For tiled loop nests accessing buffers this way:
affine.for %i = 0 to 1024 step 32 {
affine.for %ii = 0 to 32 {
affine.load [(%i + %ii) floordiv 32, (%i + %ii) mod 32]
}
}
// Note that %i is a multiple of 32 and %ii < 32, hence:
(%i + %ii) floordiv 32 is the same as %i floordiv 32
(%i + %ii) mod 32 is the same as %ii mod 32.
The simplification leads to simpler index/subscript arithmetic for
multi-dimensional arrays and also in turn enables detection of spatial
locality (for vectorization for eg.), temporal locality or loop
invariance for hoisting or scalar replacement.
Differential Revision: https://reviews.llvm.org/D135085
Thomas Symalla [Tue, 4 Oct 2022 12:30:56 +0000 (14:30 +0200)]
[NFC][AMDGPU] Pre-commit test for D134418.
Adrian Kuegel [Tue, 4 Oct 2022 12:07:39 +0000 (14:07 +0200)]
[mlir] Apply ClangTidy performance finding.
loop variable is copied but only used as const reference.
Alex Zinenko [Fri, 30 Sep 2022 14:11:34 +0000 (14:11 +0000)]
[mlir] relax transform dialect multi-handle restriction
Relax the restriction in the transform dialect interpreter utilities
that expected a payload IR op to be assocaited with at most one
transform IR handle value. This was useful during the initial
bootstrapping to avoid use-after-free error equivalents when a payload
IR op could be erased through one of the handles associated with it and
then accessed through another. It was, however, possible to erase an
ancestor of the payload IR operation in question. The expensive-checks
mode of interpretation is able to detect both cases and has proven
sufficiently robust in debugging use-after-free errors.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D134964
Guray Ozen [Mon, 3 Oct 2022 07:56:42 +0000 (09:56 +0200)]
[mlir][transform] Create GPU transform dialect
This revision adds GPU transform dialect. It also introduce a prefix such as "transform.gpu" for all ops related to this dialect.
MLIR already had two GPU transform op in linalg. This revision moves these ops into GPUTransformOps. The Ops are as follows:
`transform.structured.map_nested_foreach_thread_to_gpu_blocks` -> `transform.gpu.map_foreach_to_blocks`
This op selects the outermost (toplevel) foreach_thread and parallelize across GPU blocks. It can also generate `gpu_launch`.
`transform.structured.map_nested_foreach_thread_to_gpu_threads` -> `transform.gpu.map_nested_foreach_to_threads`
This op parallelizes nested foreach_thread that are inside `gpu_launch` across GPU threads.
It doesn't add new functionality, but there are some minor refactoring of the code.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D134800
Bjorn Pettersson [Thu, 29 Sep 2022 20:31:33 +0000 (22:31 +0200)]
[LibCalls] Cast Char argument to 'int' before calling emitFPutC
The helpers in BuildLibCalls normally expect that the Value
arguments already have the correct type (matching the lib call
signature). And exception has been emitFPutC which casted the Char
argument to 'int' using CreateIntCast. This patch moves the cast to
the caller instead of doing it inside emitFPutC.
I think it makes sense to make the BuildLibCall API:s a bit
more consistent this way, despite the need to handle the int cast
in two different places now.
Differential Revision: https://reviews.llvm.org/D135066
Bjorn Pettersson [Wed, 28 Sep 2022 20:59:39 +0000 (22:59 +0200)]
[BuildLibCalls] Use TLI to get 'int' and 'size_t' type sizes
Stop assuming that an 'int' is 32 bits in helpers that emit libcalls
to lib functions that had 'int' in the signature. For most targets
this is NFC. For a target with 16 bit 'int' type this could help out
detecting if trying to emit a libcall with incorrect signature.
Similarly we now derive the type mapping to 'size_t' by asking TLI
about the size of 'size_t'. This should be NFC (at least for in-tree
targets) since getSizeTSize(), in TLI, is deriving the size in the
same way as DataLayout::getIntPtrType().
Differential Revision: https://reviews.llvm.org/D135065
Bjorn Pettersson [Wed, 28 Sep 2022 20:18:59 +0000 (22:18 +0200)]
[BuildLibCalls] Name types to identify when 'int' and 'size_t' is assumed. NFC
Lots of BuildLibCalls helpers are using Builder::getInt32Ty to get
a type matching an 'int', and DataLayout::getIntPtrType to get a
type matching 'size_t'. The former is not true for all targets, since
and 'int' isn't always 32 bits. And the latter is a bit weird as well
as the definition of DataLayout::getIntPtrType isn't clearly mapping
it to 'size_t'.
This patch is not aiming at solving any such problems. It is merely
highlighting when a libcall is expecting to use 'int' and 'size_t'
by naming the types as IntTy and SizeTTy when preparing the type
signatures for the emitted libcalls.
Differential Revision: https://reviews.llvm.org/D135064
Florian Hahn [Tue, 4 Oct 2022 10:51:22 +0000 (11:51 +0100)]
[LAA] Pass LoopAccessInfoManager instead of GetLAA function.
Use LoopAccessInfoManager directly instead of various GetLAA lambdas.
Depends on D134608.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D134609
Amara Emerson [Tue, 4 Oct 2022 09:08:49 +0000 (10:08 +0100)]
Revert "[AArch64][GlobalISel] Fold away lowered vector sign-extend of vector compares."
This reverts commit
dcd02a524befcec71f46ab76d725b2a8f8623d69.
We should instead use the generic combine.
Nikita Popov [Tue, 4 Oct 2022 09:08:45 +0000 (11:08 +0200)]
[ValueTracking] Handle constant exprs in isKnownNonZero()
Handle constant expressions by falling through to the general
operator-based code. In particular, this adds support for bitcast
and GEP expressions.
Daniel Bertalan [Mon, 15 Aug 2022 07:26:28 +0000 (09:26 +0200)]
[lld-macho] Add support for emitting chained fixups
This commit adds support for chained fixups, which were introduced in
Apple's late 2020 OS releases. This format replaces the dyld opcodes
used for supplying rebase and binding information, and encodes most of
that data directly in the memory location that will have the fixup
applied.
This reduces binary size and is a requirement for page-in linking, which
will be available starting with macOS 13.
A high-level overview of the format and my implementation can be found
in SyntheticSections.h.
This feature is currently gated behind the `-fixup_chains` flag, and
will be enabled by default for supported targets in a later commit.
Like in ld64, lazy binding is disabled when chained fixups are in use,
and the `-init_offsets` transformation is performed by default.
Differential Revision: https://reviews.llvm.org/D132560
bipmis [Tue, 4 Oct 2022 09:39:32 +0000 (10:39 +0100)]
Add reverse load pattern tests
Florian Hahn [Tue, 4 Oct 2022 09:27:52 +0000 (10:27 +0100)]
[SimpleLoopUnswitch] Clear block and loop dispos after destroying loop.
SimpleLoopUnswitch may remove loops. Clear block and loop dispositions,
to clean up invalid entries in the cache.
Fixes #58136.
Nikita Popov [Tue, 4 Oct 2022 09:20:54 +0000 (11:20 +0200)]
[SimplifyLibCalls] Place deref attr even if nonnull already set
If nonnull is already set, we currently skip setting both nonnull
and dereferenceable. Make these independent, to avoid regressions
when additional nonnull attributes are inferred earlier.
Nikita Popov [Tue, 4 Oct 2022 09:17:09 +0000 (11:17 +0200)]
Revert "[InstCombine] Switch foldOpIntoPhi() to use InstSimplify"
This reverts commit
b20e34b39f72f2be035dfb7367b6880fd2cf213a.
This causes RAUW type mismatch assertions on some buildbots,
reverting for now.
Nikita Popov [Tue, 4 Oct 2022 09:02:31 +0000 (11:02 +0200)]
[ValueTracking] Avoid known bits fallthrough for freeze (NFCI)
The known bits logic should never produce a better result than
the direct recursive non-zero query here, so skip the fallthrough.
Nikita Popov [Tue, 4 Oct 2022 08:50:29 +0000 (10:50 +0200)]
[ValueTracking] Switch isKnownNonZero() to switch over opcodes (NFCI)
The change in the assume-queries-counter.ll test is because we skip
and unnecessary known bits query for arguments.
Matthias Springer [Tue, 4 Oct 2022 08:06:00 +0000 (17:06 +0900)]
[mlir][tensor][NFC] Rename linalg.init_tensor to tensor.empty
tensor.empty/linalg.init_tensor produces an uninititalized tensor that can be used as a destination operand for destination-style ops (ops that implement `DestinationStyleOpInterface`).
This change makes it possible to implement `TilingInterface` for non-destination-style ops without depending on the Linalg dialect.
RFC: https://discourse.llvm.org/t/rfc-add-tensor-from-shape-operation/65101
Differential Revision: https://reviews.llvm.org/D135129
Nikita Popov [Fri, 30 Sep 2022 10:13:40 +0000 (12:13 +0200)]
[InstCombine] Switch foldOpIntoPhi() to use InstSimplify
foldOpIntoPhi() currently only folds operations into the phi if all
but one operands constant-fold. The two exceptions to this are freeze
and select, where we allow more general simplification.
This patch makes foldOpIntoPhi() generally simplification based and
removes all the instruction-specific logic. We just try to simplify
the instruction for each operand, and for the (potentially) one
non-simplified operand, we move it into the new block with adjusted
operands.
This fixes https://github.com/llvm/llvm-project/issues/57448, which
was my original motivation for the change.
Valentin Clement [Tue, 4 Oct 2022 07:42:39 +0000 (09:42 +0200)]
[flang] Lower polymorphic entities types in dummy argument and function result
This patch updates lowering to produce the correct fir.class types for
various polymorphic and unlimited polymoprhic entities cases. This is only the
lowering. Some TODOs have been added to the CodeGen part to avoid errors since
this part still need to be updated as well.
The fir.class<*> representation for unlimited polymorphic entities mentioned in
the document has been updated to fir.class<none> to avoid useless work in pretty
parse/printer.
This patch is part of the implementation of the poltymorphic
entities.
https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md
Depends on D134957
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D134959
Florian Hahn [Tue, 4 Oct 2022 07:37:11 +0000 (08:37 +0100)]
[LAA] Use LoopAccessInfoManager in legacy pass.
Simplify LoopAccessLegacyAnalysis by using LoopAccessInfoManager from
D134606. As a side-effect this also removes printing support from
LoopAccessLegacyAnalysis.
Depends on D134606.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D134608
LLVM GN Syncbot [Tue, 4 Oct 2022 07:16:10 +0000 (07:16 +0000)]
[gn build] Port
6d9eb5332913
Balázs Kéri [Tue, 4 Oct 2022 06:43:35 +0000 (08:43 +0200)]
[clang-tidy] Add checker 'bugprone-suspicious-realloc-usage'.
Add a check to detect usages of `realloc` where the result is assigned
to the same variable (or field) as passed to the first argument.
Reviewed By: steakhal, martong
Differential Revision: https://reviews.llvm.org/D133119
Nicolas Vasilache [Fri, 30 Sep 2022 11:07:43 +0000 (04:07 -0700)]
[mlir][Memref] NFC - Addresult pretty printing to MemrefOps
Differential Revision: https://reviews.llvm.org/D134968
Lang Hames [Tue, 4 Oct 2022 02:28:56 +0000 (19:28 -0700)]
[llvm-jitlink] Teach InProcessDeltaMapper to honor -slab-page-size option.
The -slab-page-size option is used to set a simulated page size in -no-exec
tests. In order for this to work we need to use read/write permissions only
on all simulated pages in order to ensure that no simulated page is made
read-only by a permission change to the underlying real page.
The aim of this patch is to make it safe to enable ExecutionEngine regression
tests on arm64. Those tests will be enabled in a follow-up patch.
Lang Hames [Tue, 4 Oct 2022 04:45:31 +0000 (21:45 -0700)]
[ORC] Don't unnecessarily copy collection element.