Sema: correct AIR semantics around array concat optimization#25594
Open
Rexicon226 wants to merge 1 commit intoziglang:masterfrom
Open
Sema: correct AIR semantics around array concat optimization#25594Rexicon226 wants to merge 1 commit intoziglang:masterfrom
Rexicon226 wants to merge 1 commit intoziglang:masterfrom
Conversation
jacobly0
requested changes
Oct 16, 2025
Member
jacobly0
left a comment
There was a problem hiding this comment.
%0 = arg(*const [1]u8, 0)
%6 = array_to_slice([]u8, %4!)
%7!= memcpy(%6!, %0!)
This still seems wrong, when either side is a pointer-to-array (aka comptime-known length), lhs must be pointer-to-array and rhs must be a non-slice pointer, see for reference:
comptime {
_ = &memcpy;
}
fn memcpy(lhs: []u8, rhs: *const [5]u8) void {
@setRuntimeSafety(false);
@memcpy(lhs, rhs);
}$ zig build-obj repro.zig --verbose-air -fstrip
# Begin Function AIR: repro.memcpy:
# Total AIR+Liveness bytes: 219B
# AIR Instructions: 7 (63B)
# AIR Extra Data: 9 (36B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 0 (0B)
# Liveness special table: 0 (0B)
%0 = arg([]u8, 0)
%1 = arg(*const [5]u8, 1)
%2!= slice_len(usize, %0)
%3 = slice_ptr([*]u8, %0!)
%4 = bitcast(*[5]u8, %3!)
%5!= memcpy(%4!, %1!)
%6!= ret(@.void_value)
# End Function AIR: repro.memcpy9511dbe to
7b57c10
Compare
Contributor
Author
|
Ok I've revised it with my new understanding of the semantics... and, export fn foo(x: *const [1]u8) void {
_ = @as([]const u8, "1") ++ x;
} |
7b57c10 to
d01082f
Compare
d01082f to
9202911
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #24953
New AIR
->
->
->
->
cc @jacobly0, perhaps you could double check my AIR?