Commit Graph

533017 Commits

Author SHA1 Message Date
Ilya Biryukov
da69eb75cb [NFC] [ASTMatchers] Share code of forEachArgumentWithParamType with UnsafeBufferUsage (#132387)
This changes exposes a low-level helper that is used to implement
`forEachArgumentWithParamType` but can also be used without matchers,
e.g. if performance is a concern.

Commit f5ee10538b introduced a copy of the
implementation of the `forEachArgumentWithParamType` matcher that was
needed for optimizing performance of `-Wunsafe-buffer-usage`.

This change shares the code between the two so that we do not repeat
ourselves and any bugfixes or changes will be picked up by both
implementations in the future.
2025-04-04 14:35:15 +02:00
Ilya Biryukov
d02786e778 [Sema] Handle AttributedType in template deduction with derived-to-base conversions (#134361)
Fix #134356.

We accidentally skipped checking derived-to-base conversions because
deduction did not strip sugar in the relevant code. This caused
deduction failures when a parameter type had an attribute.
2025-04-04 14:23:55 +02:00
Baranov Victor
547d054ef1 [clang-tidy][NFC][doc] improve "options" sections of misc-, cppcore- and other checks (#133694)
Improved "options" sections of various checks:

1. Added Options keyword to be a delimiter between "body" and "options"
parts of docs
2. Added default values where were absent.
3. Changed double-tick to single-tick in default values.

---------

Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
2025-04-04 14:21:48 +02:00
Zahira Ammarguellat
babbc6f842 [NFC] Fixes proposed by code sanitizer. (#134138) 2025-04-04 08:04:16 -04:00
Vy Nguyen
a2e888f5b4 [LLDB][NFC]Fix stack-use-after free bug. (#134296)
Details: detailed_command_telemetry (bool) and command_id (int) could
already be freed when the dispatcher's dtor runs. So we should just copy
them into the lambda since they are cheap.
2025-04-04 08:00:46 -04:00
JaydeepChauhan14
0d17547879 [X86][NFC] Added POWI function testcases (#134276)
- Moved existing llvm/test/CodeGen/X86/powi.ll file to
  llvm/test/CodeGen/X86/powi-const.ll.
- Added new testcases for powi into llvm/test/CodeGen/X86/powi.ll.
2025-04-04 13:42:20 +02:00
Paul Walker
b0b97e3b05 [LLVM][AArch64] Refactor lowering of fixed length integer setcc operations. (#132434)
The original code is essentially performing isel during legalisation
with the AArch64 specific nodes offering no additional value compared to
ISD::SETCC.
2025-04-04 12:13:45 +01:00
Sergio Afonso
a17d49687a [Flang][Driver][AMDGPU] Fix -mcode-object-version (#134230)
This patch updates flang to follow clang's behavior when processing the
`-mcode-object-version` option.

It is now used to populate an LLVM module flag called
`amdhsa_code_object_version` expected by the backend and also updates
the driver to add the `--amdhsa-code-object-version` option to the
frontend invocation for device compilation of AMDGPU targets.
2025-04-04 11:54:49 +01:00
Vladi Krapp
a9a7b711e4 [ARM][NFC] Remove lines unnecessary for test (#134359) 2025-04-04 11:51:18 +01:00
Florian Hahn
2bdc1a1337 [LV] Use frozen start value for FindLastIV if needed. (#132691)
FindLastIV introduces multiple uses of the start value, where in the
original source there was only a single use, when the epilogue is
vectorized.

Each use of undef may produce a different result, so introducing
multiple uses can produce incorrect results when the input is
undef/poison.

If the start value may be undef or poison, freeze it and use the frozen
value, which will be the same at all uses.

See the following scenarios in Alive2:
* Both main and epilogue vector loops execute, go to exit block: https://alive2.llvm.org/ce/z/_TSvRr
* Both main and epilogue vector loops execute, go to scalar loop: https://alive2.llvm.org/ce/z/CsPj5v
* Only epilogue vector loop executes, go to exit block: https://alive2.llvm.org/ce/z/5XqkNV
* Only epilogue vector loop executes, go to scalar loop: https://alive2.llvm.org/ce/z/JUpqRN

The latter 2 show requiring freezing the resume phi. That means we cannot freeze 
in the preheader. We could move the freeze to the main iteration count check, but
that would be a bit fragile to find and other transforms can sink the freeze if needed.


Depends on https://github.com/llvm/llvm-project/pull/132689
and https://github.com/llvm/llvm-project/pull/132690.

Fixes https://github.com/llvm/llvm-project/issues/126836

PR: https://github.com/llvm/llvm-project/pull/132691
2025-04-04 11:48:01 +01:00
Jerry-Ge
d6c076eeaa [mlir][tosa] Reorder Tosa_ExtensionAttrs to match with definition order (#134319)
Simple refactor change.

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-04 11:33:52 +01:00
Durgadoss R
a03b2250db [NVPTX][Docs] [NFC] Update docs on intrinsics (#133136)
Recently, we have added a set of complex intrinsics on
the TMA, tcgen05, and Cvt family of instructions.

This patch captures the key learnings from our experience
so far and documents them as guidelines for future design.

Signed-off-by: Durgadoss R <durgadossr@nvidia.com>
2025-04-04 15:39:25 +05:30
Alaa Ali
5812516ae2 [MLIR] Fix canonicalization pattern for 'shape.shape_of' (#134234)
This PR will fix a bug in a canonicalization pattern (operation
shape.shape_of: shape of reshape)

```
// Before
func.func @f(%arg0: tensor<?x1xf32>, %arg1: tensor<3xi32>) -> tensor<3xindex> {
  %reshape = tensor.reshape %arg0(%arg1) : (tensor<?x1xf32>, tensor<3xi32>) -> tensor<?x1x1xf32>
  %0 = shape.shape_of %reshape : tensor<?x1x1xf32> -> tensor<3xindex>
  return %0 : tensor<3xindex>
}
//This is will error out as follows:
error: 'tensor.cast' op operand type 'tensor<3xi32>' and result type 'tensor<3xindex>' are cast incompatible
  %0 = shape.shape_of %reshape : tensor<?x1x1xf32> -> tensor<3xindex>
       ^
note: see current operation: %0 = "tensor.cast"(%arg1) : (tensor<3xi32>) -> tensor<3xindex>
```

```
// After
func.func @f(%arg0: tensor<?x1xf32>, %arg1: tensor<3xi32>) -> tensor<3xindex> {
  %0 = arith.index_cast %arg1 : tensor<3xi32> to tensor<3xindex>
  return %0 : tensor<3xindex>
}
```
See file canonicalize.mlir in the change list for an example.

For the context, this bug was found while running a test on Keras 3, the
canonicalizer errors out due to an invalid tensor.cast operation when
the batch size is dynamic.
The operands of the op are tensor<3xi32> cast to tensor<3xindex>.
This change is related to a previous PR:
https://github.com/llvm/llvm-project/pull/98531

---------

Co-authored-by: Alaa Ali <alaaali@ah-alaaali-l.dhcp.mathworks.com>
Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2025-04-04 11:46:58 +02:00
gbMattN
4da5e9dd32 [ASan] Fix shadowed-stack-serialization test on targets with different stack layout 2025-04-04 10:41:00 +01:00
Florian Hahn
a4573ee38d [LoopUnroll] UnrollRuntimeMultiExit takes precedence over TTI. (#134259)
Update UnrollRuntimeLoopRemainder to always give priority to the
UnrollRuntimeMultiExit option, if provided.

After ad9da92cf6 (https://github.com/llvm/llvm-project/pull/124462),
we would ignore the option if the backend indicates multi-exit is profitable.
This means it cannot be used to disable runtime unrolling.

To be consistent with canProfitablyRuntimeUnrollMultiExitLoop, always
respect the option.

This surfaced while discussing https://github.com/llvm/llvm-project/pull/131998.

PR: https://github.com/llvm/llvm-project/pull/134259
2025-04-04 10:16:50 +01:00
Tobias Stadler
1302610f03 [MergeFunc] Fix crash caused by bitcasting ArrayType (#133259)
createCast in MergeFunctions did not consider ArrayTypes, which results
in the creation of a bitcast between ArrayTypes in the thunk function,
leading to an assertion failure in the provided test case.

The version of createCast in GlobalMergeFunctions does handle
ArrayTypes, so this common code has been factored out into the
IRBuilder.
2025-04-04 10:16:40 +01:00
Adrian Kuegel
c154d66339 [mlir] Apply ClangTidyBugProne finding (NFC).
argument name 'outputType' in comment does not match parameter name 'outputTypes'
2025-04-04 09:01:56 +00:00
Igor Wodiany
9eb7e64145 [mlir][spirv] Add verification for Bias operand (#134231) 2025-04-04 09:41:54 +01:00
David Sherwood
aaf398c2e7 [AArch64] Regenerate apple-unrolling-multi-exit.ll test checks (#134257) 2025-04-04 09:03:49 +01:00
Vladi Krapp
f528a80d3e [Arm] Add more -mtp=cp15 tests (#134098)
This patch systematically covers all -mtp=cp15 behaviour options for
better code coverage.
2025-04-04 08:55:35 +01:00
Pavel Labath
e4f76e3a33 Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " (#134246)
This reverts commit 094904303d, reapplying
d7afafdbc4 (#133247).

The failure ought to be fixed by
0509932bb6.
2025-04-04 09:49:27 +02:00
Mariya Podchishchaeva
22130ca486 [MS][clang] Fix crash on deletion of array of pointers (#134088)
Sometimes a non-array delete is treated as delete[] when input pointer
is pointer to array. With vector deleting destructors support we now
generate a virtual destructor call instead of simple loop over the
elements. This patch adjusts the codepath that generates virtual call to
expect the case of pointer to array.
2025-04-04 09:37:28 +02:00
Mats Jun Larsen
78a4b9d9b4 [polly] Prefer PointerType::get with LLVMContext over Type (NFC) (#133868)
Part of #123569
2025-04-04 07:18:13 +00:00
Mats Jun Larsen
d579622b1e [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (#133871)
Part of #123569
2025-04-04 07:18:01 +00:00
Iris
92923e517c [mlir][llvm] Add LLVM_DependentLibrariesAttr (#133385)
https://llvm.org/docs/LangRef.html#dependent-libs-named-metadata

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
2025-04-04 08:00:04 +02:00
Fangrui Song
92c93f5286 [MC] Merge MCAsmLexer and AsmLexer
Follow-up to #134207

Both classes define `IsAtStartOfStatement` but the semantics are
confusingly different. Rename the base class one.
2025-04-03 22:11:49 -07:00
cmtice
46e2c07fa2 [LLDB] Add DIL code for handling plain variable names. (#120971)
Add the Data Inspection Language (DIL) implementation pieces for
handling plain local and global variable names.

See https://discourse.llvm.org/t/rfc-data-inspection-language/69893 for
information about DIL.

This change includes the basic AST, Lexer, Parser and Evaluator pieces,
as well as some tests.
2025-04-03 21:39:30 -07:00
Kareem Ergawy
6333f8457c [flang][OpenMP] Move reductions from loop to teams when loop is mapped to distribute (#132920)
Follow-up to #132003, in particular, see
https://github.com/llvm/llvm-project/pull/132003#issuecomment-2739701936.

This PR extends reduction support for `loop` directives. Consider the
following scenario:
```fortran
subroutine bar
  implicit none
  integer :: x, i

  !$omp teams loop reduction(+: x)
  DO i = 1, 5
    call foo()
  END DO
end subroutine
```
Note the following:
* According to the spec, the `reduction` clause will be attached to
`loop` during earlier stages in the compiler.
* Additionally, `loop` cannot be mapped to `distribute parallel for` due
to the call to a foreign function inside the loop's body.
* Therefore, `loop` must be mapped to `distribute`.
* However, `distribute` does not have `reduction` clauses.
* As a result, we have to move the `reduction`s from the `loop` to its
parent `teams` directive, which is what is done by this PR.
2025-04-04 06:20:51 +02:00
Jacob Lalonde
8e7d6baf0e Revert "[LLDB] Expose checking if the symbol file exists/is loaded via SBModule" (#134341)
Reverts llvm/llvm-project#134163

Reverting while @clayborg and I come up with a better API
2025-04-03 20:45:55 -07:00
Phoebe Wang
897f9a51b9 [X86][AVX10.2] Replace nepbh with bf16 to match with others, NFCI (#134240) 2025-04-04 11:27:39 +08:00
Fangrui Song
c9f6d26e04 [MC] Merge MCAsmLexer.{h,cpp} into AsmLexer.{h,cpp} (#134207)
2b11c7de4a introduced
`llvm/include/llvm/MC/MCAsmLexer.h` and made `AsmLexer` inherit from
`MCAsmLexer`, likely to allow target-specific parsers to depend solely
on `MCAsmLexer`. However, this separation now seems unnecessary and
confusing.

`MCAsmLexer` defines virtual functions with `AsmLexer` as its only
implementation, and `AsmLexer` itself has few extra public methods.

To simplify the codebase, this change merges MCAsmLexer.{h,cpp} into
AsmLexer.{h,cpp}. MCAsmLexer.h is temporarily kept as a forwarder.

Note: I doubt that a downstream lexer handling an assembly syntax
significantly different from the standard GNU Assembler syntax would
want to inherit from `MCAsmLexer`. Instead, it's more likely they'd
extend `AsmLexer` by adding new states and modifying its internal logic,
as seen with variables for MASM, M68k, and HLASM.
2025-04-03 19:22:45 -07:00
NAKAMURA Takumi
4088c70f4e CGHLSLBuiltins.cpp: Suppress a warning in #131237 [-Wunused-variable] 2025-04-04 11:05:46 +09:00
Mircea Trofin
4532512f6c [ctxprof] Move MoveSymbolGUID to address dependency issues (#134334)
See PR #134192
2025-04-03 19:02:46 -07:00
Mircea Trofin
2146826169 [ctxprof] Support for "move" semantics for the contextual root (#134192)
This PR finishes what PR #133992 started.
2025-04-03 18:36:45 -07:00
Rodrigo Rocha
b9891715af [BOLT] Handle generation of compare and jump sequences (#131949)
This patch fixes the following two issues with the createCmpJE for
AArch64:
1. Avoids overwriting the value of the input register RegNo by use XZR
as the destination register.
   subs xzr, RegNo, #Imm
   which is equivalent to a simple
   cmp RegNo, #Imm
2. The immediate operand to the Bcc instruction must be EQ instead of
#Imm.

This patch also adds a new function for createCmpJNE and unit tests for
the both createCmpJE and createCmpJNE for X86 and AArch64.
2025-04-03 18:34:24 -07:00
Sudharsan Veeravalli
ae5306f30e [RISCV] Add symbol parsing support for the Xqcibi branch immediate instructions (#134233)
This patch adds support for parsing symbols in the Xqcibi branch
immediate instructions. While the 32 bit branch instructions use the
same instruction format and relocation as the existing branch
instructions in RISCV, the 48 bit ones use the `InstFormatQC_EB`
instruction format and the `R_RISCV_QC_E_BRANCH` relocation that is
defined in `BinaryFormat/ELFRelocs/RISCV_nonstandard.def.`

Vendor relocation support will be added in a later patch.
2025-04-04 06:57:21 +05:30
Jerry-Ge
7d05c2326c [mlir][tosa] Remove extra trailing whitespace (#134290)
Trivial change.

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-03 18:15:39 -07:00
Jerry-Ge
fcfbef5582 [mlir][tosa] Remove extra declarations of MulOperandsAndResultElementType in TosaOps.td (#134300)
Minor code cleanup

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-03 18:15:30 -07:00
Slava Zakharin
65b85bf8bc [flang] Fixed driver link LIT test for PPC targets. (#134320)
After #131041, the F128 libraries are not linked for PPC targets even
when the driver is built with FLANG_RUNTIME_F128_MATH_LIB.
2025-04-03 16:58:11 -07:00
Michael Jones
c0079ba3dd [libc] Make utimes_test more stable (#134321)
The test for utimes added in #134167 might fail if the file for one test
hasn't been cleaned up by the OS before the second test starts. This
patch makes the tests use different files.
2025-04-03 16:53:55 -07:00
Jorge Gorbe Moya
ee1ee1144a Fix unused variable warning in non-debug build after 7d3dfc862d (NFC) 2025-04-03 16:50:19 -07:00
Alex MacLean
ba0a52a04b [InferAS] Support getAssumedAddrSpace for Arguments for NVPTX (#133991) 2025-04-03 16:47:36 -07:00
Aditya Tejpaul
d33ae41c62 [libc] Implemented utimes (Issue #133953) (#134167)
This pull request implements the `utimes` command in libc ([Issue
#133953](https://github.com/llvm/llvm-project/issues/133953)).

- [x] Add the implementation of `utimes` in `/src/sys/time`.
- [x] Add tests for `utimes` in `/test/src/sys/time`. 
- [x] Add `utimes` to
[entrypoints.txt](https://github.com/llvm/llvm-project/blob/main/libc/config/linux/x86_64/entrypoints.txt)
for at least x86_64 and whatever you're building on
- [x] Add `utimes` to
[include/sys/time.yaml](https://github.com/llvm/llvm-project/blob/main/libc/include/sys/time.yaml)
2025-04-03 16:19:12 -07:00
Ian Anderson
bd197ca003 [clang][modules] Determine if the SDK supports builtin modules independent of the target (#134005)
Whether the SDK supports builtin modules is a property of the SDK
itself, and really has nothing to do with the target. This was already
worked around for Mac Catalyst, but there are some other more esoteric
non-obvious target-to-sdk mappings that aren't handled. Have the SDK
parse its OS out of CanonicalName and use that instead of the target to
determine if builtin modules are supported.
2025-04-03 16:09:57 -07:00
modiking
9f2feeb189 [mlir][gpu][nvptx] Remove null terminator when outputting PTX (#133019)
PTX source files are expected to only contain ASCII text
(https://docs.nvidia.com/cuda/parallel-thread-execution/#source-format) and no null terminators.

`ptxas` has so far not enforced this but is moving towards doing so.
This revealed a problem where the null terminator is getting printed out
in the output file in MLIR path when outputting ptx directly. Only add the null on the assembly output path for JIT instead of in output of `moduleToObject `.
2025-04-03 15:50:54 -07:00
Jason Molenda
f1c6612202 [lldb][debugserver] Save and restore the SVE/SME register state (#134184)
debugserver isn't saving and restoring the SVE/SME register state around
inferior function calls.

Making arbitrary function calls while in Streaming SVE mode is generally
a poor idea because a NEON instruction can be hit and crash the
expression execution, which is how I missed this, but they should be
handled correctly if the user knows it is safe to do.

Re-landing this change after fixing an incorrect behavior on systems
without SME support.

rdar://146886210
2025-04-03 15:48:54 -07:00
Louis Dionne
2cd8edd1ff [libc++] Add missing release note for LLVM 20 about zip_view (#134144)
We should have had a release note in LLVM 20 about implementing P2165R4
since that is technically an ABI and API break for zip_view. We don't
expect anyone to actually hit the ABI issue, but we've come across some
(fairly small) breakage due to the API change, so this should at least
be mentioned in the release notes.
2025-04-03 18:34:49 -04:00
Andre Kuhlenschmidt
b11eece1bb [flang][intrinsics] Implement the time intrinsic (#133823)
This PR implements the nonstandard intrinsic time.

In addition to running the unit tests, I also double checked that the
example code works by manually compiling and running it.
2025-04-03 15:33:40 -07:00
Sumit Agarwal
996cf5dc67 [HLSL] Implement dot2add intrinsic (#131237)
Resolves #99221 
Key points: For SPIRV backend, it decompose into a `dot` followed a
`add`.

- [x] Implement dot2add clang builtin,
- [x] Link dot2add clang builtin with hlsl_intrinsics.h
- [x] Add sema checks for dot2add to CheckHLSLBuiltinFunctionCall in
SemaHLSL.cpp
- [x] Add codegen for dot2add to EmitHLSLBuiltinExpr in CGBuiltin.cpp
- [x] Add codegen tests to clang/test/CodeGenHLSL/builtins/dot2add.hlsl
- [x] Add sema tests to clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
- [x] Create the int_dx_dot2add intrinsic in IntrinsicsDirectX.td
- [x] Create the DXILOpMapping of int_dx_dot2add to 162 in DXIL.td
- [x] Create the dot2add.ll and dot2add_errors.ll tests in
llvm/test/CodeGen/DirectX/
2025-04-03 16:23:09 -06:00
Jorge Gorbe Moya
109566a3d0 [bazel] Fold "${Target}Analysis" targets into their respective CodeGen targets. (#134312)
After 3801bf6164, SPIRVAnalysis needs to
include SPIRV.h provided by SPIRVCodegen, but the CodeGen target already
depends on Analysis, so that would cause a circular dependency.

Analysis is a subdirectory of CodeGen so it makes sense as a part of the
main CodeGen target too.
2025-04-03 15:21:26 -07:00