[CIR] Lower sret returns in CallConvLowering (#201716)
Functions that return an aggregate by value classify their return as
ArgKind::Indirect, but CallConvLowering reached an errorNYI for that
case, so the whole CallConv pass refused to lower any struct-returning
function.
rewriteFunctionDefinition now recognizes an Indirect return: the wire
return type becomes void, a hidden sret pointer is prepended as block
argument 0, and every cir.return is routed through that pointer. Rather
than storing the loaded return value through the sret pointer (a
byte-copy that breaks non-trivially-copyable types -- libstdc++'s SSO
std::string keeps a _M_p pointer into its own _M_local_buf, so a
byte-copy leaves the destination aliasing the source's dying stack
storage), insertSRetStores rewires the __retval alloca to the sret
pointer so construction flows directly into the caller's slot, matching
classic CodeGen's "construct into %agg.result" pattern. CIRGen emits one
cir.load __retval / cir.return pair per return statement, all reading
the
[25 lines not shown]
[libc] restrict FreeTrie to the overflow bin in TLSF
- Rename config option to USE_TRIE_FOR_OVERFLOW_BIN.
- Restrict FreeTrie usage to only the last overflow bin (bit_index == TOTAL_BITS - 1).
- Simplify exact fit search to only use FreeList, as large sizes now always go to the overflow bin.
- Simplify away index_to_range by using a fixed [0, INF) range for the overflow Trie.
- Remove index argument from Trie helper functions as they only operate on the overflow bin.
TAG=agy
CONV=fe3b4efa-7a5b-4c74-8257-e53f0d6e4850
[libc] restrict FreeTrie to the overflow bin in TLSF
- Rename config option to USE_TRIE_FOR_OVERFLOW_BIN.
- Restrict FreeTrie usage to only the last overflow bin (bit_index == TOTAL_BITS - 1).
- Simplify exact fit search to only use FreeList, as large sizes now always go to the overflow bin.
- Simplify away index_to_range by calculating overflow bin range via constexpr safe helper.
- Remove index argument from Trie helper functions as they only operate on the overflow bin.
TAG=agy
CONV=fe3b4efa-7a5b-4c74-8257-e53f0d6e4850
[CIR] NFC: Drop redundant llvm:: qualifiers in sret lowering
Restore `using namespace mlir;` in CIRABIRewriteContext.cpp so the LLVM
ADT names re-exported into the mlir namespace (SmallVector, ArrayRef,
StringRef, SmallPtrSet, function_ref) are in scope without an explicit
llvm:: qualifier. An earlier review fixup had removed the directive and
qualified every ADT type with llvm::, over-applying the qualifier to
unambiguous names.
llvm:: is kept on the free functions mlir does not re-export (enumerate,
any_of, append_range), and mlir:: stays explicit on MLIR types. No
functional change.
[flang] Improve error for data component definition after CONTAINS in derived type (#203379)
When a data component declaration appears after CONTAINS in a derived
type definition, flang previously emitted confusing "expected 'FINAL'",
"expected 'GENERIC'", and "expected 'PROCEDURE'" errors for each
misplaced component.
This patch adds a misplaced-component detector following the same
pattern as `misplacedSpecificationStmt` in program-parsers.cpp.
DataComponentDefStmt is tried as a last alternative in
TypeBoundProcBinding's first(). When it matches, fail<>() fires
with the message:
error: component definition must precede CONTAINS in a derived type
CombineFailedParses then replaces the three keyword-mismatch messages
with this single targeted one, since the component parse advances
further than the PROCEDURE/GENERIC/FINAL failures.
Assisted-By: AI
[libc] Add timezone extensions to struct tm and time.h (#203381)
Added timezone extensions to struct tm and time.h:
* struct tm: Added tm_gmtoff and tm_zone, with __tm_gmtoff and __tm_zone
aliases defined as macros.
* time.h: Added tm_gmtoff_t type.
Updated gmtime and localtime to initialize these fields, and enabled %z
and %Z support in strftime.
These changes are implemented unconditionally. While the timezone
database loading is not yet implemented (so local time offsets default
to UTC/0), the timezone formatting and struct field support is fully
complete. Implementing this conditionally would require complex
build-time configuration and conditional inclusion of code, which is
avoided as this implementation is already a complete improvement over
the previous state.
Assisted-by: Automated tooling, human reviewed.
[VPlan] Account for canonical IV being simplified in verifier. (#203403)
In plain CFG plans, VPCurrentIterationPHIRecipe may be the first recipe,
if the canonical IV phi has been removed because it became unused (e.g.
the vector loop is known to only execute a single iteration).
Fixes https://lab.llvm.org/buildbot/#/builders/187/builds/20801.
[CIR] Lower string literals with high-bit bytes (#203384)
A string literal containing a byte >= 0x80 crashes CIR-to-LLVM lowering.
`convertStringAttrToDenseElementsAttr` builds each element's `APInt`
from a signed `char`, so a high-bit byte sign-extends to a 64-bit value
that no longer fits the 8-bit element width and trips the `APInt`
constructor assertion (`isUIntN(BitWidth, val) && "Value is not an N-bit
unsigned value"`).
Interpreting each string byte as `unsigned char` fixes it, mirroring
what #197269 did for scalar character literals. The string-literal array
path was the remaining site with the same defect, and the lowered LLVM
is byte-identical to classic CodeGen.
Repro: `char s[] = "\x80";` compiled with `-fclangir -emit-llvm`. This
also clears a cluster of SingleSource gcc-torture globals that embed
high-byte string data.
These globals compiled until #198427 removed the trailing-zeros
[3 lines not shown]
[libc] EAGAIN and EWOULDBLOCK should be treated as success in futex wait
The `futex` wait function means waiting until a real change has been detected. We should not reject valid EAGAIN/EWOULDBLOCK kernel detection as failures.
undist(1): misc fixes
New sentence - new line.
Uppercase option comes before its lower case counterpart.
Use .Dl for one-liners.
See Also is sorted by section first.
NAS-141362 / 25.10.4.1 / Fix handling field aliases in `APIVersionsAdapter` (#19108)
Not handling field aliases properly results in a series of tests
failing:
```
test_query_method[legacy_api_client=v25.10.3-query_method=audit.query] api2.test_legacy_api
middlewared.service_exception.ValidationErrors: [EINVAL] data.query_filters: Extra inputs are not permitted
[EINVAL] data.query_options: Extra inputs are not permitted
```
[clang-sycl-linker] Add static archive (.a) support (#202829)
Add support for static archives of LLVM bitcode files to
clang-sycl-linker. The archive member-selection engine (a symbol-driven
fixed-point lazy extraction loop) is simplified to bitcode-only
handling.
clang-sycl-linker gains -l/--library,
--whole-archive/--no-whole-archive, and -u/--undefined options. The
previous --bc-library option is removed in favor of the standard -l
mechanism. Inputs (positional files and -l libraries) are now resolved
to in-memory buffers; archive members are pulled in lazily only when
they resolve undefined symbols, and bitcode is loaded with
parseBitcodeFile.
Co-Authored-By: Claude
---------
Co-authored-by: Yury Plyakhin <yury.plyakhin at intel.com>
[CIR] NFC: Extract rewriteIndirectReturnCall helper
The sret call-site rewrite was a large block inside rewriteCallSite.
Move it into a dedicated rewriteIndirectReturnCall helper in the
anonymous namespace, leaving rewriteCallSite to dispatch to it when the
return is indirect.
Pure code motion: the Indirect-and-has-result guard stays at the call
site (the moved block dereferences the call result, so the guard cannot
fold into the helper), and the helper derives its MLIR context from the
call. No behavior change.
[CIR] NFC: Address sret review feedback in CallConvLowering
Apply andykaylor's second-round feedback on the sret lowering.
All source changes are behavior-preserving:
- Use llvm::append_range when copying arg_attrs into the sret
call's and the definition's attribute lists.
- Replace the manual pad loop in applySretSlotAttrs with an
assert plus resize to the rewritten operand count.
- Rename the Ignore-drop loop's index variables so the outer
one (argInfoIdx) indexes fc.argInfos and the inner one
(blockIdx) is the real block-argument index, matching the
convention insertArgCoercion already uses.
- Clarify the "hidden pointer" comments: the sret pointer is
synthesized by the ABI and is not part of the source-level
signature.
- Note why the llvm.sret attribute must carry the return type
explicitly, since LLVM pointers are opaque once lowered.
[6 lines not shown]
[CIR] Fix namespace, naming, and assert in sret
Remove `using namespace mlir;` from CIRABIRewriteContext.cpp
and qualify all MLIR-namespaced types explicitly with `mlir::`.
Rename `sretOffset` to `hasSRetArg` (bool) -- the name now
reflects that the value is either 0 or 1 and acts as a
presence flag, not an arbitrary offset. Rename `rewriter` to
`builder` throughout for consistency with the rest of the
calling-convention lowering code.
Assert in `insertSRetStores` that every `cir.return` in an sret
function carries an operand. CIRGen guarantees the invariant
`cir.return (cir.load %__retval)` for all returns in an
aggregate-returning function; a bare return would indicate the
sret slot was never written, which is a bug. The previous
`continue` silently ignored that case.
Add an explanatory comment at the `replaceAllUsesWith` call so
it is clear why erasing the alloca immediately after is safe,
[3 lines not shown]
[CIR] Lower sret returns in CallConvLowering
Functions that return an aggregate by value classify their return as
ArgKind::Indirect, but CallConvLowering reached an errorNYI for that
case, so the whole CallConv pass refused to lower any struct-returning
function.
rewriteFunctionDefinition now recognizes an Indirect return: the wire
return type becomes void, a hidden sret pointer is prepended as block
argument 0, and every cir.return is routed through that pointer. Rather
than storing the loaded return value through the sret pointer (a
byte-copy that breaks non-trivially-copyable types -- libstdc++'s SSO
std::string keeps a _M_p pointer into its own _M_local_buf, so a
byte-copy leaves the destination aliasing the source's dying stack
storage), insertSRetStores rewires the __retval alloca to the sret
pointer so construction flows directly into the caller's slot, matching
classic CodeGen's "construct into %agg.result" pattern. CIRGen emits one
cir.load __retval / cir.return pair per return statement, all reading the
single __retval alloca, so the alloca is rewired once and every return is
[18 lines not shown]