[Clang] Transform SubstNonTypeTemplateParmExpr replacements in a constant-evaluated context (#196791)
Fixes #175831.
When transforming a `SubstNonTypeTemplateParmExpr`,
`TreeTransform::TransformSubstNonTypeTemplateParmExpr` calls
`Sema::CheckTemplateArgument` so that any sema annotations (such as
implicit casts) that were stripped from the replacement are recovered.
This is done in whatever evaluation context the node happens to appear
in after substitutions.
Since the normalization of constraints, a `SubstNonTypeTemplateParmExpr`
can end up inside an unevaluated operand, so the replacement gets
rebuilt in an unevaluated context.
Entities it refers to are then not odr-used: for example, when a call
materializes a by-value function parameter of class type, the copy
constructor is never marked odr-used and its definition is never
instantiated.
The constant evaluation performed by `CheckTemplateArgument` afterwards
[11 lines not shown]
[Clang] Fixed an assertion in constant evaluation when using a defaulted comparison operator in a union (#198830)
Fixes an assertion failure by decoupling `IsTrivialMemoryOperation` from
assignment operators.
fix #147127
[libc][complex] Add cargf and carg functions to libc complex math (#204087)
This PR adds carg and cargf function to libc complex and also add test
cases to cover some special inputs.
---------
Signed-off-by: jinge90 <ge.jin at intel.com>
[MLIR][XeGPU] Fix order remapping in layout transpose (#205212)
LayoutAttr::transposeDims and LayoutAttr::isTransposeOf mishandled the
`order` field when transposing a layout. The `order` field is
fundamentally different from the size-valued fields (sg_layout, sg_data,
inst_data, lane_layout, lane_data): its values are dimension indices
(order[0] is the fastest-varying dim), not per-position sizes. The two
require different transpose rules:
- Size fields — reindex by position: new[i] = orig[perm[i]]
- order — relabel values through the inverse permutation: newOrder[i] =
inversePerm[origOrder[i]]
Both functions incorrectly applied the size-field rule to `order`.
Because the bug was applied consistently in both places, it stayed
hidden for trivial/symmetric (e.g. 2D [1,0]) permutations, where the two
rules happen to coincide. It only surfaces for non-trivial permutations
such as the 3D [1,0,2] produced by a broadcast→transpose chain.
Assist-by-Claude
[3 lines not shown]
[RISCV] Emit .option arch extensions without the "experimental-" prefix (#205471)
We currently emit the "experimental-" prefix in .option arch, e.g.
`.option arch, +experimental-zicfiss`, but the assembler can't parse
that back.
There are two ways to fix this:
1. Teach the assembler to accept `.option arch, +experimental-zicfiss`.
2. Emit `.option arch, +zicfiss` instead of `.option arch,
+experimental-zicfiss`.
This patch takes the second approach, which better fits the .option arch
syntax we defined. Experimental extensions are still guarded by
`-menable-experimental-extensions`.
[DAG] Fix illegal type in srl(bitcast(build_vector)) fold (#205074)
The fold
```
(srl (bitcast (build_vector e1, ..., eN)), (N-1) * eltsize) -> (zext eN)
```
added in #181412 built the result through a narrow element integer type,
which
can be illegal (e.g. i16 on RV32 with the P extension, where `<2 x i16>`
is
legal). When the fold runs in the last DAG combine that illegal type
hits the
"Unexpected illegal type!" assert.
Build the result directly in the result type `VT` and mask off the high
bits
instead:
[13 lines not shown]
[libclc] Delete wrong implementation nvptx clc_isinf (#205699)
The file calls __nv_isinf which return 1 for true on vector input, while
the generic clc_isinf which return -1 for true on vector input. Using
nvptx clc_isinf in OpenCL isinf violates OpenCL spec.
Found the issue in https://github.com/intel/llvm/pull/22413
[x86] Handle implicit sections when determining if a global is large (#204247)
Just like explicit sections.
We were seeing globals with implicit sections marked large under the
medium code model.
Assisted-by: Gemini
[libc][stat] Move internal statx type definition into OSUtil/linux (#203975)
This PR refactors the internally defined `statx` buffer to a shareable
location so other LLVM-libc linux entrypoints may call `statx` without
concern for name conflicts around `linux/stat.h`.
Specifically, this PR moves `libc/src/sys/stat/linux/kernel_statx.h` to
`libc/src/__support/OSUtil/linux/stat/` and splits it into two files,
`kernel_statx_types.h` + `stat_via_statx.h`.
This will be used by `realpath`.
[Instrumentor] Add runtime examples: [1/N] A flop counter
This adds a instrumentor-tools folder into compiler RT to showcase
use cases of the instrumentor. The initial example is a program that,
via instrumentation, counts the number of flops performed. Call and
intrinsic support will follow after #198042.
Partially developped by Claude (AI), tested and verified by me.
[Instrumentor] Add runtime examples: [1/N] A flop counter
This adds a instrumentor-tools folder into compiler RT to showcase
use cases of the instrumentor. The initial example is a program that,
via instrumentation, counts the number of flops performed. Call and
intrinsic support will follow after #198042.
Partially developped by Claude (AI), tested and verified by me.
[Driver][SYCL] Treat stdin as C++ when -fsycl is active (#204968)
1723b7a30145 added a frontend check that rejects C inputs when SYCL mode
is active (since SYCL requires C++). The stdin path in BuildInputs
hardcoded TY_C regardless of driver mode, so `-fsycl -dM -E -` would
pass -x c to cc1 and trigger the new diagnostic.
Fix: use TY_CXX for stdin when IsSYCL.
Also, upstream a downstream test that fails due to 1723b7a30145.
---------
Co-authored-by: Claude Sonnet 4.6 <noreply at anthropic.com>
[IR] Fix invalid debug metadata diagnostic kind (#205648)
This type is only ever passed to LLVMContext::diagnose directly, and
there are no downcasts to this type, so classof is effectively dead, but
we should fix this oversight.
Fixes #205340
[libc++] Implement P1885R12: `<text_encoding>` (#141312)
Resolves #105373, resolves #118371 and resolves #105332
- Implements `<text_encoding>`
- Adds availability macros for LLVM 23.
- The data is stored in three tables:
- One giant string split by null-terminators to represent the aliases
- An index table which stores indexes into the string, each entry
representing the first character of an alias
- Text encoding data, which stores an index to the index table, the MIB,
and the number of aliases the encoding has.
Storing it in the above manner allows us to make significant savings in
binary file size and required runtime storage for the data.
As required by the LLVM Project's AI use policy:
- The implementation for `__get_locale_encoding(const char*)` for
Windows has been developed with the assistance of AI.
[3 lines not shown]
[clang][ssaf] Shorten directory name to ScalableStaticAnalysis (#204697)
The directory name ScalableStaticAnalysisFramework produces build paths
that exceed Windows' MAX_PATH limit (260 chars) on downstream CI bots.
The clang-ssaf-format / clang-ssaf-linker tool names and SSAF-prefixed
source filenames are unchanged.
Assisted-By: Claude Opus 4.7
---------
Co-authored-by: Aviral Goel <goel.aviral at gmail.com>
Co-authored-by: Aviral Goel <aviralg at users.noreply.github.com>
[Instrumentor][FIX] Ensure CXX headers are available (#205693)
Try to address failure in #205221, which results in <atomic> not found.
This is CMake code copied from other compiler-rt projects using
<atomic>.
[Clang] Don't suppress vtable emission for classes with -fmodules-debuginfo (#204662)
847f9cb0e868 made `Sema::DefineUsedVTables` skip
`Consumer.HandleVTable()` when `Class->shouldEmitInExternalSource()` is
true. This works for named C++20 modules as they have an object file,
but does not hold for -fmodules-debuginfo / -fpch-debuginfo.
This patch additionally gates that on `Class->isInNamedModule()`. This
is the same pattern used by the rest of codegen for this situation.
Needing to check this everywhere is a bit unfortunate. It would be good
to eventually refactor this class of checks to have clearer semantics
around named modules, debug info, and -fmodules-codgen.
Fixes https://github.com/llvm/llvm-project/issues/198587
Assisted-by: Claude Code: opus-4-8
[lldb][NFC] Remove ConstString from Language::MethodNameVariant (#205688)
Language::MethodNameVariant is for when a given method name may have
several language-defined variants. For example, we may see an
objective-C method name with a category that should be searchable via
the name without the category.
The ObjCLanguage plugin computes these names without checking that they
are actually useful or even exist. Because these variant names are
stored in ConstString, they will live forever even if they are never
used.
[RISCV][clang] Use fcf-protection flag in Multilib Selection (#205202)
This ensures that we can separate out multilibs that are or are not
built with control flow protection enabled.
The initial version of the patch claims all values of these flags are
incompatible. It might be the case that we could make this logic more
complex if some versions do become compatible.
[Instrumentor] Add runtime examples: [1/N] A flop counter (#205221)
This adds a instrumentor-tools folder into compiler RT to showcase
use cases of the instrumentor. The initial example is a program that,
via instrumentation, counts the number of flops performed. Call and
intrinsic support will follow after #198042.
Partially developed by Claude (AI), tested and verified by me.