533887 Commits

Author SHA1 Message Date
Maksim Levental
c12cb0ccbb
[mlir][python] fix value-builder generation for snake_case ops (#135302)
Ops that are already snake case (like [`ROCDL_wmma_*`
ops](66b0b0466b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td (L411)))
produce python "value-builders" that collide with the class names:

```python
class wmma_bf16_16x16x16_bf16(_ods_ir.OpView):
  OPERATION_NAME = "rocdl.wmma.bf16.16x16x16.bf16"
  ...

def wmma_bf16_16x16x16_bf16(res, args, *, loc=None, ip=None) -> _ods_ir.Value:
  return wmma_bf16_16x16x16_bf16(res=res, args=args, loc=loc, ip=ip).result
```

and thus cannot be emitted (because of recursive self-calls).

This PR fixes that by affixing `_` to the value builder names. 

I would've preferred to just rename the ops but that would be a breaking
change 🤷.
2025-04-11 08:55:38 -04:00
Ebuka Ezike
dda53bef35
[lldb] Fix SBTarget::ReadInstruction with flavor (#134626)
When you call the `SBTarget::ReadInstructions` with flavor from lldb
crashes. This is because the wrong order of the `DisassemblyBytes`
constructor this fixes that

---------

Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com>
2025-04-11 13:45:19 +01:00
Aaron Ballman
01658b1666 Fix two MSVC warnings; NFC
One was "unsafe use of bool" and the other was "sign comparision
mismatch", and both were because we're treating a bool object as if it
were an unsigned int. Add a cast to make that more explicit.
2025-04-11 08:44:20 -04:00
Pavel Labath
2fd860c1f5 [lldb] ProcessGdbRemote header gardning
Remove unused headers, add used headers, remove declared-but-not-defined
entities.
2025-04-11 14:36:08 +02:00
Harrison Hao
e36e57b478
[BUILD] Fix unicode build issue. (#135315)
Fix unicode build fail issue:
```
C4819	The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss	...\llvm-project\llvm\include\llvm\Support\Compiler.h
```
2025-04-11 20:35:16 +08:00
Sergey Kachkov
bc2a5b5466
[RISCV] Explicitly set FRM defs as non-dead to prevent their reordering with instructions that may use it (#135176)
Fixes #135172. The proposed solution is to conservatively reset dead
flag from all $frm defs in AdjustInstrPostInstrSelection.
2025-04-11 15:07:51 +03:00
Mészáros Gergely
c58777c2ad
[clang][ReleaseNotes] Fix code block not rendering (#135330)
Bullet lists require a blank line between paragraphs therefore the `..
code-block::` directive only renders correctly if preceded by a blank
line.
2025-04-11 13:53:33 +02:00
Florian Hahn
e27a21f6a7
[VPlan] Add hasScalarTail, use instead of !CM.foldTailByMasking() (NFC). (#134674)
Now that VPlan is able to fold away redundant branches to the scalar
preheader, we can directly check in VPlan if the scalar tail may
execute. hasScalarTail returns true if the tail may execute.

We know that the scalar tail won't execute if the scalar preheader
doesn't have any predecessors, i.e. is not reachable.

This removes some late uses of the legacy cost model.

PR: https://github.com/llvm/llvm-project/pull/134674
2025-04-11 12:50:59 +01:00
Piotr Fusik
b46f16c8d7 [RISCV][test] Add tests for subtraction if above a constant threshold 2025-04-11 13:40:10 +02:00
Ningning Shi(史宁宁)
37a86cb89e
[NFC] Use the hasMinSize() instead of hasFnAttribute(Attribute::MinSize) (#135328)
The other code all use the hasMinSize(), so I change the last two
hasFnAttribute(Attribute::MinSize).
2025-04-11 19:39:25 +08:00
Simon Pilgrim
3e743a568d
[X86] lowerShuffleAsBitMask - generalize FP handling. (#135345)
Don't explicitly handle f32/f64 cases - allow any fp value type and convert to equivalent int type with MVT::changeTypeToInteger
2025-04-11 12:24:24 +01:00
Ana Mihajlovic
52a3247196
[AMDGPU] Select (xor i1 (divergent trunc:i32 x), -1) -> cmp_neq x, 1 (#133698) 2025-04-11 13:03:01 +02:00
Vivek Khandelwal
e377a5d168
[MLIR][Tensor] Remove tensor.dim canonicalization patterns registered on tensor.expand_shape/tensor.collapse_shape (#134219)
These are problematic because the iterative application that locally
resolves the tensor.dim operation introduces
intermediate floor_div, which is losing the information about the exact
division that was carried out in the original
IR, and the iterative algorithm can't converge towards the simplest
form.
Information loss is not acceptable for canonicalization.

Resolving the dimOp can be achieved through
resolve-ranked-shaped-type-result-dims and
resolve-shaped-type-result-dims passes.

---------

Signed-off-by: Vivek Khandelwal <vivekkhandelwal1424@gmail.com>
2025-04-11 06:57:34 -04:00
Viktoriia Bakalova
9eeafc63d2
Implement -dump-minimization-hints flag. (#133910)
This PR implements a CC1 flag `-dump-minimization-hints`.
The flag allows to specify a file path to dump ranges of deserialized
declarations in `ASTReader`. Example usage:

```
clang -Xclang=-dump-minimization-hints=/tmp/decls -c file.cc -o file.o
```

Example output:
```
// /tmp/decls
{
  "required_ranges": [
    {
      "file": "foo.h",
      "range": [
        {
          "from": {
            "line": 26,
            "column": 1
          },
          "to": {
            "line": 27,
            "column": 77
          }
        }
      ]
    },
    {
      "file": "bar.h",
      "range": [
        {
          "from": {
            "line": 30,
            "column": 1
          },
          "to": {
            "line": 35,
            "column": 1
          }
        },
        {
          "from": {
            "line": 92,
            "column": 1
          },
          "to": {
            "line": 95,
            "column": 1
          }
        }
      ]
    }
  ]
}

```
Specifying the flag creates an instance of
`DeserializedDeclsSourceRangePrinter`, which dumps ranges of deserialized
declarations to aid debugging and bug minimization (we use is as input to [C-Vise](https://github.com/emaxx-google/cvise/tree/multifile-hints).

Required ranges are computed from source ranges of Decls.
`TranslationUnitDecl`, `LinkageSpecDecl` and `NamespaceDecl` are ignored
for the sake of this PR.

Technical details:
* `DeserializedDeclsSourceRangePrinter` implements `ASTConsumer` and
`ASTDeserializationListener`, so that an object of
`DeserializedDeclsSourceRangePrinter` registers as its own listener.
* `ASTDeserializationListener` interface provides the `DeclRead`
callback that we use to collect the deserialized Decls.
Printing or otherwise processing them as this point is dangerous, since
that could trigger additional deserialization and crash compilation.
* The collected Decls are processed in `HandleTranslationUnit` method of
`ASTConsumer`. This is a safe point, since we know that by this point
all the Decls needed by the compiler frontend have been deserialized.
* In case our processing causes further deserialization, `DeclRead` from
the listener might be called again. However, at that point we don't
accept any more Decls for processing.
2025-04-11 12:48:18 +02:00
Nikolas Klauser
4cde945673
[libc++][NFC] Remove public from the type traits (#135088)
The type traits are always `struct`s, so the `public` isn't necessary.
We're currently using `public` in some places, while we omit it in
others. This makes us consistent across the type traits.
2025-04-11 12:08:57 +02:00
Nikolas Klauser
cb43fe33b5
[libc++][NFC] Inline _LIBCPP_FALLTHROUGH() (#135001)
We have `[[fallthrough]]` available in all standards modes, so we can
just inline it like other stanard attributes we use.
2025-04-11 12:07:04 +02:00
Michael Buch
b656915d5a
[lldb][Format][NFCI] Refactor CPlusPlusLanguage::GetFunctionDisplayName into helpers and use LLVM style (#135331)
Same cleanup as in https://github.com/llvm/llvm-project/pull/135031. It
pretty much is the same code that we had to duplicate in the language
plugin. Maybe eventually we'll find a way of getting rid of the
duplication.
2025-04-11 11:01:27 +01:00
Han-Kuan Chen
b99a2b6221 [SLP][REVEC] Update test.
The test is affected by commit aaaa2a325bd1abb8c87e0171384fd2c42da5e38a.
2025-04-11 03:01:09 -07:00
Simon Pilgrim
937cfdc7be
[X86] combineGatherScatter - split non-constant (add v, (splat b)) indices patterns and add the splat into the (scalar) base address (#135201)
We already did this for constant cases, this patch generalizes the existing fold to attempt to extract the splat from either operand of a ADD node for the gather/scatter index value

This cleanup should also make it easier to add support for splitting vXi32 indices on x86_64 64-bit pointer targets in the future as well.

Noticed while reviewing #134979
2025-04-11 10:53:53 +01:00
Simon Pilgrim
1d3d3f404e
[DAG] SDPatternMatch::ReassociatableOpc_match - pull out repeated pattern count expression. NFC. (#135187)
Minor tidyup to remove so much template noise.

CC @esan5
2025-04-11 10:53:28 +01:00
Sergey Kachkov
b0b723a241 [RISCV][NFC] Add pre-commit test 2025-04-11 12:47:53 +03:00
Simon Pilgrim
2e02164566
[X86] getConstVector - remove raw bits -> fp handling and leave it to getNode/FoldConstantArithmetic (#135337)
getConstVector could only handle f32/f64 vector element types from raw APInt bit data - instead of trying to add all supported fp types, just bitcast the integer equivalent and leave it to getNode/FoldConstantArithmetic to perform the constant bitcast conversion

Tentative fix for a regression reported after #133913
2025-04-11 10:41:48 +01:00
Nikita Popov
6d992f1db7
[LLVM][Maintainers] Add llvm-cov / Coverage maintainer (#130590) 2025-04-11 11:31:11 +02:00
Han-Kuan Chen
d77dc87511
[SLP][REVEC] Fix type comparison and mask transformation for REVEC. (#135310)
When REVEC is enabled, ScalarTy may be a FixedVectorType. Compare its
element type to decide if casting is needed. Also apply mask
transformation accordingly.
2025-04-11 17:28:34 +08:00
Martin Storsjö
8be4bd8570
[libcxxabi] Fix the long double demangling for PowerPC (#135332)
PowerPC uses a slightly different type of floats for their 128 bit long
doubles, as "double-double", with __LDBL_MANT_DIG__ == 106 rather than
__LDBL_MANT_DIG__ == 113 for IEEE 128 bit floats.

This fixes compiling libcxxabi for PowerPC after
3b70715c13876c51542ebfe2e3f4ee908f6785cb.
2025-04-11 12:24:13 +03:00
Nathan Gauër
476c1c5ec5
[SPIR-V] Don't emit OpLifetime for Vulkan (#135166)
Those instructions require the Kernel capability, which is not available
when targeting Vulkan.
2025-04-11 11:11:59 +02:00
Zhaoxin Yang
8a351f1f2e
[lld][LoongArch] Support relaxation during IE to LE conversion (#123702)
Complement https://github.com/llvm/llvm-project/pull/123680. When
relaxation enable, remove redundant NOPs.
2025-04-11 16:55:59 +08:00
Timm Baeder
fafeaab6d9
[clang][bytecode] Misc TypeidPointer fixes (#135322)
Fix comparing type id pointers, add mor info when print()ing them, use
the most derived type in GetTypeidPtr() and the canonically unqualified
type when we know the type statically.
2025-04-11 10:35:28 +02:00
Björn Svensson
0276915a6c
[clang-tidy] Fix cert-err33-c to ignore functions with same prefixes as target (#135160)
PR #82952 introduced regex matching for `CheckedFunctions` in
`UnusedReturnValueCheck` which is used by the checker `cert-err33-c`.

Add a testcase and fix false positives by adding end-of-string to target
regex's.

---------

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
2025-04-11 10:08:29 +02:00
Jean-Didier PAILLEUX
aeb06c6152
[MLIR] Adding 'inline_hint' attribute on LLMV::CallOp (#134582)
Addition of `inlinehint` attributes for CallOps in MLIR in order to be
able to say to a function call that the inlining is desirable without
having the attribute on the FuncOp.
2025-04-11 09:31:18 +02:00
Pavel Labath
23c9cfcb74
[lldb] Small refactor of eh_frame parsing (#134806)
.. which prepares us for handling of discontinuous functions. The main
change there is that we can have multiple FDEs contributing towards an
unwind plan of a single function. This patch separates the logic for
parsing of a single FDE from the construction of an UnwindPlan (so that
another patch can change the latter to combine several unwind plans).

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-04-11 09:27:56 +02:00
z
b3397bacfb
[CodeGen][LLVM] Fix MachineOperand::print crash when TII is nullptr. (#135170)
This crash will caused if run this testcase:
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.barrier-fastregalloc.ll

When build the SDNode, precisely build the SDNode for this ir:
```ir
  call void @llvm.amdgcn.ds.gws.barrier(i32 %val, i32 0)
```
If want call the dump function of the new SDNode in the gdb environment
like this:
```gdb
  p N->dump()
```
The llvm will crash.

All of these is because calling ```dump()``` will cause the
calling```MachineMemOperand::print()```
with the argument value for the```TII``` is nullptr. 
And the llvm/lib/CodeGen/MachineOperand.cpp#L1235 is a derefrence of
TII.

Signed-off-by: fanfuqiang <fuqiang.fan@mthreads.com>
2025-04-11 15:26:55 +08:00
NAKAMURA Takumi
c3eb6b7e61 SPIRV: Suppress warnings in #134429 2025-04-11 16:08:03 +09:00
offsetof
9604bdf118
[clang] Allow parentheses around CTAD declarators (#132829)
Fixes #39811
2025-04-11 08:47:07 +02:00
Nathan Ridge
fa0498fdae
[clang][HeuristicResolver] Apply default argument heuristic in resolveDeclRefExpr as well (#132576)
This is a follow-up to https://github.com/llvm/llvm-project/pull/131074.

After moving the default argument heuristic to `simplifyType` in that
patch, the heuristic no longer applied to the 
`DependentScopeDeclRefExpr` case, because that wasn't using
`simplifyType`.

This patch fixes that, with an added testcase.
2025-04-11 02:35:04 -04:00
Fangrui Song
0816c7a95d MCParser: Remove unused enum constant 2025-04-10 23:31:38 -07:00
Fangrui Song
34fb673b08 MCStreamer: Remove Mach-O specific functions from derived MCObjectStreamer 2025-04-10 23:15:41 -07:00
Nathan Ridge
715ad67c80
[clang][CodeComplete] Use HeuristicResolver in getAsRecordDecl() (#130473)
Fixes https://github.com/llvm/llvm-project/issues/130468
2025-04-11 02:02:30 -04:00
Sudharsan Veeravalli
eccd7aa888
[RISCV] Add symbol parsing support for Xqcilb long branch instructions (#135044)
This patch adds support for parsing symbols in the Xqcilb long branch
instructions. The instructions use the `R_RISCV_QC_E_JUMP_PLT`
relocation and the `InstFormatQC_EJ` instruction format.

Vendor relocation support will be added in a later patch.
2025-04-11 11:24:40 +05:30
Martin Storsjö
3b70715c13
[libcxxabi] Use __LDBL_MANT_DIG__ for configuring demangling of long doubles (#134976)
This avoids needing to hardcode the mapping between architectures and
their sizes of long doubles.

This fixes a case in test_demangle.pass.cpp, that previously failed like
this (XFAILed):

    .---command stdout------------
    | Testing 29859 symbols.
| _ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c should be invalid
but is not
| Got: 0, void test0::h<float>(char (&) [(unsigned int)(sizeof (float) +
0x0.07ff98f7ep-1022L)])
    `-----------------------------
    .---command stderr------------
| Assertion failed: !passed && "demangle did not fail", file
libcxxabi/test/test_demangle.pass.cpp, line 30338
    `-----------------------------

This testcase is defined within

// Is long double fp80? (Only x87 extended double has 64-bit mantissa)
    #define LDBL_FP80 (__LDBL_MANT_DIG__ == 64)
    ...
    #if !LDBL_FP80
    ...
    #endif

The case failed on x86 architectures with an unusual size for long
doubles, as the test expected the demangler to not be able to demangle
an 80 bit long double (based on the `__LDBL_MANT_DIG__ == 64` condition
in the test). However as the libcxxabi implementation was hardcoded to
demangle 80 bit long doubles on x86_64 regardless of the actual size,
this test failed (by unexpectedly being able to demangle it).

By configuring libcxxabi's demangling of long doubles to match what the
compiler specifies, we no longer hit the expected failures in the
test_demangle.pass.cpp test on Android on x86.

This makes libcxxabi require a GCC-compatible compiler that defines
nonstandard defines like `__LDBL_MANT_DIG__`, but I presume that's
already essentially required anyway.
2025-04-11 08:54:11 +03:00
Yingwei Zheng
db27a0af5e
[AMDGPU][InstCombine][InstSimplify] Pre-commit tests for PR130742 (#135305)
https://github.com/llvm/llvm-project/pull/130742#discussion_r1993055149
2025-04-11 12:42:14 +08:00
Fangrui Song
c04d9d57ee
MCAsmStreamer: Replace the MCInstPrinter * parameter with unique_ptr
... to clarify ownership, aligning with other parameters. Using
`std::unique_ptr` encourages users to manage `createMCInstPrinter` with
a unique_ptr instead of a raw pointer, reducing the risk of memory
leaks.

* llvm-mc: fix a leak and update llvm/test/tools/llvm-mc/disassembler-options.test
* #121078 copied the llvm-mc code to CodeGenTargetMachineImpl and made
  the same mistake. Fixed by 2b8cc651dca0c000ee18ec79bd5de4826156c9d6

Using unique_ptr requires #include MCInstPrinter.h in a few translation
units.

* Delete a createAsmStreamer overload I deprecated in 2024
* SystemZMCTargetDesc.cpp: rename to `createSystemZAsmStreamer` to fix
  an overload conflict.

Pull Request: https://github.com/llvm/llvm-project/pull/135128
2025-04-10 21:25:35 -07:00
Amir Ayupov
ba93fe97c2
[BOLT][NFC] Simplify getOrCreate/analyze/populate/emitJumpTable (#132108) 2025-04-10 21:17:04 -07:00
Yingwei Zheng
04c38981a9
[Clang][CodeGen] Do not set inbounds flag in EmitMemberDataPointerAddress when the base pointer is null (#130952)
See also https://github.com/llvm/llvm-project/pull/130734 for the
original motivation.

This pattern (`container_of`) is also widely used by real-world
programs.
Examples:

1d89d7d5d7/llvm/include/llvm/IR/SymbolTableListTraits.h (L77-L87)

a2a53cb728/src/util-inl.h (L134-L137)
https://github.com/search?q=*%29nullptr-%3E*&type=code
2025-04-11 10:51:08 +08:00
Philip Reames
f40001372b
[RISCV] Lower a shuffle which is nearly identity except one replicated element (#135292)
This can be done with a vrgather.vi/vx, and (possibly) a register move.
The alternative is to do a vrgather.vv with a full width index vector.

We'd already caught the two operands forms of this shuffle; this patch
specifically handles the single operand form.

Unfortunately only in abstract, it would be nice if we canonicalized
shuffles in some way wouldn't it?
2025-04-10 19:45:04 -07:00
Douglas Yung
b03aa291b8 Add 'REQUIRES: asserts' to test undef-args.ll added in #135247 to skip test when asserts are not present.
Should fix bot failure: https://lab.llvm.org/buildbot/#/builders/202/builds/601
2025-04-11 02:18:10 +00:00
Johannes Doerfert
8bd93b8303
[OpenMP][NFC] Do not collect kernels if they are not used (#135252) 2025-04-10 19:10:27 -07:00
Owen Pan
72540dbe01 [clang-format][NFC] Reformat git-clang-format 2025-04-10 19:07:44 -07:00
Vitaly Buka
862e7190c9
Reland "Replace bool operator== for VersionType in sanitizer_mac.h" (#135276)
Fixes error: ISO C++20 considers use of overloaded operator '==' (with
operand types 'MacosVersion' and 'MacosVersion') to be ambiguous despite
there being a unique best viable function
[-Werror,-Wambiguous-reversed-operator].

This converts the comparison operator from a non-symmetric operator
(const VersionBase<VersionType>& (as "this") and const VersionType &).
into a symmetric operator

Relands #135068

Co-authored-by: Ivan Tadeu Ferreira Antunes Filho <antunesi@google.com>
2025-04-10 19:05:26 -07:00
Slava Zakharin
9aff19e7a3
[flang] Defined SafeTempArrayCopyAttrInterface for array repacking. (#134346)
This patch defines `fir::SafeTempArrayCopyAttrInterface` and the
corresponding
OpenACC/OpenMP related attributes in FIR dialect. The actual
implementations
are just placeholders right now, and array repacking becomes a no-op
if `-fopenacc/-fopenmp` is used for the compilation.
2025-04-10 18:41:54 -07:00