500766 Commits

Author SHA1 Message Date
Simon Pilgrim
54b20cbb95
[DAG] computeKnownBits - abds(x, y) will be zero in the upper bits if x and y are sign-extended (#94448)
As reported on #94442 - if x and y have more than one signbit, then the upper bits of its absolute value are guaranteed to be zero

Sibling PR to #94382

Alive2: https://alive2.llvm.org/ce/z/7_z2Vc

Fixes #94442
2024-06-05 11:57:55 +01:00
Christian Ulmann
9b2a349991
[MLIR][ModuleTranslation] Add disableVerification parameter (NFC) (#94445)
This commit adds a boolean parameter that allows downstream users to
disable the verification when translating an MLIR module to LLVM IR.
This is helpful for debugging broken LLVM IR modules post translation.
2024-06-05 12:47:24 +02:00
Nikita Popov
851710d791 [SimplifyCFG] Add additional tests for sinking (NFC)
This covers some interesting edge cases when the sink target is
a loop header.
2024-06-05 12:45:56 +02:00
Benjamin Maxwell
29a925abb6
[mlir][affine][Analysis] Add conservative bounds for semi-affine mods (#93576)
This patch adds support for computing bounds for semi-affine mod
expression to FlatLinearConstraints. This is then enabled within the
ScalableValueBoundsConstraintSet to allow computing the bounds of
scalable remainder loops.

E.g. computing the bound of something like:
```
// `1000 mod s0` is a semi-affine.
#remainder_start_index = affine_map<()[s0] -> (-(1000 mod s0) + 1000)>
#remaining_iterations = affine_map<(d0) -> (-d0 + 1000)>

%0 = affine.apply #remainder_start_index()[%c8_vscale]
scf.for %i = %0 to %c1000 step %c8_vscale {
  %remaining_iterations = affine.apply #remaining_iterations(%i)
  // The upper bound for the remainder loop iterations should be:
  // %c8_vscale - 1  (expressed as an affine map,
  // affine_map<()[s0] -> (s0 * 8 - 1)>, where s0 is vscale)
  %bound = "test.reify_bound"(%remaining_iterations) <{scalable, ...}>
}
```

There are caveats to this implementation. To be able to add a bound for
a `mod` we need to assume the rhs is positive (> 0). This may not be
known when adding the bounds for the `mod` expression. So to handle this
a constraint is added for `rhs > 0`, this may later be found not to hold
(in which case the constraints set becomes empty/invalid).

This is not a problem for computing scalable bounds where it's safe to
assume `s0` is vscale (or some positive multiple of it). But this may
need to be considered when enabling this feature elsewhere (to ensure
correctness).
2024-06-05 11:35:13 +01:00
Tom Eccles
2c31bc7c04
[flang][Semantics][OpenMP] Fix ICE for unknown reduction starting with . (#94398)
In this case the union inside of the `parser::DefinedOperator` contains
a string name instead of the expected
`parser::DefinedOperator::IntrinsicOperator`. This led to a
`std::abort`.

This patch adapts the code so that if it contains a string name we emit
a semantic error.
2024-06-05 11:26:34 +01:00
Florian Hahn
05e1b5340b
[VPlan] Model FOR resume value extraction in VPlan. (#93396)
This patch uses the ExtractFromEnd VPInstruction opcode
to extract the value of a FOR to be used as resume value for the ph in
the scalar loop.

It adds a new live-out that temporarily wraps the FOR phi in the scalar
loop. fixFixedOrderRecurrence will process live outs for fixed order
recurrence phis by creating a new phi node in the scalar preheader, 
using the generated value for the live-out as incoming value from the
middle block and the original start value as incoming value for the
other edge. Creation of the phi in the preheader, as well as updating
the phi in the scalar loop will also be moved to VPlan in the future,
eventually retiring fixFixedOrderRecurrence

Depends on https://github.com/llvm/llvm-project/pull/93395

PR: https://github.com/llvm/llvm-project/pull/93396
2024-06-05 11:18:06 +01:00
Simon Pilgrim
e635520be8
[DAG] computeKnownBits - abs(x) will be zero in the upper bits if x is sign-extended (#94382)
As reported on https://github.com/llvm/llvm-project/issues/94344 - if x has more than one signbit, then the upper bits of its absolute value are guaranteed to be zero

Alive2: https://alive2.llvm.org/ce/z/a87fHU

Fixes #94344
2024-06-05 10:58:54 +01:00
Kerry McLaughlin
043cc5a227
[AArch64][compiler-rt] Add a function returning the current vector length (#92921)
__arm_get_current_vg emits a cntd instruction if in streaming mode or SVE is
available at runtime, otherwise it will return 0.
2024-06-05 10:57:14 +01:00
klensy
42ebf3eaaf
[utils][filecheck-lint]: speedup filecheck_lint (#94191)
For example:
clang\test\OpenMP\task_codegen.cpp:  0m29.570s -> 0m0.159s
clang\test\Driver: 4m55.917s -> 1m48.053s

Most win from big files.

---------

Co-authored-by: klensy <nightouser@gmail.com>
2024-06-05 11:43:32 +02:00
Tom Eccles
7eaae4e6af
[flang][CodeGen][NFC] Reduce PreCGRewrite pass boilerplate (#94329)
The pass constructor can be generated automatically by tablegen.

This pass is module-level and runs on all instances of target operations
inside of it and so does not need any modification to support
alternative top-level operations.
2024-06-05 10:27:06 +01:00
David Green
a07f03f116 [AArch64] Add a test for LSR chain generation with vscale increments. NFC 2024-06-05 10:19:11 +01:00
LLVM GN Syncbot
b8b2a013da [gn build] Port d3a9043ec2ee 2024-06-05 09:14:55 +00:00
Alexey Merzlyakov
d3a9043ec2
[lldb][RISCV] Add RegisterContextPOSIXCore for RISC-V 64 (#93297)
The PR adds the support of CoreDump debugging for RISC-V 64. It
implements new `RegisterContextCorePOSIX_riscv64` class.

Also, the contribution fixes `GetRegisterCount()` ->
`GetRegisterSetCount()` misprint in
`RegisterContextPOSIX_riscv64::GetRegisterSetCount()` method, which
leaded to `set && "Register set should be valid."` assertion during
`register info aX` command call.

The patch was tested (on coredumps generated for simple Integer/FP
calculation code) for _cross x86_64 -> RISCV_ and _native RISCV_ LLDB
builds. There were performed basic LLDB functionality tests, such as:

 - CoreDump file load
 - Backtrace / frames
 - GP/FP registers read/info/list
 - Basic switch between threads
 - Disassembler code
 - Memory regions read / display
2024-06-05 10:14:48 +01:00
Kai Luo
8ab578a126 [PowerPC] Add test of non-zero addend in tocdata relocation. NFC.
It intends to check if IAS handles non-zero addend correctly.
2024-06-05 08:55:57 +00:00
Nikita Popov
775ebc1d71 [SimplifyCFG] Regenerate test checks (NFC) 2024-06-05 10:31:46 +02:00
Marco Borgeaud
04a02c1b88
[ASTMatchers] forCallable should not erase binding on success (#89657)
Do not erase Builder when the first check fails because it could succeed
on the second stack frame.

The problem was that `InnerMatcher.matches` erases the bindings when it
returns false. The appropriate solution is to pass a copy of the
bindings, similar to what `matchesFirstInRange` does.
2024-06-05 10:20:37 +02:00
Hsiangkai Wang
419e7b8256
[NFC] Clean up TestLinalgGreedyFusion (#94430)
Linalg fusion-on-memrefs are removed in dc37dc824aabbbe. There is
nothing being inserted in the erase set. Remove the useless code.
2024-06-05 09:10:47 +01:00
Stanislav Mekhanoshin
c8c3b8b2bb
[AMDGPU] Move flat patterns instantiation down. NFC. (#94409)
I want to reuse some of the global patterns for the flat, so move
instantiation past the declarations.
2024-06-05 00:59:06 -07:00
Vyacheslav Levytskyy
37cf0473ad
[SPIR-V] Introduce support of '__spirv_' wrapper builtins for the SPV_INTEL_subgroups extension (#94235)
This PR Introduces support of '__spirv_' wrapper builtins for the
SPV_INTEL_subgroups extension.
2024-06-05 09:57:23 +02:00
Vyacheslav Levytskyy
6d4fb3d3bb
[SPIR-V] Emit valid SPIR-V code for integer sizes other than 8,16,32,64 (#94219)
Only with SPV_INTEL_arbitrary_precision_integers SPIR-V Backend creates
arbitrary sized integer types (<= 64 bits). Without such extension and
according to the SPIR-V specification
`SPIRVGlobalRegistry::getOpTypeInt()` rounds integer sizes other than
8,16,32,64 up, to one of defined by the specification sizes. For the
`DuplicateTracker` class this means that several original LLVM types
(e.g., i2, i4) map to the same "OpTypeInt 8" instruction. This breaks
`DuplicateTracker`'s logic and leads to generation of invalid SPIR-V
code eventually.

For example,

```
define spir_func void @foo(i2 %a, i4 %b) {
entry:
  %res2 = tail call i2 @llvm.bitreverse.i2(i2 %a)
  %res4 = tail call i4 @llvm.bitreverse.i4(i4 %b)
  ret void
}

declare i2 @llvm.bitreverse.i2(i2)
declare i4 @llvm.bitreverse.i4(i4)
```

after translation to SPIR-V would fail during validation (`spirv-val`)
due to two `OpTypeInt 8 0` instructions.

This PR fixes the issue by changing source LLVM type according to the
SPIR-V type that will be used in the emitted code.
2024-06-05 09:56:52 +02:00
tpenge
0977504537
Update Security.rst with github username tpenge (#94404)
Add username for LLVM Security Group member
2024-06-05 09:18:46 +02:00
Nikita Popov
a87ff8db26
[SROA] Remove sroa-strict-inbounds option (NFC) (#94342)
This option was added in 3b79b2ab4e35353e63ba323a3de4b0a70c61a5f1 with
the comment:

> I had SROA implemented this way a long time ago and due to the
> overwhelming bugs that surfaced, moved to a much more relaxed
> variant. Richard Smith would like to understand the magnitude
> of this problem and it seems fairly harmless to keep some
> flag-controlled logic to get the extremely strict behavior here.
> I'll remove it if it doesn't prove useful.

As far as I know, it did not prove useful, so I'm removing it now.

With constant GEPs canonicalized to i8, GEPs that only temporarily go
out of bounds during the offset calculation do not naturally occur
anymore anyway.
2024-06-05 09:18:13 +02:00
Leandro Lupori
79b1137666
[flang] Fix build on Darwin after #92571 (#94327)
flang/runtime/time-intrinsic.cpp:403:19: error: comparison of
integers of different signs: 'clock_t' (aka 'unsigned long') and
'int' [-Werror,-Wsign-compare]
  if (times(&tms) != -1) {
2024-06-05 08:58:56 +02:00
LLVM GN Syncbot
9760be0276 [gn build] Port 6b755b0cf4dd 2024-06-05 05:51:08 +00:00
Vlad Serebrennikov
6b755b0cf4
[clang] Split up SemaDeclAttr.cpp (#93966)
This patch moves language- and target-specific functions out of
`SemaDeclAttr.cpp`. As a consequence, `SemaAVR`, `SemaM68k`,
`SemaMSP430`, `SemaOpenCL`, `SemaSwift` were created (but they are not
the only languages and targets affected).

Notable things are that `Sema.h` actually grew a bit, because of
templated helpers that rely on `Sema` that I had to make available from
outside of `SemaDeclAttr.cpp`. I also had to left CUDA-related in
`SemaDeclAttr.cpp`, because it looks like HIP is building up on top of
CUDA attributes.

This is a follow-up to #93179 and continuation of efforts to split
`Sema` up. Additional context can be found in #84184 and #92682.
2024-06-05 09:46:37 +04:00
Shengchen Kan
e282118f47 [X86][TTI] Update the return value of X86TTIImpl::getNumberOfRegisters for EGPR 2024-06-05 13:45:01 +08:00
LLVM GN Syncbot
c5dd10ba3a [gn build] Port 68716573b627 2024-06-05 04:59:09 +00:00
c8ef
68716573b6
[ADT] refactor MoveOnly type in ADT unittest (#94421)
context:
https://github.com/llvm/llvm-project/pull/94151#pullrequestreview-2097098530
2024-06-04 21:58:45 -07:00
Serge Pavlov
c0bb16eaf7
Revert "[symbolizer] Empty string is not an error" (#94424)
Reverts llvm/llvm-project#92660

It needs more discussion.
2024-06-05 11:39:23 +07:00
Kareem Ergawy
7db4e6c1ec
[OpenMP][LLVM] Update alloca IP after PrivCB in OMPIRBUIlder (#93920)
Fixes a crash uncovered by
[pr77666.f90](https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/gomp/pr77666.f90)
in the test suite when delayed privatization is enabled by default.

In particular, whenever `PrivCB` (the callback responsible for
generating privatizaiton logic for an OMP variable) generates a
multi-block privatization region, the insertion point diverges: the BB
component of the IP can become a different BB from the parent block of
the instruction iterator component of the IP. This PR updates the IP to
make sure that the BB is the parent block of the instruction iterator.
2024-06-05 05:13:47 +02:00
Shengchen Kan
d1a0605337
[X86][CodeGen] Support using NF instructions for flag copy lowering (#93508) 2024-06-05 10:08:47 +08:00
Feng Zou
627463dc39
[X86][FP16] Limit combination of fp_round & concat to concat of 2 operands (#94302)
Add check of number of operands for concat_vectors being equal to 2.
This can
avoid crash if there are more than 2 operands for concat_vectors and
operand 0 & 1 are undef value.
2024-06-05 10:08:28 +08:00
Phoebe Wang
99b2581a4b
Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (#88245)
This is a second try to reland
https://github.com/llvm/llvm-project/pull/87149.

The previous commit exposed failures on some targets. The reason is only
a few targets support COFF ObjectFormatType on Windows:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842

With https://github.com/llvm/llvm-project/pull/87149, the targets don't
support COFF will report "warning: argument unused during compilation:
'-gcodeview-command-line' [-Wunused-command-line-argument]" in the test
gcodeview-command-line.c

I was thinking `REQUIRES: *-registered-target` could solve the problem,
but it didn't. We need to check the actual triple instead of just
`*-registered-target`.
2024-06-05 09:56:08 +08:00
Eric Fiselier
e34f9567c4 Remove act from builder image. It never turned out to be useful 2024-06-04 21:12:31 -04:00
Fangrui Song
dd82fd4744 [Xtensa] Fix Clang warnings after #92960 2024-06-04 16:47:28 -07:00
Fangrui Song
85daa95b18 [MC] Ensure UseAssemblerInfoForParsing is true upon return
Fixes: 5ee580bbfb11d781c220c19416c1a97b657e039a

5ee580bbfb11d781c220c19416c1a97b657e039a does not ensure that
UseAssemblerInfoForParsing is re-enabled. This is benign but not good.
2024-06-04 16:39:18 -07:00
Maksim Panchenko
c923d39509
[BOLT] Fix ValidateMemRefs pass (#94406)
In ValidateMemRefs pass, when we validate references in the form of
`Symbol + Addend`, we should check `Symbol` not `Symbol + Addend`
against aliasing a jump table.

Recommitting with a modified test case:
https://github.com/llvm/llvm-project/pull/88838

Co-authored-by: sinan <sinan.lin@linux.alibaba.com>
2024-06-04 16:12:29 -07:00
PiJoules
330e8a7619
[libc][stdlib] Add calloc header (#94403) 2024-06-04 15:51:53 -07:00
Joachim Meyer
8896f21ca9
[NFC] Fix typo in libc/docs/gpu/using.rst 2024-06-04 15:40:45 -07:00
Philip Reames
0360d03240 [SCEV] Add coverage for howFarToZero with stride=VF*vscale 2024-06-04 15:38:50 -07:00
Slava Zakharin
e42864ecfb [flang] Fixed buildbots: removed std::move preventing copy elision. 2024-06-04 15:31:39 -07:00
OverMighty
6b5ae148e5
[libc][math][c23] Add {fromfp,fromfpx,ufromfp,ufromfpx}f16 C23 math functions (#94254)
https://github.com/llvm/llvm-project/issues/93566
2024-06-04 18:29:53 -04:00
Slava Zakharin
ae4f300133
[flang] Canonicalize fir.array_coor by pulling in embox/rebox. (#92858)
In a simple case like this:
```
program test
  integer :: u(120, 2)
  u(1:120,1:2) = u(1:120,1:2) + 2
end program
```
Flang is creating a copy loop with fir.array_coor using
a result of fir.embox inserted before the loop. This results in split
address computations before and inside the loop, which can be seen
as many more arithmetic operations than required after converting
FIR to LLVM dialect. Even though LLVM SROA/mem2reg are able
to optimize the temporary descriptor, and then LICM is able to hoist
the invariant computations, we seem to get better mix of LLVM dialect
operations after FIR-to-LLVM codegen. This may also slightly reduce
the compilation time taken by LLVM to optimize the generate LLVM IR.
This may also slightly reduce the time spent by FIR AliasAnalysis
to reach the memory reference source.
2024-06-04 15:21:19 -07:00
Fangrui Song
cb09b5f3d5 [MC] Disable MCAssembler based constant folding for compact unwind and emitJumpTableEntry
Similar to commit 245491a9f384e4c53421196533c2a2b693efaf8d for DwarfDebug.

This completely disables the expensive MCFragment walk code in
`AttemptToFoldSymbolOffsetDifference` when compiling sqlite3.i for
macOS.

In the future, we should try enabling the MCFragment walk only for
constructs like `.if . -_start == 1` and `.subsection a-b` and
remove these `setUseAssemblerInfoForParsing`.
2024-06-04 15:06:12 -07:00
Florian Hahn
e949b54a5b
[LAA] Use PSE::getSymbolicMaxBackedgeTakenCount. (#93499)
Update LAA to use PSE::getSymbolicMaxBackedgeTakenCount which returns
the minimum of the countable exits.

When analyzing dependences and computing runtime checks, we need the
smallest upper bound on the number of iterations. In terms of memory
safety, it shouldn't matter if any uncomputable exits leave the loop,
as long as we prove that there are no dependences given the minimum of
the countable exits. The same should apply also for generating runtime
checks.

Note that this shifts the responsiblity of checking whether all exit
counts are computable or handling early-exits to the users of LAA.

Depends on https://github.com/llvm/llvm-project/pull/93498

PR: https://github.com/llvm/llvm-project/pull/93499
2024-06-04 22:23:30 +01:00
Michael Buch
afe6ab7586
[lldb][DebugNames] Only skip processing of DW_AT_declarations for class/union types (#94400)
This is a follow-up of
https://github.com/llvm/llvm-project/pull/92328#issuecomment-2145849441

Clang attaches `DW_AT_declaration` to static inline data members and
`dsymutil` indexes these constants. Skipping these caused the expression
evaluator to fail to find such constants when using DWARFv5.

Fixes `TestConstStaticIntegralMember.py` on DWARFv5.
2024-06-04 22:17:51 +01:00
Michael Christensen
679f75e24b
[easy] Fix spacing in help message of 'process save-core' command (#89445)
Very minor change to help message on `process save-core`. Adds space
between two sentences explaining the `-p` option:

"Specify a plugin name to create the core file.This allows core files to
be saved in different formats."
-->
"Specify a plugin name to create the core file. This allows core files
to be saved in different formats."

Before:
```
(lldb) help process save-core
Save the current process as a core file using an appropriate file type.

Syntax: process save-core [-s corefile-style -p plugin-name] FILE

Command Options Usage:
  process save-core [-p[<plugin>]] [-s <corefile-style>] <path>

       -p[<plugin>] ( --plugin-name=[<plugin>] )
            Specify a plugin name to create the core file.This allows core files to be saved in different formats.

       -s <corefile-style> ( --style <corefile-style> )
            Request a specific style of corefile to be saved.
            Values: full | modified-memory | stack

     This command takes options and free-form arguments.  If your arguments resemble option specifiers (i.e., they start with a -
     or --), you must use ' -- ' between the end of the command options and the beginning of the arguments.
```

After:
```
michristensen@devbig356 build/Debug » $HOME/llvm-sand/build/Debug/bin/lldb -x
(lldb) help process save-core
Save the current process as a core file using an appropriate file type.

Syntax: process save-core [-s corefile-style -p plugin-name] FILE

Command Options Usage:
  process save-core [-p[<plugin>]] [-s <corefile-style>] <path>

       -p[<plugin>] ( --plugin-name=[<plugin>] )
            Specify a plugin name to create the core file. This allows core files to be saved in different formats.

       -s <corefile-style> ( --style <corefile-style> )
            Request a specific style of corefile to be saved.
            Values: full | modified-memory | stack

     This command takes options and free-form arguments.  If your arguments resemble option specifiers (i.e., they start with a -
     or --), you must use ' -- ' between the end of the command options and the beginning of the arguments.
```
2024-06-04 14:02:41 -07:00
Min-Yih Hsu
cd3255abed
[gold] Enable time trace profiler in LLVMgold (#94293)
To get the time trace of LTO in the gold plugin, now we can pass the
`time-trace=<time trace file>` as well as
`time-trace-granularity=<granularity>` flags to LLVMgold.

Note that we still have to populate `LTOConfig::TimeTraceEnabled` and
`LTOConfig::TimeTraceGranularity` because ThinLTO backend needs them.
2024-06-04 14:01:15 -07:00
Arthur Eubanks
eca9caf419 [LazyCallGraph] Assert in removeDeadFunction() that NodeMap contains function
The function should always be known to LazyCallGraph
2024-06-04 20:35:33 +00:00
Keith Smiley
2e0e163bb5
[bazel] Port #94109 (#94395) 2024-06-04 13:08:48 -07:00