remove elem_val and field_val ZIR instructions; forbid runtime vector indexes#25138
Closed
remove elem_val and field_val ZIR instructions; forbid runtime vector indexes#25138
Conversation
Member
Author
|
Soliciting help from @jacobly0: Basically the result of |
Member
--- a/src/arch/x86_64/CodeGen.zig
+++ b/src/arch/x86_64/CodeGen.zig
@@ -186936,7 +186936,7 @@ const Temp = struct {
break :part_ty .usize;
},
},
- .struct_type => {
+ .struct_type, .tuple_type => {
assert(src_regs.len - part_index == std.math.divCeil(u32, src_abi_size, 8) catch unreachable);
break :part_ty .u64;
}, |
Member
Author
|
Ah of course thank you! |
Member
Author
|
It trips that assert: |
Member
|
This kind of works --- a/src/arch/x86_64/CodeGen.zig
+++ b/src/arch/x86_64/CodeGen.zig
@@ -186940,6 +186940,10 @@ const Temp = struct {
assert(src_regs.len - part_index == std.math.divCeil(u32, src_abi_size, 8) catch unreachable);
break :part_ty .u64;
},
+ .tuple_type => |tuple_type| {
+ assert(tuple_type.types.len == src_regs.len);
+ break :part_ty .fromInterned(tuple_type.types.get(ip)[part_index]);
+ },
};
const part_size: u31 = @intCast(part_ty.abiSize(zcu));
const src_rc = src_reg.class(); |
f9ffb45 to
bbc171d
Compare
Member
Author
|
Reduction for analysis: const std = @import("std");
pub const panic = std.debug.no_panic;
export fn entry() void {
comptime var map: [10]usize = @splat(0);
map[0] = 0;
var runtime_index: usize = 0;
_ = &runtime_index;
const set_index = map[runtime_index];
_ = set_index;
}I argue this is a correct error. Before it was relying on const copy = map;
const set_index = copy[runtime_index];Or, more likely, they will realize this is creating bloat in the binary and instead create only 1 copy of the runtime data and access it several times. In summary it exposes an invisible copy. |
register manager is a bad name
point at the var not at the init expression
vector indexes must be comptime-known now
bbc171d to
adb4923
Compare
Member
Author
|
superseded by #25154 |
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.
fixes #22906
fixes #13938
fixes #25111
related: some other issue that @mlugg mentioned regarding runtime vector issues
Upgrade Guide
for->inline forwhen iterating over vector elements.Merge Checklist