122056 Commits

Author SHA1 Message Date
Andy Kaylor
fa70ee45be
[CIR] Implement __builtin_flt_rounds and __builtin_set_flt_rounds (#190706)
This adds CIR handling for the __builtin_flt_rounds and
__builtin_set_flt_rounds builtin functions. Because the LLVM dialect
does not have dedicated operations for these, I have chosen not to
implement them as operations in CIR either. Instead, we just call the
LLVM intrinsic.
2026-04-06 17:11:49 -07:00
Andy Kaylor
511a7aacee
[CIR][NFC] Use tablegen to create CIRAttrToValue visitor declarations (#187607)
This change introduces TableGen support for indicating CIR attributes
that require a CIRAttrToValue visitor, adds the new flag to all
attributes to which it applies, and replaces the explicit declarations
with the tablegen output.
2026-04-06 17:11:25 -07:00
Andy Kaylor
aedd4e0850
[CIR] Handle static local var decl constants (#190699)
This adds the handling for the case where the address of a static local
variable is used to initialize another static local. In this case, the
address of the first variable is emitted as a constant in the
initializer of the second variable.
2026-04-06 16:13:23 -07:00
Yeongu Choe
228b6ae560
[CIR][CodeGen] Implement __builtin_signbit (#188433)
__builtin_signbit function checks if the sign bit of a floating-point
number is set to 0 or 1.
2026-04-06 16:11:13 -07:00
Yeongu Choe
df461c164c
[CIR][CodeGen] Implement __builtin_fpclassify (#187977)
I implemented CIR version of __builtin_fpclassify function.
2026-04-06 14:41:55 -07:00
Aadarsh Keshri
326593b4b4
[Support][Modules] Removed prepareForGetLock and its usages. Ensured parent directory exists when creating lock file. (#189888)
Following #187372
2026-04-06 12:37:32 -07:00
Daniel Thornburgh
fecf609998
Reland "[LTO][LLD] Prevent invalid LTO libfunc transforms (#164916)" (#190642)
This reverts commit 1ec7e86b3a779df2a0af3f37e58c8f5b3a398d7f after issue
#190072 was fixed.
2026-04-06 19:20:45 +00:00
Henry Jiang
412d6941e3
[VFS] Guard against null key/value nodes when parsing YAML overlay (#190506)
When a VFS overlay YAML file contains malformed content such as tabs,
the YAML parser can produce KeyValueNode entries where `getKey` returns
nullptr. The VFS overlay parser then passes the nullptr to
`parseScalarString`, which then calls dyn_cast.

Switch to `dyn_cast_if_present` for the above callsites and a few more.
2026-04-06 12:10:26 -07:00
Brian Cain
ab43cb8520
[Hexagon] Pass -pie to linker when PIE is the toolchain default (#189723)
The Hexagon driver only checked for an explicit -pie flag when
constructing the link command, ignoring the toolchain's PIE default. For
linux-musl targets, isPIEDefault() returns true (via the Linux toolchain
base class), so the compiler generates PIC/PIE code (-pic-level 2
-pic-is-pie) but the linker never received -pie.

This mismatch caused LTO failures: without -pie the linker sets
Reloc::Static for the LTO backend, which generates GP-relative
(small-data) references that lld cannot resolve.

Use hasFlag() to respect the toolchain default, and guard the -pie
emission against -shared and -r (relocatable) modes.
2026-04-06 13:58:43 -05:00
neonetizen
e11a31f4c7
[CIR][AArch64] Lower FP16 vduph lane intrinsics (#186955)
From #185382 

Lower `vduph_lane_f16` and `vduph_laneq_f16` to `cir::VecExtractOp`

Tests moved from `v8.2a-neon-instrinsics-generic.c` to a new CIR-enabled
test file.

I tried following from notes made in #185852 (BF16)
2026-04-06 19:12:34 +01:00
Andrzej Warzyński
38c53b3eb9
[clang][cir][nfc] Fix comments, add missing EOF (#190623) 2026-04-06 18:06:57 +01:00
Henrich Lauko
348295ac05
[CIR] Use data size in emitAggregateCopy for overlapping copies (#186702)
Add skip_tail_padding property to cir.copy to handle
potentially-overlapping
subobject copies directly, instead of falling back to cir.libc.memcpy.
When
set, the lowering uses the record's data size (excluding tail padding)
for
the memcpy length. This keeps typed semantics and promotability of
cir.copy.

Also fix CXXABILowering to preserve op properties when recreating
operations,
and expose RecordType::computeStructDataSize() for computing data size
of
padded record types.
2026-04-06 18:24:10 +02:00
albertbolt1
8d7823ea8f
[CIR][AArch64] Added vector intrinsics for shift left (#187516)
Added vector intrinsics for 
vshlq_n_s8
vshlq_n_s16
vshlq_n_s32
vshlq_n_s64
vshlq_n_u8
vshlq_n_u16
vshlq_n_u32
vshlq_n_u64

vshl_n_s8
vshl_n_s16
vshl_n_s32
vshl_n_s64
vshl_n_u8
vshl_n_u16
vshl_n_u32
vshl_n_u64

these cover all the vector intrinsics for constant shift 

the method followed 

1) the vectors for quad words are of the form `64x2`, `32x4`, `16x8`,
`8x16` and the shift is a constant value but for shift left we need both
of them to be vectors so we take the constant shift and convert it into
a vector of respective form, for `64x2` we convert the constant to
`64x2`, I have learnt that this process is also called **splat**
2) After splat we have that the lhs and rhs are of the same size hence
the shift left can be applied
3) There is one issue though, the ops[0] is not of the right size, for
quad words it falls back to the default int8*16 in the function, so I am
converting it to the required size using bit casting, `8x16` = `64x2` so
we can bitcast and get the vector array in the right form.


Wrote the test cases for all the intrinsics listed above

#185382
2026-04-06 17:00:38 +01:00
Erich Keane
297a70c9b5
[CIR] Implement global decomposition declarations (#190364)
No real challenge to these, it is effectively a copy/paste of the
classic codegen as it just requires we properly emit the holding
variable. The rest falls out of the rest of our handling of variables.
2026-04-06 07:38:21 -07:00
Timm Baeder
59e899e16b
[clang][bytecode] Don't unref constexpr-unknown references (#190177)
If the pointer for a reference is constexpr-unknown, use the pointer
itself instead, instead of dereferencing it. Unfortunately, that means
constexpr-unknown pointers to reach a lot more places than before.
2026-04-06 15:52:17 +02:00
Devajith
ba286040c9
[clang-repl] Use canonical types in QualTypeToString (#190528)
Use the canonical type when generating type strings to ensure sugared
(e.g. `AutoType`, `DecltypeType`) are resolved before calling
getFullyQualifiedType.

This will revert a few commits that were added to fix these assertions.

---------

Co-authored-by: Harald van Dijk <hdijk@accesssoftek.com>
2026-04-05 18:09:39 +02:00
Matt Arsenault
144c324380
clang: Make --cuda-gpu-arch translation test comprehensive for AMDGPU (#190509) 2026-04-05 15:00:54 +02:00
Henrich Lauko
942e1082ac
[CIR] Convert global_visibility from attribute to property (#190488)
Replace CIR_VisibilityAttr with
DefaultValuedProp<EnumProp<CIR_VisibilityKind>>
for global_visibility on GlobalOp and FuncOp. This removes the need for
custom
parse/print functions and simplifies callers to use direct enum values
instead
of wrapping/unwrapping VisibilityAttr.
2026-04-05 07:35:53 +02:00
Timm Baeder
66483dfe34
[clang][AST][NFC] Add default value to Expr::isConstantInitializer() parameter (#190313)
Almost every caller passes `false` for `ForRef`, or rather, doesn't care
what the value is. Use a default value instead.
2026-04-05 06:54:06 +02:00
Younan Zhang
257cc5ad89
[Clang] Fix concept cache for normalized fold expressions (#190312)
When both outer and inner pack substitution indexes are present, we
should cache both. Otherwise we will have wrong cached result.

This is a regression fix so no release note.

Fixes https://github.com/llvm/llvm-project/issues/190169
2026-04-05 10:36:50 +08:00
Serosh
17ed1e6c4b
[clang] diagnose block pointer types as invalid for constant template parameters (#190464)
Fixes a crash by making it ill-formed to have a constant template
parameter with a block pointer type.

Fixes #189247
2026-04-04 22:24:19 -03:00
Matheus Izvekov
7fd02b32f9
[clang] NFC: Add test case for #178324 and mark it as fixed (#190490)
Issue #178324 was actually fixed by #187755

We lost the "declaration does not declare anything" warning since the
regression was introduced, but that was because:
1) Since #78436 we treat __builtin_FUNCSIG in a dependent context
effectivelly as if it contained a template parameter.
2) Our decltype implementation treats eexpressions containing template
parameters as if they were completely opaque (but alas this goes against
the spec, which says in [temp.type]p4 this should be looking only at
type dependence).
3) Since the decltype is opaque, we don't know what lookup will find, so
we can't issue the warning because we don't know if we are going to end
up with a type or an expression.

Fixes #178324
2026-04-04 19:10:29 -03:00
Matt Arsenault
4066590d8e
clang: Stop assuming one toolchain covers all GPUArchs (#190369) 2026-04-04 13:27:53 +02:00
Anders Waldenborg
da0aec2990
[clang][test] Fix solaris ld driver test to not assume gnu ld location (#186250) 2026-04-04 16:25:36 +07:00
Petr Hosek
3080198cc3
Revert "[clang] Fix conflicting declaration error with using_if_exists" (#190441)
Reverts llvm/llvm-project#167646
2026-04-03 19:25:34 -07:00
Peter Collingbourne
5c355ef216
Remove unnecessary -O1 from clang command.
It is generally inappropriate to pass -O flags to IRGen tests because
it makes them sensitive to optimizer behavior. #186548 makes a change to
optimizer behavior that would cause this test to fail without this change.

Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/190417
2026-04-03 15:28:34 -07:00
Jackson Stogel
3f37512c8f
[DiagnosticInfo] Allow std::string_view in DiagnosticBuilder operator<<. (#190374)
After a68ae7b0cc0922b79114aabe8cf1ec8dc68524d7, calling `<<` with a
`std::string_view` gives:

```
clang/include/clang/Basic/Diagnostic.h:1319:8: error: use of overloaded operator '<<' is ambiguous (with operand types 'const StreamingDiagnostic' and 'const std::string_view')
 1319 |     DB << V;
      |     ~~ ^  ~
```
2026-04-03 15:02:14 -07:00
Matt Arsenault
36e781ceb4
clang: Remove dead null toolchain check (#190402) 2026-04-03 23:35:18 +02:00
Eli Friedman
9471fabf8a
[clang] Fix issues with const/pure on varargs function. (#190252)
There are two related issues here. On the declaration/definition side,
we need to make sure the markings are conservative. Then on the caller
side, we need to make sure we don't access parameters that don't exist.

Fixes #187535.
2026-04-03 13:57:35 -07:00
Florian Hahn
6476619f30
[Matrix] Use matrix element type for TBAA nodes. (#190029)
Matrix loads and stores are accesses of their element types. Emit TBAA
nodes using their element type to allow more precise TBAA alias
analysis.

PR: https://github.com/llvm/llvm-project/pull/190029
2026-04-03 20:11:04 +00:00
Alexey Karyakin
6f464d1b3a
[Hexagon] Clean up library and include paths and fix --sysroot (#188824)
Unify include and library paths by reusing common code to compute path
prefixes. First, determine the effective sysroot by choosing a
user-provided sysroot, "../target/<triple>", or "../target/hexagon",
in the order of precedence. Based on the sysroot, derive the standard
include path, C++ include path, and base library path.

Fix the default -L library paths so they are taken from the external
sysroot, when one specified. Previously, these paths were always
relative to the install directory and sysroot was ignored.

Remove certain locations from considerations, as there are never used
for the corresponding purpose in existing sysroots:
- fallback to install path, typically "../target/bin", as the base path
  when other sysroot cannot be found;
- similarly, fallback to "../target/" for startup files;
- "../target/bin" for program paths as there are no program files in
  current sysroots.

Other minor changes:
- use windows-correct path delimiting;
- enable hexagon-toolchain-linux.c test for windows hosts.
2026-04-03 14:44:19 -05:00
Amr Hesham
a4632f6294
[Clang][Sema] Prevent implicit casting Complex type to Vector (#187954)
Emitting an error message in case of implicit casting of a complex type
to a built-in vector type in C

Fixes: #186805
2026-04-03 21:10:58 +02:00
Andy Kaylor
68b6a27771
[CIR] Use destination type when emitting constant function ptrs (#189741)
This updates the CIR constant emitter to use the correct destination
type when emitting a constant initializer for a structure that might be
initialized with non-prototyped function pointers. We were previously
using the type from whatever function declaration we had, but this may
not be the correct type.

This change also updates the `replaceUsesOfNonProtoTypeWithRealFunction`
to ignore global initializer uses, which do not need to be updated after
this change.
2026-04-03 10:58:46 -07:00
Henrich Lauko
f26b30ea35
[CIR] Auto-generate matchAndRewrite for one-to-one CIR-to-LLVM lowerings (#190326)
When a CIR op specifies a non-empty `llvmOp` field, the lowering
emitter now generates the `matchAndRewrite` body that converts the
result type and forwards all operands to the corresponding LLVM op.
This removes 27 boilerplate lowering patterns from LowerToLLVM.cpp.

Ops needing custom logic (FMaxNumOp/FMinNumOp for FastmathFlags::nsz)
override `llvmOp = ""` to retain hand-written implementations.

Also fixes llvmOp names (TruncOp -> FTruncOp, FloorOp -> FFloorOp)
and adds a diagnostic rejecting conflicting llvmOp + custom constructor.
2026-04-03 19:29:03 +02:00
Amr Hesham
2108252f0e
[clang] Fixed a crash when explicitly casting to atomic complex (#172163)
Fixed a crash when explicitly casting a scalar to an atomic complex.

resolve: #114885
2026-04-03 19:28:20 +02:00
Henrich Lauko
dec90ffbc9
[CIR] Fix record layout for [[no_unique_address]] fields (#186701)
Fix two bugs in CIR's handling of `[[no_unique_address]]` fields:

- Record layout: Use the base subobject type (without tail padding)
instead of the complete object type for [[no_unique_address]] fields,
allowing subsequent fields to overlap with tail padding.
- Field access: Insert bitcasts from the base subobject pointer to the
complete object pointer after cir.get_member for potentially-overlapping
fields, so downstream code sees the expected type.
- Zero-sized fields: Handle truly empty [[no_unique_address]] fields by
computing their address via byte offsets rather than cir.get_member,
since they have no entry in the record layout.

A known gap (CIR copies 8 bytes where OG copies 5 via
`ConstructorMemcpyizer`) is noted for follow-up.
2026-04-03 19:07:25 +02:00
Jan Svoboda
7f9e4fe708
[clang] Extract in-memory module cache writes from ASTWriter (#190062)
This PR extracts the write to the in-memory module cache from within
`ASTWriter` into `CompilerInstance.` This brings it closer to other
module cache manipulations, making the ordering much more clear and
explicit.
2026-04-03 09:18:33 -07:00
Artemiy
dc83ad2b37
[CIR] Fix incorrect CIR_GlobalOp.global_visibility assembly format (#189673)
Closes #189666 .

Fix incorrect printing and parsing of `cir.global` if
`global_visibility` attribute is present. Incorrect assembly format
```
(`` $global_visibility^)?
```

Resulted in keyword sticking to previous word and producing incorrect
cir like this:
```
cir.globalhidden external dso_local @hidden_var = #cir.int<10> : !s32i {alignment = 4 : i64} loc(#loc22)
cir.global "private"hidden internal dso_local @hidden_static_var = #cir.int<10> : !s32i {alignment = 4 : i64} loc(#loc24)
```

Using custom parser/printer that is used in `cir.func` parser fixes this
issue and makes printed/parsed attribute for functions and global values
consistent.

Also added tests for both global values and functions.
2026-04-03 09:17:44 -07:00
Andy Kaylor
641276751d
[CIR] Fix mixing of catch-all and type-specific catch handlers (#190285)
If a try block has a catch-all handler and one or more type-specific
catch handlers, we were failing to generate the null type specifier when
lowering from CIR to LLVM IR. This change fixes that problem.

Assisted-by: Cursor / claude-4.6-opus-high
2026-04-03 08:38:55 -07:00
Andy Kaylor
5b56352757
[CIR] Implement cleanups for temporaries with automatic duration (#189754)
This implements handling for cleanup of temporary variables with
automatic storage duration. This is a simplified implementation that
doesn't yet handle the possibility of exceptions being thrown within
this cleanup scope or the cleanup scope being inside a conditional
operation. Support for those cases will be added later.
2026-04-03 08:38:06 -07:00
Erich Keane
11d65dc8c2
Revert "[CIR][NFC] Add NYI for OMPSplitDirective stmt" (#190346)
Reverts llvm/llvm-project#190329

The patch this depends on got reverted.
2026-04-03 14:40:42 +00:00
Matt Arsenault
34ec1870ae
clang/AMDGPU: Refactor triple adjustments (#190343)
Factor this similar to the ARM case for future
expansion. The difference being -mcpu is treated as
an alias for -mcpu instead of something separately
useful.

I don't understand this mutation of the triple into
spirv64. The only test where this appears to matter
does not use -mcpu. Previously this would only match
for -mcpu, but this would change the behavior to prefer
-march before falling back to -mcpu.
2026-04-03 16:17:34 +02:00
Erich Keane
0a3fdd30e5
[CIR] Handle vtable-lowering-with-incomplete types (#190216)
The NYI diagnostic in getFunctionTypeForVTable showed up a few times in
testing, so this patch is attempting to fix that up.

The reproducer here is a function type for a vtable that has an
incomplete type in it(return or parameter). Classic codegen chooses to
represent this as an opaque type.

This patch instead removes the special v-table handling here, so that we
can instead just represent the types as incomplete record types.

At the moment, this patch ends up lowering incomplete types as 'empty'
types in LLVM-IR, which we may find we need to modify in the future,
however at the moment, it seems to work.

This patch ALSO changes the definition of RecordType::isSized to only be
true for complete types, which prevents a number of other things from
attempting to add attributes/check the size of the type/etc, but those
are irrelevant for the purposes of vtable emission.
2026-04-03 05:59:46 -07:00
Erich Keane
2c734b3951
[CIR] Implement top level 'ExportDecl' emission (#190286)
This is a pretty simple one, its just a type of decl-context. The actual
exporty-ness is handled on a per-declaration basis.

This patch just makes sure we emit them, as I suspect this will reveal
quite a bit more issues in module code I suspect.
2026-04-03 05:59:25 -07:00
Amr Hesham
0932472f3b
[CIR][NFC] Add NYI for OMPSplitDirective stmt (#190329)
Fix the warning of missing OMPSplitDirective statement in the emitStmt
switch
2026-04-03 14:45:48 +02:00
alexpaniman
b9924c76da
[clang] Make -dump-tokens option align tokens (#164894)
When using `-Xclang -dump-tokens`, the lexer dump output is currently
difficult to read because the data are misaligned. The existing
implementation simply separates the token name, spelling, flags, and
location using `'\t'`, which results in inconsistent spacing.

For example, the current output looks like this on provided in this
patch example **(BEFORE THIS PR)**:

<img width="2936" height="632" alt="image"
src="https://github.com/user-attachments/assets/ad893958-6d57-4a76-8838-7fc56e37e6a7"
/>

# Changes

This small PR improves the readability of the token dump by:

+ Adding padding after the token name and after the spelling (the
padding amount was chosen empirically to produce good average
alignment).
+ Swapping the order of location and flags (since flags can take up a
lot of space and disrupt alignment).

The result is a more readable output **(AFTER THIS PR)**:

<img width="1470" height="315" alt="image"
src="https://github.com/user-attachments/assets/c24f24e5-a431-42cc-b5b6-232bac5c635e"
/>
2026-04-03 08:33:36 -04:00
theRonShark
00aede8f19
Revert "[Clang][OpenMP] Implement Loop splitting #pragma omp split directive " (#190335)
Reverts llvm/llvm-project#183261

15 new lit tests failing in openmp
2026-04-03 12:27:07 +00:00
Donát Nagy
c80443cd37
[NFC][analyzer] Eliminate SwitchNodeBuilder (#188096)
This commit removes the class `SwitchNodeBuilder` because it just
obscured the logic of switch handling by hiding some parts of it in
another source file.
2026-04-03 09:46:06 +02:00
Amit Tiwari
1972cf64fd
[Clang][OpenMP] Implement Loop splitting #pragma omp split directive (#183261)
OpenMP 6.0 Loop-splitting directive `#pragma omp split` construct with `counts`
clause
2026-04-03 10:42:31 +05:30
Weibo He
bc11c85b6b
[clang][CodeGen] Emit coro.dead intrinsic to improve coroutine allocation elision (#190295)
Part 4/4: Implement HALO for coroutines that flow off final suspend.
Parent PR: #185336
2026-04-03 02:06:10 +00:00