| ... | ... | @@ -3994,6 +3994,7 @@ pub const Function = struct { |
| 3994 | 3994 | names: [*]const String = &[0]String{}, |
| 3995 | 3995 | value_indices: [*]const u32 = &[0]u32{}, |
| 3996 | 3996 | strip: bool, |
| 3997 | any_nosanitize: bool, |
| 3997 | 3998 | debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{}, |
| 3998 | 3999 | debug_values: []const Instruction.Index = &.{}, |
| 3999 | 4000 | extra: []const u32 = &.{}, |
| ... | ... | @@ -4090,6 +4091,7 @@ pub const Function = struct { |
| 4090 | 4091 | block, |
| 4091 | 4092 | br, |
| 4092 | 4093 | br_cond, |
| 4094 | br_cond_nosanitize, |
| 4093 | 4095 | call, |
| 4094 | 4096 | @"call fast", |
| 4095 | 4097 | cmpxchg, |
| ... | ... | @@ -4345,6 +4347,13 @@ pub const Function = struct { |
| 4345 | 4347 | else => unreachable, |
| 4346 | 4348 | }; |
| 4347 | 4349 | } |
| 4350 | |
| 4351 | pub fn isNosanitize(self: Tag) bool { |
| 4352 | return switch (self) { |
| 4353 | .br_cond_nosanitize => true, |
| 4354 | else => false, |
| 4355 | }; |
| 4356 | } |
| 4348 | 4357 | }; |
| 4349 | 4358 | |
| 4350 | 4359 | pub const Index = enum(u32) { |
| ... | ... | @@ -4367,6 +4376,7 @@ pub const Function = struct { |
| 4367 | 4376 | return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) { |
| 4368 | 4377 | .br, |
| 4369 | 4378 | .br_cond, |
| 4379 | .br_cond_nosanitize, |
| 4370 | 4380 | .ret, |
| 4371 | 4381 | .@"ret void", |
| 4372 | 4382 | .@"switch", |
| ... | ... | @@ -4380,6 +4390,7 @@ pub const Function = struct { |
| 4380 | 4390 | return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) { |
| 4381 | 4391 | .br, |
| 4382 | 4392 | .br_cond, |
| 4393 | .br_cond_nosanitize, |
| 4383 | 4394 | .fence, |
| 4384 | 4395 | .ret, |
| 4385 | 4396 | .@"ret void", |
| ... | ... | @@ -4470,6 +4481,7 @@ pub const Function = struct { |
| 4470 | 4481 | .block => .label, |
| 4471 | 4482 | .br, |
| 4472 | 4483 | .br_cond, |
| 4484 | .br_cond_nosanitize, |
| 4473 | 4485 | .fence, |
| 4474 | 4486 | .ret, |
| 4475 | 4487 | .@"ret void", |
| ... | ... | @@ -4656,6 +4668,7 @@ pub const Function = struct { |
| 4656 | 4668 | .block => .label, |
| 4657 | 4669 | .br, |
| 4658 | 4670 | .br_cond, |
| 4671 | .br_cond_nosanitize, |
| 4659 | 4672 | .fence, |
| 4660 | 4673 | .ret, |
| 4661 | 4674 | .@"ret void", |
| ... | ... | @@ -5100,6 +5113,7 @@ pub const WipFunction = struct { |
| 5100 | 5113 | instructions: std.MultiArrayList(Instruction), |
| 5101 | 5114 | names: std.ArrayListUnmanaged(String), |
| 5102 | 5115 | strip: bool, |
| 5116 | any_nosanitize: bool, |
| 5103 | 5117 | debug_locations: std.AutoArrayHashMapUnmanaged(Instruction.Index, DebugLocation), |
| 5104 | 5118 | debug_values: std.AutoArrayHashMapUnmanaged(Instruction.Index, void), |
| 5105 | 5119 | extra: std.ArrayListUnmanaged(u32), |
| ... | ... | @@ -5146,6 +5160,7 @@ pub const WipFunction = struct { |
| 5146 | 5160 | .instructions = .{}, |
| 5147 | 5161 | .names = .{}, |
| 5148 | 5162 | .strip = options.strip, |
| 5163 | .any_nosanitize = false, |
| 5149 | 5164 | .debug_locations = .{}, |
| 5150 | 5165 | .debug_values = .{}, |
| 5151 | 5166 | .extra = .{}, |
| ... | ... | @@ -6437,7 +6452,7 @@ pub const WipFunction = struct { |
| 6437 | 6452 | .@"ret void", |
| 6438 | 6453 | .@"unreachable", |
| 6439 | 6454 | => {}, |
| 6440 | | .br_cond => { |
| 6455 | .br_cond, .br_cond_nosanitize => { |
| 6441 | 6456 | const extra = self.extraData(Instruction.BrCond, instruction.data); |
| 6442 | 6457 | instruction.data = wip_extra.addExtra(Instruction.BrCond{ |
| 6443 | 6458 | .cond = instructions.map(extra.cond), |
| ... | ... | @@ -6624,6 +6639,7 @@ pub const WipFunction = struct { |
| 6624 | 6639 | function.names = names.ptr; |
| 6625 | 6640 | function.value_indices = value_indices.ptr; |
| 6626 | 6641 | function.strip = self.strip; |
| 6642 | function.any_nosanitize = self.any_nosanitize; |
| 6627 | 6643 | function.debug_locations = debug_locations; |
| 6628 | 6644 | function.debug_values = debug_values; |
| 6629 | 6645 | } |
| ... | ... | @@ -8537,6 +8553,7 @@ pub fn init(options: Options) Allocator.Error!Builder { |
| 8537 | 8553 | |
| 8538 | 8554 | try self.metadata_string_indices.append(self.gpa, 0); |
| 8539 | 8555 | assert(try self.metadataString("") == .none); |
| 8556 | assert(try self.debugTuple(&.{}) == .empty_tuple); |
| 8540 | 8557 | |
| 8541 | 8558 | return self; |
| 8542 | 8559 | } |
| ... | ... | @@ -8934,6 +8951,7 @@ pub fn addFunctionAssumeCapacity( |
| 8934 | 8951 | .kind = .{ .function = function_index }, |
| 8935 | 8952 | }), |
| 8936 | 8953 | .strip = undefined, |
| 8954 | .any_nosanitize = false, |
| 8937 | 8955 | }); |
| 8938 | 8956 | return function_index; |
| 8939 | 8957 | } |
| ... | ... | @@ -9581,6 +9599,12 @@ pub fn printUnbuffered( |
| 9581 | 9599 | }); |
| 9582 | 9600 | } |
| 9583 | 9601 | if (function.instructions.len > 0) { |
| 9602 | const maybe_empty_tuple: ?u32 = if (!function.any_nosanitize) null else b: { |
| 9603 | const gop = try metadata_formatter.map.getOrPut(self.gpa, .{ |
| 9604 | .metadata = .empty_tuple, |
| 9605 | }); |
| 9606 | break :b @intCast(gop.index); |
| 9607 | }; |
| 9584 | 9608 | var block_incoming_len: u32 = undefined; |
| 9585 | 9609 | try writer.writeAll(" {\n"); |
| 9586 | 9610 | var maybe_dbg_index: ?u32 = null; |
| ... | ... | @@ -9770,6 +9794,14 @@ pub fn printUnbuffered( |
| 9770 | 9794 | }), |
| 9771 | 9795 | } |
| 9772 | 9796 | }, |
| 9797 | .br_cond_nosanitize => { |
| 9798 | const extra = function.extraData(Function.Instruction.BrCond, instruction.data); |
| 9799 | try writer.print(" br {%}, {%}, {%}", .{ |
| 9800 | extra.cond.fmt(function_index, self), |
| 9801 | extra.then.toInst(&function).fmt(function_index, self), |
| 9802 | extra.@"else".toInst(&function).fmt(function_index, self), |
| 9803 | }); |
| 9804 | }, |
| 9773 | 9805 | .call, |
| 9774 | 9806 | .@"call fast", |
| 9775 | 9807 | .@"musttail call", |
| ... | ... | @@ -10046,8 +10078,12 @@ pub fn printUnbuffered( |
| 10046 | 10078 | } |
| 10047 | 10079 | |
| 10048 | 10080 | if (maybe_dbg_index) |dbg_index| { |
| 10049 | | try writer.print(", !dbg !{}\n", .{dbg_index}); |
| 10050 | | } else try writer.writeByte('\n'); |
| 10081 | try writer.print(", !dbg !{}", .{dbg_index}); |
| 10082 | } |
| 10083 | if (instruction.tag.isNosanitize()) { |
| 10084 | try writer.print(", !nosanitize !{d}", .{maybe_empty_tuple.?}); |
| 10085 | } |
| 10086 | try writer.writeByte('\n'); |
| 10051 | 10087 | } |
| 10052 | 10088 | try writer.writeByte('}'); |
| 10053 | 10089 | } |