Commit Graph

436697 Commits

Author SHA1 Message Date
Sanjay Patel ee0bf64722 [InstCombine] try to fold mul by neg-power-of-2 to shl
`(A * -2**C) + B --> B - (A << C)`

https://alive2.llvm.org/ce/z/A6BWkf

This inverts what Negator was doing before:
D134310 / 0f32a5dea0

Analysis and codegen are generally better without multiply,
so we should favor this form even if we trade add for sub
(because those are generally equivalent cost operations).
2022-09-21 15:09:39 -04:00
owenca 3d62139862 [clang-format][NFC] Reformat clang/lib/Format using 6257832bf9
Fix braces and add .clang-format to keep the directory formatted.

Differential Revision: https://reviews.llvm.org/D134329
2022-09-21 12:02:49 -07:00
Aaron Ballman 1ae5310ebb Changing some strange code into an assert; NFC
This code was added in b65b1f322b, but it
was not noticed that the [[fallthrough]] behavior was very wrong. In C
mode, we would set the ParenExprType to CompoundLiteral and then
promptly overwrite that information by falling through.

After some investigation, I convinced myself that it is not possible to
hit this code path in C, only in C++. I've switched it to be an
assertion; I don't expect to hit it, but if we do hit it, that will at
least give us a code example we can use to reason about the intent of
the original code.
2022-09-21 14:59:51 -04:00
Fangrui Song efd97c716b [libclang] Fix -Wswitch after D129883 2022-09-21 11:55:14 -07:00
Fangrui Song 069ecd0c6e [ARM] Check target feature support for __builtin_arm_crc*
`__builtin_arm_crc*` requires the target feature crc which is available on armv8
and above. Calling the fuctions for armv7 leads to a SelectionDAG crash.

```
% clang -c --target=armv7-unknown-linux-gnueabi -c a.c
fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b
PLEASE submit a bug report to ...
```

Add `TARGET_BUILTIN` and define required features for these builtins to
report an error in `CodeGenFunction::checkTargetFeatures`. The problem is quite widespread.
I will add `TARGET_BUILTIN` for more builtins later.

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

Differential Revision: https://reviews.llvm.org/D134127
2022-09-21 11:50:15 -07:00
Scott Linder 552539bdac Revert "[NFC][AMDGPU] Refactor AMDGPUDisassembler"
This reverts commit f583151461.
2022-09-21 18:48:42 +00:00
Fangrui Song bce6416775 [ELF] --pack-dyn-relocs=android: scan relocation serially after D133003
https://reviews.llvm.org/D133003#3806508 can reproduce a non-determinism with
--threads=4. Making the config serial fixes non-determinism (by running the link
many times and compare output).
2022-09-21 11:43:13 -07:00
Siva Chandra Reddy 4f1474daec [libc] Add implementations of POSIX getpid, getppid, getuid, geteuid functions.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D134338
2022-09-21 18:41:20 +00:00
Siva Chandra Reddy e310f8bddf [libc] Add implementation of functions stat, fstat and lstat.
All supporting type and macro definitions have also been added.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D134262
2022-09-21 18:35:02 +00:00
Krzysztof Parzyszek f6e7ad5604 [Hexagon] Revamp type legalization of ext/trunc/sat in HVX
Resizing operations (e.g. sign extension) in DAG can go from any width
to any other width, e.g. i8 -> i32. If the input and the result differ
by a factor larger than 2, the operation cannot be legal in HVX, since
the only two legal vector sizes in HVX are a single vector and a pair
of vectors.
To simplify the legalization, such operations are expanded into steps
that only double/halve the type size, so that each such step can be fully
legalized on its own. The complication is that DAG will automatically
fold these steps back into one, e.g. sext(sext) -> sext. To prevent that
new HexagonISD nodes are introduced: TL_EXTEND and TL_TRUNCATE. Once
legalized, these nodes are replaced with the original opcodes.

The type legalization is now common to aext/sext/zext/trunc and Hexagon-
specific ssat/usat nodes.
2022-09-21 11:25:27 -07:00
Florian Hahn ac434afed8
[AArch64] Try to fold shuffle (tbl2, tbl2) to tbl4.
shuffle (tbl2, tbl2) can be folded into a single tbl4 if the mask for
the selected elements is constant.

Reviewed By: t.p.northover

Differential Revision: https://reviews.llvm.org/D133491
2022-09-21 19:15:56 +01:00
Sanjay Patel 64d309131a [InstCombine] try multi-use demanded bits fold for 'sub'
This is similar to D133788 / 73919a87e9, but for sub
the transform is valid only for low zeros in operand 1.

https://alive2.llvm.org/ce/z/EmRsXC
2022-09-21 14:13:05 -04:00
Sanjay Patel eecaa86314 [InstCombine] add tests for multi-use sub demanded bits: NFC 2022-09-21 14:13:05 -04:00
Sanjay Patel 782b987f52 [InstCombine] add tests for (X * -2**C) + Y; NFC 2022-09-21 14:13:05 -04:00
Fangrui Song fa74144c64 [ELF] Parallelize --compress-debug-sections=zstd
See D117853: compressing debug sections is a bottleneck and therefore it
has a large value parallizing the step.

zstd provides multi-threading API and the output is deterministic even with
different numbers of threads (see https://github.com/facebook/zstd/issues/2238).
Therefore we can leverage it instead of using the pigz-style sharding approach.

Also, switch to the default compression level 3. The current level 5
is significantly slower without providing justifying size benefit.

```
  'dash b.sh 1' ran
    1.05 ± 0.01 times faster than 'dash b.sh 3'
    1.18 ± 0.01 times faster than 'dash b.sh 4'
    1.29 ± 0.02 times faster than 'dash b.sh 5'

level=1 size: 358946945
level=3 size: 309002145
level=4 size: 307693204
level=5 size: 297828315
```

Reviewed By: andrewng, peter.smith

Differential Revision: https://reviews.llvm.org/D133679
2022-09-21 11:13:03 -07:00
Michael Jones a9e0dbefdd [libc] add fputs and puts
add fputs, puts, and the EOF macro that they use.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D134328
2022-09-21 11:10:20 -07:00
Lang Hames f40266603e [ORC-RT] Fix case on test file suffix.
Testcases expect this file to have an uppercase .S suffix.
2022-09-21 11:08:50 -07:00
Joel E. Denny 88f183c0db [lit] Work around another windows issue in new test from 28412d1800
Based on result shown at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10123>
2022-09-21 14:08:10 -04:00
Xiang Li a7e3de2450 [NFC] Fix build error ignored by MSVC. 2022-09-21 10:57:43 -07:00
John McIver 01fdc2a3c9 [Utils] Refactor update_cc_test_checks.py to use shutil
The package `distutils` is deprecated and removal is planned for Python 3.12. All calls to `distutils.spawn.find_executable` are replaced with local version of `find_executable` which makes use of `shutils.which`.

Reviewed By: arichardson, MaskRay

Differential Revision: https://reviews.llvm.org/D134015
2022-09-21 10:55:33 -07:00
Guozhi Wei c39311eb40 [RegisterCoalescer] Use LiveRangeEdit to handle rematerialization
This patch uses the API provided by LiveRangeEdit to handle rematerialization.
It will make future maintenance and improvement more easier.

No functional change.

Differential Revision: https://reviews.llvm.org/D133610
2022-09-21 17:51:07 +00:00
Arthur Eubanks 0f19c60342 [gn build] Don't set LLVM_UNREACHABLE_OPTIMIZE when llvm_enable_assertions
llvm_unreachable should properly error out if assertions are enabled.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D134332
2022-09-21 10:34:48 -07:00
Joel E. Denny b9735db646 [lit] Work around windows issue in new test from 28412d1800
Based on result shown at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10120>
2022-09-21 13:27:41 -04:00
LLVM GN Syncbot 96d6e68ed2 [gn build] Port 782ac2182c 2022-09-21 17:07:56 +00:00
Xiang Li 782ac2182c [HLSL] Support cbuffer/tbuffer for hlsl.
This is first part for support cbuffer/tbuffer.

The format for cbuffer/tbuffer is
BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... };

More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants

New keyword 'cbuffer' and 'tbuffer' are added.
New AST node HLSLBufferDecl is added.
Build AST for simple cbuffer/tbuffer without attribute support.

The special thing is variables declared inside cbuffer is exposed into global scope.
So isTransparentContext should return true for HLSLBuffer.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D129883
2022-09-21 10:07:43 -07:00
Thomas Symalla 1f4d3c681c [NFC][AMDGPU] Add new v_bfi Codegen test.
Pre-commit a test for an upcoming change.
2022-09-21 19:02:11 +02:00
zhijian 3238951b61 Refactor XCOFFObjectFile::getImportFileTable.
Summary:

  1. Refactor with XCOFFObjectFile::getImportFileTable with function getSectionFileOffsetToRawData instead of getLoaderSectionAddress

  2. Delete the function getLoaderSectionAddress.

Reviewers: James Henderson,Esme Yi
Differential Revision: https://reviews.llvm.org/D134280
2022-09-21 12:51:38 -04:00
Arthur Eubanks f77342693b [CGSCC] Properly handle invalidating analyses for invalidated SCCs
Currently if we mark an SCC as invalid, if we haven't set UR.UpdatedC, we won't propagate the PreservedAnalyses up to the parent pass (adaptor/pass manager).

In the provided test case, we inline the function into itself then delete it as it has no users. The SCC is marked as invalid without providing a replacement UR.UpdatedC. Then the CGSCC pass manager and adaptor discard the PreservedAnalyses. Instead, handle PreservedAnalyses first before bailing due to the invalid SCC.

Fixes crashes due to out of date analyses.
2022-09-21 09:50:00 -07:00
Valentin Clement f3222be4fc
[flang] Avoid deallocation of intent(out) when dummy arg is not in entry stmt
In some case, the ENTRY statement in a procedure is including some
dummy argument. Until now, deallocation of intent(out) allocatable was
not checking for this and it could result in a segmentation fault.

This patch avoids deallocation when the value is not in the ENTRY stmt.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D134342
2022-09-21 18:48:09 +02:00
Min-Yih Hsu 006a752a3c [mlir][LLVMIR] Do not create pseudo debug file name using llvm::Instruction
Previously in mlir-translate, if debug info was absent in a
llvm::Instruction, we tried to create one using the name of its defined
value in a textual LLVM IR file as the (pseudo) debug file name.
However, in order to get that name, we need to call out to LLVM's
SlotTracker, which, surprisingly, took a lot of time. Judging from
the usefulness of such pseudo debug file name and the performance penalty
during translation, this patch simply use "imported-bitcode" as the
debug file name in these case. Eliminating the need of using (expensive)
LLVM value numbering.

Differential Revision: https://reviews.llvm.org/D134305
2022-09-21 09:46:58 -07:00
wlei c136d8582b [llvm-profgen] Remove CommaSeparated option from perf file cl
There could be comma in one perf file path, since at this point it only support one file as input, there is no need for the `llvm:🆑:MiscFlags::CommaSeparated` option.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D134287
2022-09-21 09:46:21 -07:00
natashaknk 3e41bec03e [mlir][tosa] Revert added support for dynamic height/weight for pooling in tosa-to-linalg
Partial rollback to D133389

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D134370
2022-09-21 09:29:17 -07:00
Joel E. Denny 387924b307 [lit] Increase FileCheck verbosity temporarily
This is to help debug the failure 28412d1800 caused and f47a5df92d
failed to fix at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10117>
2022-09-21 12:27:45 -04:00
Konstantina 80d3ed6fb1 [NFC][NewGVN] Remove OpIsSafeForPHIOfOpsHelper()
Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D130949
2022-09-21 09:25:59 -07:00
Ashay Rane dfbaf90043
[llvm] prefix linker flag on non-MSVC compilers with `-Wl,`
Prior to this patch, a Windows build of llvm-lto using clang failed with
the error: `LTO.def: unknown file type`.  The reason for this failure is
that .DEF files are used by the linker not by the clang compiler.  The
MSVC compiler+linker handles this transparently, but if we're using
clang (or gcc), then we need to tell the compiler to forward this flag
to the linker. This patch adds the necessary `-Wl` flag to fix the
problem.

Reviewed By: rnk, mstorsjo

Differential Revision: https://reviews.llvm.org/D134165
2022-09-21 11:18:42 -05:00
Akira Hatanaka adaf62ced2 [Sema] Reject array element types whose sizes aren't a multiple of their
alignments

In the following code, the first element is aligned on a 16-byte
boundary, but the remaining elements aren't:

```
typedef char int8_a16 __attribute__((aligned(16)));
int8_a16 array[4];
```

Currently clang doesn't reject the code, but it should since it can
cause crashes at runtime. This patch also fixes assertion failures in
CodeGen caused by the changes in https://reviews.llvm.org/D123649.

Differential Revision: https://reviews.llvm.org/D133711
2022-09-21 09:15:03 -07:00
Joel E. Denny f47a5df92d [lit] Try to fix new test from 28412d1800 under Windows
`llvm/utils/lit/tests/Inputs/shtest-define/value-escaped.txt` broke at
least at <https://lab.llvm.org/buildbot/#/builders/216/builds/10114>.

The problem appears to be a non-portable `echo` command line.
2022-09-21 12:06:41 -04:00
Philip Reames 143f3bf8f4 [SDAG] Split handling of VPLoad/VPGather and VPStore/VPScatter [nfc]
The merged routines are not-idiomatic, and the code sharing that results is prettty minimal.  The confusion factor is not justified.
2022-09-21 09:06:02 -07:00
J. Ryan Stinnett 74f0e64bb9 [LangRef][Docs] Fix RST header length for GC intrinsics
This fixes up the header length which regressed in
8c1a9e3cf3.
2022-09-21 16:53:55 +01:00
Kazu Hirata 0a0ccc85bb [ModuleInliner] Factor out common code in InlineOrder.cpp (NFC)
This patch factors out common code in InlineOrder.cpp.

Without this patch, the model is to ask classes like SizePriority and
CostPriority to compare a pair of call sites:

  bool hasLowerPriority(const CallBase *L, const CallBase *R) const override {

while these priority classes have their own caches of priorities:

  DenseMap<const CallBase *, PriorityT> Priorities;

This model results in a lot of duplicate code like hasLowerPriority
and updateAndCheckDecreased.

This patch changes the model so that priority classes just have two
methods to compute a priority for a given call site and to compare two
previously computed priorities (as opposed to call sites).

Facilities like hasLowerPriority and updateAndCheckDecreased move to
PriorityInlineOrder along with the map from call sites to their
priorities.  PriorityInlineOrder becomes a template class so that it
can accommodate different priority classes.

Differential Revision: https://reviews.llvm.org/D134149
2022-09-21 08:50:30 -07:00
J. Ryan Stinnett 8c1a9e3cf3 [LangRef][Docs] Align RST syntax for GC intrinsics
This changes the GC intrinsics to use the same header styling as the others.
2022-09-21 16:46:33 +01:00
Joel E. Denny 28412d1800 [lit] Implement DEFINE and REDEFINE directives
These directives define per-test lit substitutions.  The concept was
discussed at
<https://discourse.llvm.org/t/iterating-lit-run-lines/62596/10>.

For example, the following directives can be inserted into a test file
to define `%{cflags}` and `%{fcflags}` substitutions with empty
initial values, which serve as the parameters of another newly defined
`%{check}` substitution:

```
// DEFINE: %{cflags} =
// DEFINE: %{fcflags} =

// DEFINE: %{check} = %clang_cc1 %{cflags} -emit-llvm -o - %s | \
// DEFINE:            FileCheck %{fcflags} %s
```

The following directives then redefine the parameters before each use
of `%{check}`:

```
// REDEFINE: %{cflags} = -foo
// REDEFINE: %{fcflags} = -check-prefix=FOO
// RUN: %{check}

// REDEFINE: %{cflags} = -bar
// REDEFINE: %{fcflags} = -check-prefix=BAR
// RUN: %{check}
```

Of course, `%{check}` would typically be more elaborate, increasing
the benefit of the reuse.

One issue is that the strings `DEFINE:` and `REDEFINE:` already appear
in 5 tests.  This patch adjusts those tests not to use those strings.
Our prediction is that, in the vast majority of cases, if a test
author mistakenly uses one of those strings for another purpose, the
text appearing after the string will not happen to have the syntax
required for these directives.  Thus, the test author will discover
the mistake immediately when lit reports the syntax error.

This patch also expands the documentation on existing lit substitution
behavior.

Reviewed By: jhenderson, MaskRay, awarzynski

Differential Revision: https://reviews.llvm.org/D132513
2022-09-21 11:32:05 -04:00
Chris Bieneman bc97751a23 [NFC] Add GitHub issues to HLSL FIXME comments
In order to make this easier to track I've filed issues for each of the
HLSL FIXME comments that I can find. I may have missed some, but I want
this to be the new default mode.
2022-09-21 10:31:25 -05:00
Matt Arsenault 10207fc5ae AMDGPU: Move test to correct location
This is not a MIR printer/parser test, so it belongs with the ordinary
codegen tests.
2022-09-21 11:30:32 -04:00
rkayaith aa00e3e6c1 [mlir][llvm] Support pointer entries in data layout translation
This adds support for pointer DLTI entries in LLVMIR export, e.g.
```
// translated to: p0:32:64:128
#dlti.dl_entry<!llvm.ptr, dense<[32,64,128]> : vector<3xi32>>
// translated to: p1:32:32:32:64
#dlti.dl_entry<!llvm.ptr<1>, dense<[32,32,32,64]> : vector<4xi32>>
```

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D133434
2022-09-21 11:16:15 -04:00
Anders Langlands bc14ed7de0 Add clang_CXXMethod_isDeleted function
Adds a function to check if a method has been deleted by copy-pasting
the existing implementation of clang_CXXMethod_isDefaulted and changing
it to call CXXMethod::isDeleted() instead.

Differential Revision: https://reviews.llvm.org/D133924
2022-09-21 11:12:48 -04:00
bixia1 9f13b9346b [mlir][memref] Add realloc op.
Add memref.realloc and canonicalization of the op. Add conversion patterns for
lowering the op to LLVM using unaligned alloc or aligned alloc based on the
conversion option.

Add filecheck tests for parsing and converting the op. Add an integration test.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D133424
2022-09-21 08:04:00 -07:00
Alexey Bataev e664dea182 [SLP]Fix write-after-bounds.
Mask might be larger than the NumElts-OffsetBeg, need to use actual
indices to avoid acces out of bounds.
2022-09-21 08:00:15 -07:00
Nikita Popov 7652710f9f [InstSimplify] Add additional simplifyWithOpReplaced() vector tests (NFC) 2022-09-21 16:59:28 +02:00
Florian Hahn 53aad7a69a
[llvm-reduce] Update NoChunks initializer to be in line with AllChunks.
Without this patch, the assertion triggers below on the test case,
because we are using different oracles for the verification.

    Assertion failed: (Targets == NoChunksCounter.count() && "number of chunks changes when reducing"), function runDeltaPass, file Delta.cpp, line 272.
2022-09-21 15:50:30 +01:00