Currently, when calling `free` a slice created by slicing a pointer with
comptime-known start and end, a compile-time assertion is hit, because
the slicing results in `*[len]T` rather than the expected `[]T`.
This commit allows `Allocator.free` to be called on such pointers as
well.
closes#35712
This function can be used to prepend a list of arguments when running a
test step. Instead, the additional arguments should be manually added to
the run step which can handle a broader set of use cases.
NtCreateFile is called with `.IO = .ASYNCHRONOUS` but then `NtFsControlFile` is called without any handling of `PENDING`. By switching to the `deviceIoControl` helper function, `PENDING` is handled since we are passing `.nonblocking = true`.
Fixes https://codeberg.org/ziglang/zig/issues/35871
In theory, for any integer type containing padding bits (e.g. `i3`),
LLVM *does* support storing and loading that type to and from memory,
and the documented semantics for this in the LLVM langref are a valid
implementation of Zig's integer semantics. However, in practice, this
support is frequently buggy, because Clang never emits such operations
and so they are poorly tested in LLVM. The most recent example of such a
bug is https://codeberg.org/ziglang/zig/issues/35560.
In addition, LLVM's semantics here lead to suboptimal codegen, because
loads/stores are only rounded up to the next byte (rather than the next
ABI integer type) and padding bits are unspecified (or, on LLVM master,
padding bits are all zero, even for a negative signed integer).
We can both mitigate LLVM bugs and get better codegen by employing the
strategy used by the self-hosted backends, wherein we zero- or
sign-extend to an integer of bit size `@sizeOf(WeirdInt) * 8`. This type
has the same size in memory but has no padding bits. When loading, we
load the extended type and then use `trunc nuw` or `trunc nsw`
(depending on the signedness) to convert to the correct value type.
The name of the game here is to minimize occurrences of `wip.load` and
`wip.store` in the LLVM backend, with most accesses instead going
through higher-level functions which handle this extension/truncation
for us. Those higher-level functions are `codegen.llvm.FuncGen.load` and
`codegen.llvm.FuncGen.store`. I changed their signatures slightly to
make them consistent and more generally useful, and changed the majority
of calls to `wip.load`/`wip.store` to use them. They are the only
functions which include the integer extension/truncation logic.
The remaining occurrences of `wip.load` and `wip.store` outside of those
two functions are all in ABI handling. These code paths cannot occur for
non-ABI types due to how we lower `CallingConvention.auto`, therefore
they cannot be reached for non-ABI-sized integer types.
This diff was not purely mechanical---I had to make a handful of
non-trivial logic changes and refactors. The biggest logic change is in
lowering a "select" operation to a manual loop: we now use phi nodes to
track the loop iterator and accumulator instead of an `alloca`. (To be
honest, this wasn't really necessary, but I felt dirty migrating the old
logic when this approach is clearly better.) The most significant
refactor is that the logic for extracting function call arguments has
been moved into `FuncGen`: the `codegen.llvm.Object.updateFunc`
implementation will not initialize the three fields which depend on
function arguments, and a new function `FuncGen.genMainBody` will
populate those fields before calling `genBody` on the main AIR body.
This change was made so that I could use member functions on `FuncGen`
in this logic without jumping through hoops.
The reproduction given in https://codeberg.org/ziglang/zig/issues/35560
is apparently quite delicate, so I haven't added a test case because it
realistically would not be very useful. However, I have manually tested
the reproduction, and can confirm that the bug *does* trigger before
this commit (targeting both baseline and native CPU), and does *not*
trigger after this commit (again, for both baseline and native CPU).
Resolves: https://codeberg.org/ziglang/zig/issues/35560
Swaps `dupeSentinel` for `dupe` in the `parse` function.
Aside from being inconsistent with the other `findNative` functions in
the file, `dupeSentinel` also causes `deinit` to panic because it
attempts to free fewer bytes than were allocated.
* Adds a new API that takes an options struct instead of having a
function for each combination of options
* Adds support for prefix and suffix to every argument type
* Adds support for making paths absolute when passed as arguments
* Deprecates the old API
* Fixes mismatch between documentation and behavior of
`process.currentPath` on WASI
- Support __imp_ prefixed symbols
- Support data imports
- Support globals symbols pointing directly to IAT entries
- Don't create duplicate IAT entries if multiple globals reference the same import name / ordinal
- Rework storage of Symbol.value
- Add support for `is_dll_import`
- Supply host libc libs to the linker
- Add std.meta.BareUnion (from multi_array_list)
- Rework object loading to handle COMDAT sections
- Add better error output for multiple definitions
- Track all symbols associated with input sections in a flat array
- Resolve weak externals to their alias if nothing defines the weak symbol
- Fixup incorrect signs of reloc addends in the logic that saves / restores them