Commit Graph

543563 Commits

Author SHA1 Message Date
Simon Pilgrim
372e332a57 [X86] freeze-unary.ll - remove unnecessary freeze from CTLZ/CTTZ_ZERO_UNDEF tests 2025-07-01 08:32:28 +01:00
Nikita Popov
ab6316e219 [Coroutines] Work on intrinsic IDs instead of names (NFCI) (#145518)
For the checks whether certain intrinsics are used, work with intrinsic
IDs instead of intrinsic names.

This also exposes that some of the checks were incorrect, because the
intrinsics were overloaded. There is no efficient way to determine
whether these are used. This change explicitly documents which
intrinsics are not checked for this reason.
2025-07-01 09:22:23 +02:00
Fangrui Song
9beb467d92 MC: Store fragment content and fixups out-of-line
Moved `Contents` and `Fixups` SmallVector storage to MCSection, enabling
trivial destructors for most fragment subclasses and eliminating the need
for MCFragment::destroy in ~MCSection.

For appending content to the current section, use
getContentsForAppending. During assembler relaxation, prefer
setContents/setFixups, which may involve copying and reduce the benefits
of https://reviews.llvm.org/D145791.

Moving only Contents out-of-line caused a slight performance regression
(Alexis Engelke's 2024 prototype). By also moving Fragments out-of-line,
fragment destructors become trivial, resulting in
neglgible instructions:u increase for "stage2-O0-g" and [large max-rss decrease](https://llvm-compile-time-tracker.com/compare.php?from=84e82746c3ff63ec23a8b85e9efd4f7fccf92590&to=555a28c0b2f8250a9cf86fd267a04b0460283e15&stat=max-rss&linkStats=on)
for the "stage1-ReleaseLTO-g (link only)" benchmark.
(
An older version using fewer inline functions: https://llvm-compile-time-tracker.com/compare.php?from=bb982e733cfcda7e4cfb0583544f68af65211ed1&to=f12d55f97c47717d438951ecddecf8ebd28c296b&linkStats=on
)

Now using plain SmallVector in MCSection for storage, with potential for
future allocator optimizations, such as allocating `Contents` as the
trailing object of MCDataFragment. (GNU Assembler uses gnulib's obstack
for fragment management.)

Co-authored-by: Alexis Engelke <engelke@in.tum.de>

Pull Request: https://github.com/llvm/llvm-project/pull/146307
2025-07-01 00:21:12 -07:00
Nikita Popov
7e830f7671 [Clang] Partially fix m68k alignments (#144740)
As the data layout a few lines further up specifies, the int, long and
pointer alignment should be 16 instead of the default of 32.

The long long alignment is also incorrect, but that would require a
change to the data layout as well.

Comparison with GCC, which consistently uses 2 byte alignment:
https://gcc.godbolt.org/z/K3x6a7dEf At least based on some spot checks,
the changes to bit field layout also make use match GCC now.

This was found by https://github.com/llvm/llvm-project/pull/144720.
2025-07-01 09:06:41 +02:00
Nikita Popov
c5e4546a01 [DwarfDebug] Slightly optimize computeKeyInstructions() (NFC) (#146357)
Fetch the DILocation once, instead of many times. This is pretty
trivial, but goes through out-of-line code.
2025-07-01 09:06:17 +02:00
Pavel Labath
72b40f7c64 [lldb] Delete unused DWARFDataExtractor methods (#146356)
They are left over from our previous attempt at DWARF64. The new attempt
is not using them, and they also don't have equivalents in the llvm
DWARFDataExtractor class.
2025-07-01 08:47:45 +02:00
Mahesh-Attarde
84e82746c3 [X86][llvm-exegesis] fix LNLP performance counter binding issue (#146348)
We added LNLP sched model recently, PFM counter bounding names needs to
match cpu string.
llvm-exegesis wont produce results without correct naming.

Co-authored-by: mattarde <mattarde@intel.com>
2025-07-01 10:29:23 +05:30
Fangrui Song
393aebf5c2 CodeView: Move MCCVDefRangeFragment storage to MCContext/MCFragment. NFC (#146462)
so that ~MCCVInlineLineTableFragment will become trivial when we
make ~MCEncodedFragment trivial (#146307).
2025-06-30 21:49:54 -07:00
Phoebe Wang
67b740bd73 [X86] Add diagnostic for fp128 inline assemble for 32-bit (#146458)
Suggested by Craig from #146259
2025-07-01 12:39:43 +08:00
Jason Molenda
e94c6091c9 [lldb][Mach-O] Fix several bugs in x86_64 Mach-O corefile (#146460)
reading, and one bug in the new RegisterContextUnifiedCore class.

The PR I landed a few days ago to allow Mach-O corefiles to augment
their registers with additional per-thread registers in metadata exposed
a few bugs in the x86_64 corefile reader when running under different CI
environments. It also showed a bug in my RegisterContextUnifiedCore
class where I wasn't properly handling lookups of unknown registers
(e.g. the LLDB_GENERIC_RA when debugging an intel target).

The Mach-O x86_64 corefile support would say that it had fpu & exc
registers available in every corefile, regardless of whether they were
actually present. It would only read the bytes for the first register
flavor in the LC_THREAD, the GPRs, but it read them incorrectly, so
sometimes you got more register context than you'd expect. The LC_THREAD
register context specifies a flavor and the number of uint32_t words;
the ObjectFileMachO method would read that number of uint64_t's,
exceeding the GPR register space, but it was followed by FPU and then
EXC register space so it didn't crash. If you had a corefile with GPR
and EXC register bytes, it would be written into the GPR and then FPU
register areas, with zeroes filling out the rest of the context.
2025-06-30 21:27:53 -07:00
Jim Lin
ce159d20e5 [RISCV] Put REQUIRES: riscv-registered-target in the first line of the file. NFC.
To be more consistent with other files.
2025-07-01 12:18:16 +08:00
Yang Bai
393a75ebb7 [mlir][Vector] Add constant folding for vector.from_elements operation (#145849)
### Summary

This PR adds a new folding pattern for **vector.from_elements** that
canonicalizes it to **arith.constant** when all input operands are
constants.

### Implementation Details

**Leverages FoldAdaptor capabilities**: Uses adaptor.getElements() to
access **pre-computed** constant attributes, avoiding redundant pattern
matching on operands.

### Example Transformation
```
Before:
%c0_i32 = arith.constant 0 : i32
%c1_i32 = arith.constant 1 : i32
%c2_i32 = arith.constant 2 : i32
%c3_i32 = arith.constant 3 : i32
%v = vector.from_elements %c0_i32, %c1_i32, %c2_i32, %c3_i32 : vector<2x2xi32>

After:
%v = arith.constant dense<[[0, 1], [2, 3]]> : vector<2x2xi32>
```

---------

Co-authored-by: Yang Bai <yangb@nvidia.com>
2025-06-30 20:39:53 -07:00
S. VenkataKeerthy
0a69c83421 [NFC][IR2Vec] Remove unreachable code and simplify invalid mode test (#146459)
The code following `llvm_unreachable`  is optimized out in Release builds. In this case, `Embedder::create` do not seem to return `nullptr` causing `CreateInvalidMode` test to break. Hence removing `llvm_unreachable`.
2025-06-30 20:31:47 -07:00
Qi Zhao
66cc167dfa [LoongArch] Add tests for inserting extracted integer elements. NFC 2025-07-01 10:21:33 +08:00
Kazu Hirata
8cf3b989a9 [Analysis] Fix a warning
This patch fixes:

  llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp:132:12:
  error: moving a local object in a return statement prevents copy
  elision [-Werror,-Wpessimizing-move]
2025-06-30 18:44:45 -07:00
S. VenkataKeerthy
a2dc64cd03 [NFC][MLGO] Convert notes to proper RST note directives in MLGO.rst (#146450) 2025-06-30 18:25:12 -07:00
S. VenkataKeerthy
9438048816 [IR2Vec] Simplifying creation of Embedder (#143999)
This change simplifies the API by removing the error handling complexity. 

- Changed `Embedder::create()` to return `std::unique_ptr<Embedder>` directly instead of `Expected<std::unique_ptr<Embedder>>`
- Updated documentation and tests to reflect the new API
- Added death test for invalid IR2Vec kind in debug mode
- In release mode, simply returns nullptr for invalid kinds instead of creating an error

(Tracking issue - #141817)
2025-06-30 18:24:08 -07:00
NAKAMURA Takumi
24c4bba076 [bazel] Quick fix for #145584 (Core deps ProfileData/InstrProf.h) 2025-07-01 10:03:03 +09:00
Mingjie Xu
6323541a2a [LLD][ELF] Skip non-SHF_ALLOC sections when checking max VA and max VA difference in relaxOnce() (#145863)
For non-SHF_ALLOC sections, sh_addr is set to 0.
Skip sections without SHF_ALLOC flag, so `minVA` will not be set to 0
with non-SHF_ALLOC sections, and the size of non-SHF_ALLOC sections will
not contribute to `maxVA`.
2025-07-01 09:02:06 +08:00
S. VenkataKeerthy
6620db50fe [NFC][MLGO] Fix indentation in MLGO.rst (#146444) 2025-06-30 18:00:09 -07:00
Jim Lin
70db191efa [RISCV] Add LLVM IR intrinsicis vrgatherei16/vslideup/vslidedown support for Zvfbfmin (#146312)
This patch add LLVM IR intrinsicis vrgatherei16/vslideup/vslidedown
support for Zvfbfmin.
2025-07-01 08:48:13 +08:00
S. VenkataKeerthy
a4f637d988 [MLGO] Fix feature iteration using FeatureMap.size() instead of NumberOfFeatures (#146436)
Due to the changes made in #143479, size of `FeatureMap` reflects the number of features used. Hence replacing `NumberOfFeatures` with `FeatureMap.size()` in the `DevelopmentModeInlineAdvisor`.
2025-06-30 17:44:23 -07:00
Ami-zhang
8d9cdb65f0 [Clang][LoongArch] Fixed incorrect _BitInt(N>64) alignment (#145297)
This patch makes determining alignment and width of BitInt to be target
ABI specific and makes it consistent with [Procedure Call Standard for
the LoongArch™ Architecture] for LoongArch target
(https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc).
2025-07-01 08:42:16 +08:00
Maksim Panchenko
ad7d675991 [BOLT] Refactor mapCodeSections(). NFC (#146434)
Factor out non-relocation specific code into a separate function.
2025-06-30 17:09:41 -07:00
Razvan Lupusoru
a3c8165421 [flang][acc] Fix dialect dependencies (#146431)
The TestOpenACCInterfaces test loads dialects including HLFIR and DLTI
(for data layout). The appropriate dependencies were missing leading to
link failures:

TestOpenACCInterfaces.cpp:(.text._ZNK12_GLOBAL__N_124TestFIROpenACCInterfaces20getDependentDialectsERN4mlir15DialectRegistryE+0x66):
undefined reference to
`mlir::detail::TypeIDResolver<hlfir::hlfirDialect, void>::id'
TestOpenACCInterfaces.cpp:(.text._ZNK12_GLOBAL__N_124TestFIROpenACCInterfaces20getDependentDialectsERN4mlir15DialectRegistryE+0x141):
undefined reference to `mlir::detail::TypeIDResolver<mlir::DLTIDialect,
void>::id'
2025-06-30 17:04:48 -07:00
Mircea Trofin
d2500e639b [pgo] add means to specify "unknown" MD_prof (#145578)
This PR is part of https://discourse.llvm.org/t/rfc-profile-information-propagation-unittesting/73595

In a slight departure from the RFC, instead of a brand-new `MD_prof_unknown` kind, this adds a first operand to `MD_prof` metadata. This makes it easy to replace with valid metadata (only one `MD_prof`), otherwise sites inserting valid `MD_prof` would also have to check to remove the `unknown` one.

The patch just introduces the notion and fixes the verifier accordingly. Existing APIs working (esp. reading) `MD_prof` will be updated subsequently.
2025-06-30 16:57:11 -07:00
Deric C.
12409a18f6 [DirectX] Implement memcpy in DXIL CBuffer Access pass (#144436)
Fixes #141840

This PR implements support for the `memcpy` intrinsic in the DXIL
CBuffer Access pass with the following restrictions:

- The CBuffer Access must be the `src` operand of `memcpy` and must be
direct (i.e., not a GEP)
- The type of the CBuffer Access must be of an Array Type

These restrictions greatly simplify the implementation of `memcpy` yet
still covers the known uses in DML shaders.

Furthermore, to prevent errors like #141840 from occurring silently
again, this PR adds error reporting for unsupported users of globals in
the DXIL CBuffer Access pass.
2025-06-30 16:32:43 -07:00
Rahul Joshi
92b50959da [NFC][TableGen] Capitalize to in UseFnTableInDecodetoMCInst. (#146419) 2025-06-30 16:12:15 -07:00
Jakub Kuderski
ff4faaa660 [mlir][examples] Fix deprecation warnings for ArrayRef(std::nullopt) (#146420)
This used to print:
```
llvm-project/mlir/include/mlir/IR/ValueRange.h:401:20: warning: 'ArrayRef' is deprecated: Use {} or ArrayRef<T>() instead [-Wdeprecated-declarations]
  401 |       : ValueRange(ArrayRef<Value>(std::forward<Arg>(arg))) {}
      |                    ^~~~~~~~
      |                    {}
build/tools/mlir/examples/toy/Ch7/include/toy/Ops.cpp.inc:2221:30: note: in instantiation of function template specialization 'mlir::ValueRange::ValueRange<const std::nullopt_t &, void>' requested here
 2221 |  build(odsBuilder, odsState, std::nullopt); 
      |                              ^
llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: 'ArrayRef' has been explicitly marked deprecated here
   70 |     /*implicit*/ LLVM_DEPRECATED("Use {} or ArrayRef<T>() instead", "{}")
      |                  ^
llvm-project/llvm/include/llvm/Support/Compiler.h:249:50: note: expanded from macro 'LLVM_DEPRECATED'
  249 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
```
2025-06-30 18:14:33 -04:00
Razvan Lupusoru
f16983f7d0 [flang][acc] Ensure fir.class is handled in type categorization (#146174)
fir.class is treated similarly as fir.box - but it has one key
distinction which is that it doesn't hold an element type. Thus the
categorization logic was mishandling this case for this reason (and also
the fact that it assumed that a base object is always a fir.ref).

This PR improves this handling and adds appropriate test exercising both
a class and a class field to ensure categorization works.
2025-06-30 15:04:14 -07:00
realqhc
6896d8a05d [RISCV][MC] Support Base P non-GPR pair instructions (#137927) 2025-07-01 08:01:06 +10:00
Florian Hahn
59a7185dd9 [VPlan] Truncate/Extend ComputeReductionResult at construction (NFC). (#141860)
Instead of looking up the narrower reduction type via getRecurrenceType
we can generate the needed extend directly at constructiond re-use the
truncated value from the loop.

PR: https://github.com/llvm/llvm-project/pull/141860
2025-06-30 22:39:17 +01:00
Jeffrey Byrnes
d599bdeaa4 [AMDGPU] Autogen checks for test (#146421)
Needed for upcoming PR for RA priorities
2025-06-30 14:36:23 -07:00
Jonas Devlieghere
1eb795413d [lldb] Correctly restore the cursor column after resizing the statusline (#146132)
This PR ensures we correctly restore the cursor column after resizing
the statusline. To ensure we have space for the statusline, we have to
emit a newline to move up everything on screen. The newline causes the
cursor to move to the start of the next line, which needs to be undone.

Normally, we would use escape codes to save & restore the cursor
position, but that doesn't work here, as the cursor position may have
(purposely) changed. Instead, we move the cursor up one line using an
escape code, but we weren't restoring the column.

Interestingly, Editline was able to recover from this issue through the
LineInfo struct which contains the buffer and the cursor location, which
allows us to compute the column. This PR addresses the bug by having
Editline "refresh" the cursor position.

Fixes #134064
2025-06-30 14:34:35 -07:00
Ellis Hoag
0d1392e979 [MachineOutliner] Remove LOHs from outlined candidates (#143617)
Remove Linker Optimization Hints (LOHs) from outlining candidates
instead of simply preventing outlining if LOH labels are found in the
candidate. This will improve the effectiveness of the machine outliner
when LOHs are enabled (which is the default).

In
https://discourse.llvm.org/t/loh-conflicting-with-machineoutliner/83279/1
it was observed that the machine outliner is much more effective when
LOHs are disabled. Rather than completely disabling LOH, this PR aims to
keep LOH in most places and removing them from outlined functions where
it could be illegal. Note that we are conservatively removing all LOHs
from outlined functions for simplicity, but I believe we could retain
LOHs that are in the intersection of all candidates.

It should be ok to remove these LOHs since these blocks are being
outlined anyway, which will harm performance much more than the gain
from keeping the LOHs.
2025-06-30 14:29:06 -07:00
Valentin Clement (バレンタイン クレメン)
f4cecfe1bb [flang][cuda] Bring PARAMETER arrays into the GPU module (#146416) 2025-06-30 14:24:44 -07:00
Kazu Hirata
56739f5866 [Analysis] Fix a warning
This patch fixes:

  llvm/lib/Analysis/IR2Vec.cpp:296:2: error: extra ';' outside of a
  function is incompatible with C++98
  [-Werror,-Wc++98-compat-extra-semi]
2025-06-30 14:18:03 -07:00
S. VenkataKeerthy
0745eb501d [IR2Vec] Scale embeddings once in vocab analysis instead of repetitive scaling (#143986)
Changes to scale opcodes, types and args once in `IR2VecVocabAnalysis` so that we can avoid scaling each time while computing embeddings. This PR refactors the vocabulary to explicitly define 3 sections---Opcodes, Types, and Arguments---used for computing Embeddings. 

(Tracking issue - #141817 ; partly fixes - #141832)
2025-06-30 23:09:19 +02:00
Mahesh-Attarde
56ef00a59d [X86][GlobalISel] Fix RegBank issue for G_FABS (#145674)
Fixes hidden issue in https://github.com/llvm/llvm-project/pull/136718. 
It removes custom selection code since problem was in RegBank
assignment
2025-06-30 22:52:12 +02:00
Jonas Devlieghere
eb904e857a [lldb] Fix link syntax in docs/use/mcp.md 2025-06-30 13:50:32 -07:00
S. VenkataKeerthy
dcf8ec9218 Reland "[MLGO][IR2Vec] Integrating IR2Vec with MLInliner (#143479)" (#145664)
Relanding #143479 after fixes. 

Removed `NumberOfFeatures` from the `FeatureIndex` enum as the number of features used depends on whether IR2Vec embeddings are used.
2025-06-30 22:37:39 +02:00
Florian Hahn
026aae7047 [VPlan] Infer reduction result types w/o accessing underlying phis.(NFC)
Remove another use of the underlying IR phi.
2025-06-30 21:29:29 +01:00
Amr Hesham
f205e354ae [CIR] Upstream GenericSelectionExpr for ComplexType (#146265)
Upstream the GenericSelectionExpr for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-30 22:25:01 +02:00
sribee8
81c9a1a4e5 [libc][obvious] Fixed typos in some wchar headers (#146413)
Some of the wchar headers had typos in them.

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-30 20:22:05 +00:00
Krzysztof Parzyszek
4c7d3e9315 [STLForwardCompat] Implement llvm::type_identity (#146390)
A basic implementation until we get it in `std` in C++20.
2025-06-30 15:05:49 -05:00
sribee8
4bf0c6b5f8 [libc][bazel] Added wchar functions to bazel (#146126)
Added wchar functions, apart from ones that use mbstate_t. to the bazel
files

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-30 20:05:26 +00:00
Robert Konicar
163a7e1b4f [mlir][LLVMIR][NFC] Remove duplicate getUnnamedAddrAttrName uses in op printers (#146090)
Fix `UnnamedAddrAttrName` being inserted twice into the `elidedAttrs`
list for the attribute dictionary printer in `GlobalOp` and `AliasOp`
print functions.
2025-06-30 21:57:05 +02:00
Eugene Epshteyn
93849a39c4 [flang] Check for ultimate ALLOCATABLE component in LOCAL_INIT() (#145800)
Fortran 2023 constraint C1130 disallows variables of derived type with
ultimate allocatable component to appear in LOCAL_INIT().
2025-06-30 15:49:07 -04:00
Erick Velez
a68e4470c1 [clang-doc] serialize friends (#146165)
Parse friends into a new FriendInfo and serialize them in JSON. We keep track of the friend declaration's template and function information if applicable.
2025-06-30 12:43:52 -07:00
Baranov Victor
96b9b2e21d [Clang] Fix '-Wformat-overflow' FP when floats had field-width and plus prefix (#144274)
If field width is specified, the sign/space is already accounted for
within the field width, so no additional size is needed.

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

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-06-30 22:43:47 +03:00