61187 Commits

Author SHA1 Message Date
Mircea Trofin
52cb6e9d49
[ProfCheck][NFC] Make Function argument from branch weight setter optional (#166032)
This picks up from #166028, making the `Function` argument optional:
most cases don't need to provide it, but in e.g. InstCombine's case,
where the instruction (select, branch) is not attached to a function
yet, the function needs to be passed explicitly.

Co-authored-by: Florian Hahn <flo@fhahn.com>
2025-11-05 07:40:37 -08:00
Matt Arsenault
ad8f6b44be
DAG: Avoid some libcall string name comparisons (#166321)
Move to the libcall impl based functions.
2025-11-05 07:09:02 -08:00
hev
a4105707ee
[llvm][LoongArch] Introduce LASX and LSX conversion intrinsics (#157818)
This patch introduces the LASX and LSX conversion intrinsics:

- <8 x float> @llvm.loongarch.lasx.cast.128.s(<4 x float>)
- <4 x double> @llvm.loongarch.lasx.cast.128.d(<2 x double>)
- <4 x i64> @llvm.loongarch.lasx.cast.128(<2 x i64>)
- <8 x float> @llvm.loongarch.lasx.concat.128.s(<4 x float>, <4 x
float>)
- <4 x double> @llvm.loongarch.lasx.concat.128.d(<2 x double>, <2 x
double>)
- <4 x i64> @llvm.loongarch.lasx.concat.128(<2 x i64>, <2 x i64>)
- <4 x float> @llvm.loongarch.lasx.extract.128.lo.s(<8 x float>)
- <2 x double> @llvm.loongarch.lasx.extract.128.lo.d(<4 x double>)
- <2 x i64> @llvm.loongarch.lasx.extract.128.lo(<4 x i64>)
- <4 x float> @llvm.loongarch.lasx.extract.128.hi.s(<8 x float>)
- <2 x double> @llvm.loongarch.lasx.extract.128.hi.d(<4 x double>)
- <2 x i64> @llvm.loongarch.lasx.extract.128.hi(<4 x i64>)
- <8 x float> @llvm.loongarch.lasx.insert.128.lo.s(<8 x float>, <4 x
float>)
- <4 x double> @llvm.loongarch.lasx.insert.128.lo.d(<4 x double>, <2 x
double>)
- <4 x i64> @llvm.loongarch.lasx.insert.128.lo(<4 x i64>, <2 x i64>)
- <8 x float> @llvm.loongarch.lasx.insert.128.hi.s(<8 x float>, <4 x
float>)
- <4 x double> @llvm.loongarch.lasx.insert.128.hi.d(<4 x double>, <2 x
double>)
- <4 x i64> @llvm.loongarch.lasx.insert.128.hi(<4 x i64>, <2 x i64>)
2025-11-05 20:36:38 +08:00
Mircea Trofin
02f5a1aa07
[ADT] Introduce Casting function objects (#165803)
Adding casting function objects as a convenience for expressing e.g. `auto AsDoubles = map_range(RangeOfInts, StaticCastTo<double>)`​
2025-11-04 16:39:26 -08:00
Min-Yih Hsu
6d4e75cc93
[MISched][NFC] Rename isUnbufferedGroup to isReservedGroup (#166439)
In both ScheduleDAGInstrs and MachineScheduler, we call `BufferSize = 0`
as _reserved_ and `BufferSize = 1` as _unbuffered_. This convention is
stem from the fact that we set `SUnit::hasReservedResource` to true when
any of the SUnit's consumed resources has BufferSize equal to zero; set
`SUnit::isUnbuffered` to true when any of its consumed resources has
BufferSize equal to one.

However, `SchedBoundary::isUnbufferedGroup` doesn't really follow this
convention: it returns true when the resource in question is a
`ProcResGroup` and its BufferSize equals to **zero** rather than one.
This could be really confusing for the reader. This patch renames this
function to `isReservedGroup` in aligned with the convention mentioned
above.

NFC.
2025-11-04 16:21:37 -08:00
Matt Arsenault
fe106b6e73
BasicTTI: Cleanup multiple result intrinsic handling (#165970)
Avoid weird lambda returning function pointer and sink the libcall
logic to where the operation is handled. This allows chaining the
libcall logic to try sincos_stret and fallback to sincos. The resulting
cost seems too low.
2025-11-04 10:19:32 -08:00
Matt Arsenault
fb21f16fe6
RuntimeLibcalls: Add stub API for getting function signatures (#166290)
Eventually this should be generated by tablegen for all functions.
For now add a manually implementation for sincos_stret, which I
have an immediate use for. This will allow pulling repeated code
across targets into shared call sequence code.

Also add sqrt just to make sure we can handle adding return attributes
on the declaration.
2025-11-04 10:06:29 -08:00
Greg Clayton
6601c384d3
Fix getting section info in large mach-o files. (#165940)
Mach-o has 32 bit file offsets in the MachO::section_64 structs. dSYM
files can contain sections whose start offset exceeds UINT32_MAX, which
means the MachO::section_64.offset will get truncated. We can calculate
when this happens and properly adjust the section offset to be 64 bit
safe. This means tools can get the correct section contents for large
dSYM files and allows tools that parse DWARF, like llvm-gsymutil, to be
able to load and convert these files correctly.
2025-11-04 09:36:54 -08:00
Florian Hahn
af9a4263a1
[LAA] Only use inbounds/nusw in isNoWrap if the GEP is dereferenced. (#161445)
Update isNoWrap to only use the inbounds/nusw flags from GEPs that are
guaranteed to be dereferenced on every iteration. This fixes a case
where we incorrectly determine no dependence.

I think the issue is isolated to code that evaluates the resulting
AddRec at BTC, just using it to compute the distance between accesses
should still be fine; if the access does not execute in a given
iteration, there's no dependence in that iteration. But isolating the
code is not straight-forward, so be conservative for now. The practical
impact should be very minor (only one loop changed across a corpus with
27k modules from large C/C++ workloads.

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

PR: https://github.com/llvm/llvm-project/pull/161445
2025-11-04 17:08:12 +00:00
Tim Corringham
89ec96b8b4
[HLSL] Implement the f16tof32() intrinsic (#165860)
Implement the f16tof32() intrinsic, including DXILand SPIRV codegen, and
associated tests.

Fixes #99112

---------

Co-authored-by: Tim Corringham <tcorring@amd.com>
2025-11-04 17:04:39 +00:00
Kazu Hirata
ed7d6c3511
[ADT] Deprecate a soft-deprecated APInt constructor (#166314)
This patch deprecates an APInt constructor that has been
soft-deprecated via comments since:

  commit 7a16288157efc5fb85fbe3b8b4c37071da7609a6
  Author: Jeffrey Yasskin <jyasskin@google.com>
  Date:   Mon Jul 18 21:45:40 2011 +0000

This patch updates a small number of remaining uses.
2025-11-04 08:28:51 -08:00
Kazu Hirata
c2269c842d
[ADT] Move llvm::to_address to STLForwardCompat.h (NFC) (#166315)
This patch moves llvm::to_address to STLForwardCompat.h, a collection
of backports from C++20 and beyond.
2025-11-04 07:12:29 -08:00
Rahul Joshi
a2495ff991
[NFC][TableGen] Emit empty lines after/before namespace scope (#166217)
Emit empty line after a namespace scope is opened and before its closed.
Adjust DirectiveEmitter code empty line emission in response to this to
avoid lot of unit test changes.
2025-11-04 07:11:26 -08:00
zhijian lin
b25868157d
[NFC] add LLVM_ABI to function getMemcmp declaration (#166192)
According to discussion of
https://github.com/llvm/llvm-project/pull/153600#discussion_r2356071934

add LLVM_ABI to function getMemcmp declaration
2025-11-04 09:53:45 -05:00
Yingwei Zheng
8a84b285f6
[SimplifyCFG] Eliminate dead edges of switches according to the domain of conditions (#165748)
In simplifycfg/cvp/sccp, we eliminate dead edges of switches according
to the knownbits/range info of conditions. However, these approximations
may not meet the real-world needs when the domain of condition values is
sparse. For example, if the condition can only be either -3 or 3, we
cannot prove that the condition never evaluates to 1 (knownbits:
???????1, range: [-3, 4)).
This patch adds a helper function `collectPossibleValues` to enumerate
all the possible values of V. To fix the motivating issue,
`eliminateDeadSwitchCases` will use the result to remove dead edges.

Note: In
https://discourse.llvm.org/t/missed-optimization-due-to-overflow-check/88700
I proposed a new value lattice kind to represent such values. But I find
it hard to apply because the transition becomes much complicated.

Compile-time impact looks neutral:
https://llvm-compile-time-tracker.com/compare.php?from=32d6b2139a6c8f79e074e8c6cfe0cc9e79c4c0c8&to=e47c26e3f1bf9eb062684dda4fafce58438e994b&stat=instructions:u
This patch removes many dead error-handling codes:
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/3012
Closes https://github.com/llvm/llvm-project/issues/165179.
2025-11-04 20:55:33 +08:00
Jay Foad
f037f41350
[IR] Add new function attribute nocreateundeforpoison (#164809)
Also add a corresponding intrinsic property that can be used to mark
intrinsics that do not introduce poison, for example simple arithmetic
intrinsics that propagate poison just like a simple arithmetic
instruction.

As a smoke test this patch adds the new property to
llvm.amdgcn.fmul.legacy.
2025-11-04 12:00:44 +00:00
Michael Buch
f8656ed455
[llvm][dwarfdump] Add --child-tags option to filter by DWARF tags (#165720)
This patch adds a new option `--child-tags` (`-t` for short), which
makes dwarfdump only dump children whose DWARF tag is in the list of
tags specified by the user.

Motivating examples are:
* dumping all global variables in a CU
* dumping all non-static data members of a structure
* dumping all module import declarations of a CU
* etc.

For tags not known to dwarfdump, we pretend that the tag wasn't
specified.

Note, this flag only takes effect when `--show-children` is set (either
explicitly or implicitly). We error out when trying to use the flag
without dumping children.

Example:
```
$ builds/release/bin/llvm-dwarfdump -t DW_TAG_structure_type a.out.dSYM                 
...
0x0000000c: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 22.0.0git (git@github.com:Michael137/llvm-project.git 737da3347c2fb01dd403420cf83e9b8fbea32618)")
              DW_AT_language    (DW_LANG_C11)
              ...
0x0000002a:   DW_TAG_structure_type
                DW_AT_APPLE_block       (true)
                DW_AT_byte_size (0x20)

0x00000067:   DW_TAG_structure_type
                DW_AT_APPLE_block       (true)
                DW_AT_name      ("__block_descriptor")
                DW_AT_byte_size (0x10)
...
```

```
$ builds/release/bin/llvm-dwarfdump -t DW_TAG_structure_type -t DW_TAG_member a.out.dSYM
...
0x0000000c: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 22.0.0git (git@github.com:Michael137/llvm-project.git 737da3347c2fb01dd403420cf83e9b8fbea32618)")
              DW_AT_language    (DW_LANG_C11)                                                             
              DW_AT_name        ("macro.c")                                                               
              ...                                              
0x0000002a:   DW_TAG_structure_type                                                                       
                DW_AT_APPLE_block       (true)                                                            
                DW_AT_byte_size (0x20)
                                                     
0x0000002c:     DW_TAG_member                 
                  DW_AT_name    ("__isa")                                                                 
                  DW_AT_type    (0x00000051 "void *")                                                     
                  DW_AT_data_member_location    (0x00)
                                                                                                          
0x00000033:     DW_TAG_member                                                                             
                  DW_AT_name    ("__flags")                                                               
                  DW_AT_type    (0x00000052 "int")                                                        
                  DW_AT_data_member_location    (0x08)
                                                                                                          
0x0000003a:     DW_TAG_member                                                                             
                  DW_AT_name    ("__reserved")
                  DW_AT_type    (0x00000052 "int")                                                        
                  DW_AT_data_member_location    (0x0c)                                                    

0x00000041:     DW_TAG_member
                  DW_AT_name    ("__FuncPtr")   
                  DW_AT_type    (0x00000056 "void (*)(int)")                                              
                  DW_AT_data_member_location    (0x10)                                         
                                                     
0x00000048:     DW_TAG_member                                                                             
                  DW_AT_name    ("__descriptor")                                                          
                  DW_AT_type    (0x00000062 "__block_descriptor *")
                  DW_AT_alignment       (8)
                  DW_AT_data_member_location    (0x18)                                                    
                                                     
0x00000067:   DW_TAG_structure_type                                                                       
                DW_AT_APPLE_block       (true)
                DW_AT_name      ("__block_descriptor")
                DW_AT_byte_size (0x10)                                                                    
                                                                                                          
0x0000006a:     DW_TAG_member              
                  DW_AT_name    ("reserved")                                                              
                  DW_AT_type    (0x00000079 "unsigned long")
                  DW_AT_data_member_location    (0x00)                                         
                                                     
0x00000071:     DW_TAG_member                                                                             
                  DW_AT_name    ("Size")                                                                  
                  DW_AT_type    (0x00000079 "unsigned long")
                  DW_AT_data_member_location    (0x08)             
...                                       
```
2025-11-04 11:37:56 +00:00
kper
5b2f9b53bd
[SimplifyCFG]: Switch on umin replaces default (#164097)
A switch on `umin` can eliminate the default case by making the `umin`'s
constant the default case.

Proof: https://alive2.llvm.org/ce/z/_N6nfs
Fixes: https://github.com/llvm/llvm-project/issues/162111
2025-11-04 18:35:40 +08:00
shore
546a783d81 [Attributor] Fix sanitizer for getAssumedMinTrailingZeros() 2025-11-04 15:01:18 +08:00
Shoreshen
00ee53cc7b
[Attributor] Propagate alignment through ptrmask (#150158)
Propagate alignment through ptrmask based on potential constant values
of mask and align of ptr.

---------

Co-authored-by: Shilei Tian <i@tianshilei.me>
2025-11-04 12:26:17 +08:00
Steven Wu
6747ea050d
[CAS] Add UnifiedOnDiskCache and OnDiskCAS (#114103)
Add a new abstraction layer UnifiedOnDiskCache that adds new functions
of disk space management and data validation that builds on top of
OnDiskGraphDB and OnDiskKeyValueDB.

Build upon UnifiedOnDiskCache, it is OnDiskCAS that implements
ObjectStore and ActionCache interface for LLVM tools to interact with
CAS storage.
2025-11-03 09:50:28 -08:00
Kazu Hirata
5ed8f48476
[Support] Use "using" instead of "typedef" (NFC) (#166130)
Identified with modernize-use-using.
2025-11-03 08:41:32 -08:00
Kazu Hirata
11c2923ccc
[ADT] Use "using" instead of "typedef" (NFC) (#166129)
Identified with modernize-use-using.
2025-11-03 08:41:25 -08:00
Jakub Kuderski
25ed923115
[ADT] Handle and document multiple matches in StringSwitch (#166177)
Specify that the first match is returned and bail out early when
processing multiple case values.
2025-11-03 11:40:18 -05:00
Jakub Kuderski
7c9f137b3c
[ADT] Drop unused include in StringSwitch. NFC. 2025-11-03 09:56:34 -05:00
Kazu Hirata
4eed68357e
[llvm] Use "= default" (NFC) (#166088)
Identified with modernize-use-equals-default.
2025-11-02 17:16:47 -08:00
Kazu Hirata
902b0bd04a
[llvm] Remove "const" in the presence of "constexpr" (NFC) (#166109)
"const" is extraneous in the presence of "constexpr" for simple
variables and arrays.
2025-11-02 15:52:44 -08:00
Kazu Hirata
707bab651f
[llvm] Remove redundant typename (NFC) (#166087)
Identified with readability-redundant-typename.
2025-11-02 13:15:16 -08:00
Fangrui Song
cea260e8b5 Object: Move instead of copy EFFile. NFC 2025-11-02 09:54:14 -08:00
Kazu Hirata
26c7d40999
[ADT, Support] Remove redundant typename (NFC) (#166045)
Identified with readability-redundant-typename.
2025-11-02 08:59:40 -08:00
Kazu Hirata
c9ef3d8eb8
[Transforms] Use "= default" (NFC) (#166043)
Identified with modernize-use-equals-default.
2025-11-02 08:59:24 -08:00
Jakub Kuderski
2de905d17a
[ADT] Deprecate variadic StringSwitch::Cases. NFC. (#166066)
Suggest the initializer_list overload instead.

For more context, see https://github.com/llvm/llvm-project/pull/163117.
2025-11-02 11:00:07 -05:00
Kazu Hirata
46ecf458e1
[Support] Drop unnecessary std::move in JSON.h (NFC) (#166027)
fixUTF8 takes StringRef, so we do not need std::move here.

Identified with performance-move-const-arg.
2025-11-01 23:20:27 -07:00
Kazu Hirata
31b8ba5670
[Analysis, CodeGen] Use ArrayRef instead of const ArrayRef (NFC) (#166026)
This patch improves readability by using "ArrayRef<T>" instead of
"const ArrayRef<T>" and "const ArrayRef<T> &" in function parameter
types.
2025-11-01 23:20:19 -07:00
Kazu Hirata
b82bde695e
[Analysis, CodeGen] Use "= default" (NFC) (#166024)
Identified with modernize-use-equals-default.
2025-11-01 23:20:11 -07:00
Ikhlas Ajbar
8565fbc838
[Hexagon] Add V81 instructions and intrinsics (#165903) 2025-11-01 23:55:38 -05:00
Kazu Hirata
a4c7ce2d5e
[IR, Analysis] Remove redundant declarations (NFC) (#166023)
These ConstantFold* functions are declared in both:

- llvm/include/llvm/Analysis/ConstantFolding.h
- llvm/include/llvm/IR/ConstantFold.h

However, the implementation resides in llvm/lib/IR/ConstantFold.cpp.

This patch removes the declarations in Analysis/ConstantFolding.h and
moves associated comments to IR/ConstantFold.h.
2025-11-01 19:56:08 -07:00
Jakub Kuderski
4c21d0cb14
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020)
Update all uses of variadic `.Cases` to use the initializer list
overload instead. I plan to mark variadic `.Cases` as deprecated in a
followup PR.

For more context, see https://github.com/llvm/llvm-project/pull/163117.
2025-11-02 00:12:33 +00:00
Jakub Kuderski
04f87c693c
[ADT] Deprecate variadic StringSwitch::CasesLower. NFC. (#166016)
Suggest the initializer_list overload instead. I plan to deprecate the
last variadic `.Cases` in a separate PR.

For more context, see https://github.com/llvm/llvm-project/pull/163117.
2025-11-01 20:10:52 +00:00
Kazu Hirata
e7a23c4020
[llvm] Remove redundant str() and c_str() (NFC) (#166012)
io.mapRequired takes StringRef as the key type.  As such, we do not
need to create extraneous copies with str().c_str() or str().

Identified with readability-redundant-string-cstr.
2025-11-01 12:42:06 -07:00
Kazu Hirata
b575edc757
[ADT, Support] Use "= default" (NFC) (#166007)
Identified with modernize-use-equals-default.
2025-11-01 12:41:43 -07:00
Kazu Hirata
ec8d85f08d
[IR] clang-format ConstantFold.h (NFC) (#166006)
I'm planning to modify this file.
2025-11-01 12:41:35 -07:00
Fabrice de Gans
92e80d41c4
Add missing LLVM_ABI annotations (#165908) 2025-11-01 10:55:02 -07:00
Alex MacLean
4a383f9ff7
[NVPTX] Add ex2.approx bf16 support and cleanup intrinsic definition (#165446) 2025-11-01 17:51:17 +00:00
Kazu Hirata
03d044971e
[ADT] Use a dedicated empty type for StringSet (NFC) (#165967)
This patch introduces StringSetTag, a dedicated empty struct to serve
as the "value type" for llvm::StringSet.  This change is part of an
effort to reduce the use of std::nullopt_t outside the context of
std::optional.
2025-11-01 10:41:47 -07:00
Kazu Hirata
334c9fd8c2
[CodeGenTypes] Remove redundant declarations (NFC) (#165972)
In C++17, static constexpr members are implicitly inline, so they no
longer require an out-of-line definition.

This patch also removes redundant "const" from the in-class definitions.

Identified with readability-redundant-declaration.
2025-11-01 09:25:19 -07:00
SahilPatidar
605a7d6534
REAPPLY [ORC] Add automatic shared library resolver for unresolved symbols. (attempt 2) (#165360)
This PR reapplies the changes previously introduced in
https://github.com/llvm/llvm-project/pull/148410.
It introduces a redesigned and rebuilt Cling-based auto-loading
workaround that enables scanning libraries and resolving unresolved
symbols within those libraries.

Fix build failures in LibraryResolverTest and silence symlink warning

This commit resolves issues observed in the build bots:

1. Silences the -Wunused-result warning by handling the return value
of ::symlink in LibraryResolverTest.cpp. Previously, ignoring
the return value triggered compiler warnings.

2. Fixes a linker error in OrcJITTests caused by an undefined
symbol: llvm::yaml::convertYAML. The test setup in
LibraryResolverTest.cpp now correctly links against the required
LLVM YAML library symbols.

3. Fixes persistent build bot failure caused by a path difference issue.

This resolves the build failures for PR
https://github.com/llvm/llvm-project/pull/148410 on the affected bots.
2025-11-01 11:19:28 +05:30
Justin Bogner
74ffe1cc16
[DirectX] Annotate interfaces for DLL export (#165914)
This is largely based off of #143615, but for the DirectX target which
is still in experimental.
2025-10-31 13:38:18 -07:00
Kazu Hirata
da5a3c959f
[MC] Remove SMRange(std::nullopt_t) (#165832)
This patch removes SMRange(std::nullopt_t) to reduce the number of
uses of std::nullopt outside the context of std::optional.  Since
there are only a handful of uses, this patch removes the constructor
without going through deprecation.

The use of std::nullopt here has its root in llvm::None, which was
used as a convenient way to indicate "nothing" before we migrated
llvm::Optional to std::optional.
2025-10-31 09:42:15 -07:00
Kazu Hirata
cfbb4cc312
[ADT] Remove ArrayRef(std::nullopt_t) (#165831)
ArrayRef(std::nullopt_t) has been deprecated since:

  commit 2529de5c935ad59e5f76d15890f857bf42817bc9
  Author: Kazu Hirata <kazu@google.com>
  Date:   Fri Jun 27 01:03:02 2025 -0700

Note that we've made at lease one release, llvmorg-21.1, with this
deprecation.
2025-10-31 09:42:07 -07:00