[libc++][Android] Guard SELinux filesystem subtests and forward stdin in adb_run.py
Follow-up to #243692 addressing the remaining Android filesystem and `std::{cin,wcin}` `LIBCXX-ANDROID-FIXME` tests:
- Add `has-no-{fifos,hardlinks,sockets}` lit features to guard filesystem subtests, including on Android where SELinux blocks them for the `shell` user in `/data/local/tmp` on Android N (API 24) and up, allowing the rest of those tests to run.
- Forward non-TTY stdin via a temporary file in `adb_run.py` when `shell_v2` is unavailable so `std::{cin,wcin}` tests don't hang waiting for EOF on API 23.
Assisted-by: Gemini
[clang] Emit #embed missing file error even with -MD (#247362)
In 2e89b719 we accidentally made #embed silently ignore a missing file
if any dependency file was being emitted, when that behaviour should
only be when suppressing missing file errors (e.g. -MM -MG) to match
what we do for missing headers.
Fixes #247359
rdar://193739474
[libc] Add UTF-16 support in CharacterConverter [1/6] (#230434)
This pull request adds support of UTF-16 in `CharacterConverter`. It
does not use the functionality yet. Follow-ups will add uses to the
functionality that this PR implements.
Aside from `push(char16_t)` and `pop_utf16()` that implements the
conversion, another function `isPartiallyPopping()` is added, which
distinguishes if the current state is "partially pushing" or "partially
popping". Since UTF-16 can have 2 code units for 1 code point, this
reporting function will be crucial to the follow-up uses.
For `isPartiallyPopping()` to work, UTF-8 overlong encodings must be
rejected. They pose a security hazard anyway. This PR adds new checks
that reject UTF-8 overlong encodings. This PR also adds new checks that
reject `>U+10FFFF` inputs.
Tests are added to cover the above-mentioned functionalities. This
includes testing that `isPartiallyPopping()` works in UTF-8 -> UTF-32
conversions, which the function is designed to work.
[4 lines not shown]
[MergeFunctions] Only merge functions that have address insignificance
Implements the semantics in #247279.
I haven't empirically measured the impact of this given this pass isn't
on in any of the default pass pipelines, but it should not be large.
Helps with #229138.
Assisted-By: LLM
Reviewers: efriedma-quic, nikic
Pull Request: https://github.com/llvm/llvm-project/pull/247311
[Clang][OpenMP][NFC] Make dims AST print tests conforming (#247462)
OpenMP 6.1 specifies the following restriction for the `num_threads`
clause:
> If the dims-modifier is specified, its dimensionality argument must
not exceed the number of dimensions specified by the thread-limit-var
ICV.
Four AST print test cases specify `num_threads(dims(2): ...)` alongside
or inside a construct with `thread_limit(dims(1): ...)`. This commit
updates their thread limits to two dimensions so the test cases conform
to this restriction.
A separate PR can add Sema diagnostics for cases where the conflicting
dimensions are visible to the compiler.
Assisted by OpenAI Codex GPT-6 Sol.
[CIR][AMDGPU][SPIR-V] Wire AMDGCN SPIR-V into the call convention lowering pass (#238348)
Use the AMDGPU ABI for AMDGCN SPIR-V kernels, with SPIR-V address spaces
This matches classic codegen: structs pass byref in addrspace(2) and
pointers in addrspace(1)
[X86] Emit the import call optimization table in a deterministic order (#247679)
X86AsmPrinter kept the import call sites per section in a DenseMap keyed
by MCSection pointers and emitted the .retplne table by iterating it, so
the order of the sections in the table depended on pointer values and
changed between runs. Use a MapVector, like AArch64AsmPrinter does.
Compile time and memory are unchanged on a module with 10000 such
sections.
The table checks in win-import-call-optimization.ll had no colons, so
FileCheck ignored them, and their call kinds were out of date. Fix both.
Assisted-by: Claude Code (Claude Opus 5.5)
[X86] Add VMTRUNC/VMTRUNCS/VMTRUNCUS upper elements handling (#247633)
computeKnownBitsForTargetNode - the masked truncations zero the
elements above the truncated ones, like VTRUNC/VTRUNCS/VTRUNCUS.
isGuaranteedNotToBeUndefOrPoisonForTargetNode - these upper elements
are never undef/poison. #245048 adds the same handling for VTRUNC.
Assisted-by: Claude Code (Claude Opus 5.5)
[AMDGPU] Re-enable AAInstanceInfo in AMDGPUAttributor
This was enabled and then disabled because of its compile time impact. This
recent changes, the compile time issue should have been resolved.
[X86] combineSelect - only create VMTRUNC from a legal source type
The select(c, trunc(x), y) -> VMTRUNC fold for targets without BWI
(#201339) runs before type legalization. With AVX512VL and a 256-bit
preferred vector width, v16i32 and v8i64 are illegal, and the type
legalizer can't split the operand of the target node: "Should not
custom lower this!". Reachable from C with -mavx512f -mavx512vl
-mprefer-vector-width=256; real code such as libwebp's sharpyuv hits
it. The same fold also crashed with "use-soft-float", where no vector
type is legal.
Assisted-by: Claude Code (Claude Opus 5.5)
[CIR] Add TBAA support for scalar loads and stores (#246079)
Port classic CodeGenTBAA to CIR. CIRGen attaches access tags to
`cir.load` and `cir.store`, following classic CodeGen at each site where
an access is built, and LowerToLLVM turns them into `!tbaa` metadata.
The attributes follow the ClangIR incubator, except that type
descriptors store no CIR type. Tags therefore survive passes that
rewrite types, and lowering does not need the AST.
Left for follow-ups: vtable-pointer tags, `tbaa.struct`, atomics,
`!llvm.errno.tbaa` (needed for `-fmath-errno`), and `-new-struct-path-tbaa`.
This relates to #160387 and #169226.
Co-authored-by: PikachuHy <pikachuhy at linux.alibaba.com>
[DebugInfo][FLMD] Add MIR printing/parsing support for !!dbgLoc
Extending from the IR printing/parsing support, this adds !!dbgLoc parsing
to the MIR parser, and has the MIR printing passes access the conversion
layer via the ModuleSlotTracker. Just as with regular debug-location
attachments in MIR, we print the attachments in their expanded/in-line form
if the same attachment did not appear in the IR, because the IR module may
have already been printed, and thus we cannot add new metadata IDs to the
printed output - in this case, we cannot add to the SrcLocs or InlinedAts
storage arrays.
Note that we can meaningfully print the SrcLoc in-line, but not the
InlinedAt, since that has a unique identity - this is a case that is very
unlikely to be stimulated however, and (I believe) already exists as a
deficiency in current IR, so we accept its absence for now. If this were
to become a significant issue, then we could implement in-line InlinedCall
printing.
AI assistance was used to partially generate the test input in this patch;
all test comments/checks were hand-written.
[DebugInfo][FLMD] Add Bitcode read/write support for !!dbgLoc
This patch adds support for reading and writing !!dbgLoc attachments to
instructions/debug records (FLDebugLoc), and also for !DIDbgLoc which
contains an FLDebugLoc argument. Besides adding the bitcode representation
itself, this adds support for converting from FLDebugLoc->DILocation in the
MetadataLoader.
[DebugInfo][FLMD] Add parsing for expanded !!dbgLoc attachments
This patch expands the textual IR parsing support added previously, to
also support parsing "expanded" FLDebugLocs, where the SrcLoc fields (line,
column, scope) are all printed in-line. This adds some complications to
parsing, primarily in that it requires us to read and write to the
MDFunctionLocalContext pre-verifier, and that we need yet another form of
"forward-reference" state tracking.
[DebugInfo][FLMD] Add !!dbgLoc and !DIDbgLoc textual IR parsing
This patch adds support for parsing !!dbgLoc attachments to Instructions
and DbgRecords, and also !DIDbgLoc nodes which contain !!dbgLoc fields.
This patch necessarily makes use of the DebugLoc Conversion Map, which is
used this time to read FLDebugLocs and convert to DILocations.
This patch doesn't add support for parsing the expanded form of !!dbgLoc;
that is added in the next patch, which extends the FLMDAttachment variant
to include expanded dbgLocs.
AI assistance was used in generating the test IR added in this commit; all
comments are human-written and the test expects are generated by
update_test_checks, and the IR is unmodified (besides comments) opt output.
[DebugInfo][FLMD] Add printing support for FLDebugLoc+DIDbgLoc
This patch follows up on the preceding patch by adding support for
printing FLDebugLoc as an attachment `!!dbgLoc(...)` for instructions and
debug records, and for printing DIDbgLoc nodes which contain a !!dbgLoc
operand.
A major component of this patch is the addition of a "DebugLoc conversion"
layer, which allows for conversion between DILocation and FLDebugLoc
formats. This is currently only used for converting DILocation->FLDebugLoc
for printing, but provides a common mechanism that will later be used for
FLDebugLoc<->DILocation conversion for printing+parsing, switching between
the two depending on which format is currently being used in-memory. Due to
the constraint of needing to support consistent conversions at different
points in time (primarily for MIR printing and lazy bitcode
materialization), some information is stored in the LLVMContext, including
a third representation of source location information, stored in a format
which is easy to convert to/from either existing format.
[11 lines not shown]
[FLMD][DebugInfo] Add classes for function-local DebugLocs
This patch adds two new classes. The first, FLDebugLoc, represents a
DebugLoc in a function-local context; combined with the correct
`!MDFunctionLocalContext`, this class is equivalent in information to a
`!DILocation`, with some exceptions (IsImplicitCode is not included,
IRLayers are to-be-implemented). The second, DIDbgLoc, is a new
MDNode type which wraps an `MDFunctionLocalContext*` and an `FLDebugLoc`.
This makes it an effective substitute for `DILocation` in metadata,
able to replicate the interface of `DILocation` entirely. Implementation
of this interface is added in a later patch.
Add MDFunctionLocalContext support to update_test_checks
The new `!MDFunctionLocalContext` metadata type is unique in that it may
be printed across multiple lines, which causes the update_test_checks
script to only generate checks, and transitively find other metadata, for
the opening line. This patch fixes this by recording multiple lines for
metadata, where the first line ends with '[' and the last line ends with
'])', matching the printed format of `!MDFunctionLocalContext`.
[DebugInfo][FLMD] Add bitcode printing/parsing for function context (#236801)
This patch adds support for bitcode printing/parsing for
MDFunctionLocalContext. This is an unusual entry in that it contains
multiple variable-length arrays, and collectively comprises a
potentially very large (technically up to ~2^32, realistically >10000 is
possible) number of records. There is no abbreviation, since the
existing abbreviation mechanism does not easily translate to this case.
Also unique is that, as with the LLParser, we use a custom forward
reference resolution. In this case, we track the metadata IDs rather
than maintaining a TrackingMDRef, and resolve these at the general
metadata resolution step, where the MetadataList has been finalized.
Finally, the ValueEnumerator for an MDFunctionLocalContext has to be
adapted to examine the `getUsedMDNodes` result from the context; this is
done by using an operand index instead of an `MDNode::op_iterator`, and
examining either `operands` or `getUsedNodes` accordingly.
[X86] LowerFunnelShift - don't pre-apply modulo mask before splitting large vectors with a splat shift amount (#247715)
We should prefer SPLAT(AND(AMT,BW-1)) to AND(SPLAT(AMT),BW-1)) - we're
unwrapping the SPLAT anyhow, but splitting the instruction can prevent
further shuffle folding.
Avoids a use case for the AND(X,0) SimplifyDemandedVectorElts fold that
is causing so many POISON issues.
[scudo] Fix wrapper tests. (#247360)
The size check in the size deallocate was changed to allow any value
between the size and usable size. However, the wrapper test was not
checking this properly. Now make sure to use UsableSize + 1 for one of
the boundaries instead of Size + 1.
In addition, fix the incorrect size check when MTE is on.