authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-27 06:10:56+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-27 06:10:56+01:00
logd3c6f7179c7a6086ab9cdbaed231da9a1f0b4dee
treea75bc8abc129a679fce0673165e04fa7283f2823
parentd9147b91a601ad2442aaa43f4dba2d01b25d803d
parent4c0f021c2e4270c7392df7250a5d8f2431dcc54f
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21214 from mlugg/branch-hint-and-export

Implement `@branchHint` and new `@export` usage

266 files changed, 2443 insertions(+), 1808 deletions(-)

doc/langref.html.in+12-24
......@@ -4340,6 +4340,13 @@ comptime {
43404340 {#see_also|@sizeOf|@typeInfo#}
43414341 {#header_close#}
43424342
4343 {#header_open|@branchHint#}
4344 <pre>{#syntax#}@branchHint(hint: BranchHint) void{#endsyntax#}</pre>
4345 <p>Hints to the optimizer how likely a given branch of control flow is to be reached.</p>
4346 <p>{#syntax#}BranchHint{#endsyntax#} can be found with {#syntax#}@import("std").builtin.BranchHint{#endsyntax#}.</p>
4347 <p>This function is only valid as the first statement in a control flow branch, or the first statement in a function.</p>
4348 {#header_close#}
4349
43434350 {#header_open|@breakpoint#}
43444351 <pre>{#syntax#}@breakpoint() void{#endsyntax#}</pre>
43454352 <p>
......@@ -4767,23 +4774,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
47674774 {#header_close#}
47684775
47694776 {#header_open|@export#}
4770 <pre>{#syntax#}@export(declaration, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
4771 <p>
4772 Creates a symbol in the output object file.
4773 </p>
4774 <p>
4775 <code>declaration</code> must be one of two things:
4776 </p>
4777 <ul>
4778 <li>An identifier ({#syntax#}x{#endsyntax#}) identifying a {#link|function|Functions#} or a
4779 {#link|variable|Container Level Variables#}.</li>
4780 <li>Field access ({#syntax#}x.y{#endsyntax#}) looking up a {#link|function|Functions#} or a
4781 {#link|variable|Container Level Variables#}.</li>
4782 </ul>
4777 <pre>{#syntax#}@export(comptime ptr: *const anyopaque, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
4778 <p>Creates a symbol in the output object file which refers to the target of <code>ptr</code>.</p>
4779 <p><code>ptr</code> must point to a global variable or a comptime-known constant.</p>
47834780 <p>
47844781 This builtin can be called from a {#link|comptime#} block to conditionally export symbols.
4785 When <code>declaration</code> is a function with the C calling convention and
4786 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to
4782 When <code>ptr</code> points to a function with the C calling convention and
4783 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}.Strong{#endsyntax#}, this is equivalent to
47874784 the {#syntax#}export{#endsyntax#} keyword used on a function:
47884785 </p>
47894786 {#code|export_builtin.zig#}
......@@ -5252,15 +5249,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
52525249 </p>
52535250 {#header_close#}
52545251
5255 {#header_open|@setCold#}
5256 <pre>{#syntax#}@setCold(comptime is_cold: bool) void{#endsyntax#}</pre>
5257 <p>
5258 Tells the optimizer that the current function is (or is not) rarely called.
5259
5260 This function is only valid within function scope.
5261 </p>
5262 {#header_close#}
5263
52645252 {#header_open|@setEvalBranchQuota#}
52655253 <pre>{#syntax#}@setEvalBranchQuota(comptime new_quota: u32) void{#endsyntax#}</pre>
52665254 <p>
doc/langref/export_builtin.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 @export(internalName, .{ .name = "foo", .linkage = .strong });
2 @export(&internalName, .{ .name = "foo", .linkage = .strong });
33}
44
55fn internalName() callconv(.C) void {}
doc/langref/test_functions.zig+2-2
......@@ -27,9 +27,9 @@ const WINAPI: std.builtin.CallingConvention = if (native_arch == .x86) .Stdcall
2727extern "kernel32" fn ExitProcess(exit_code: u32) callconv(WINAPI) noreturn;
2828extern "c" fn atan2(a: f64, b: f64) f64;
2929
30// The @setCold builtin tells the optimizer that a function is rarely called.
30// The @branchHint builtin can be used to tell the optimizer that a function is rarely called ("cold").
3131fn abort() noreturn {
32 @setCold(true);
32 @branchHint(.cold);
3333 while (true) {}
3434}
3535
lib/c.zig+11-11
......@@ -26,27 +26,27 @@ const is_freestanding = switch (native_os) {
2626
2727comptime {
2828 if (is_freestanding and is_wasm and builtin.link_libc) {
29 @export(wasm_start, .{ .name = "_start", .linkage = .strong });
29 @export(&wasm_start, .{ .name = "_start", .linkage = .strong });
3030 }
3131
3232 if (builtin.link_libc) {
33 @export(strcmp, .{ .name = "strcmp", .linkage = .strong });
34 @export(strncmp, .{ .name = "strncmp", .linkage = .strong });
35 @export(strerror, .{ .name = "strerror", .linkage = .strong });
36 @export(strlen, .{ .name = "strlen", .linkage = .strong });
37 @export(strcpy, .{ .name = "strcpy", .linkage = .strong });
38 @export(strncpy, .{ .name = "strncpy", .linkage = .strong });
39 @export(strcat, .{ .name = "strcat", .linkage = .strong });
40 @export(strncat, .{ .name = "strncat", .linkage = .strong });
33 @export(&strcmp, .{ .name = "strcmp", .linkage = .strong });
34 @export(&strncmp, .{ .name = "strncmp", .linkage = .strong });
35 @export(&strerror, .{ .name = "strerror", .linkage = .strong });
36 @export(&strlen, .{ .name = "strlen", .linkage = .strong });
37 @export(&strcpy, .{ .name = "strcpy", .linkage = .strong });
38 @export(&strncpy, .{ .name = "strncpy", .linkage = .strong });
39 @export(&strcat, .{ .name = "strcat", .linkage = .strong });
40 @export(&strncat, .{ .name = "strncat", .linkage = .strong });
4141 } else if (is_msvc) {
42 @export(_fltused, .{ .name = "_fltused", .linkage = .strong });
42 @export(&_fltused, .{ .name = "_fltused", .linkage = .strong });
4343 }
4444}
4545
4646// Avoid dragging in the runtime safety mechanisms into this .o file,
4747// unless we're trying to test this file.
4848pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
49 @setCold(true);
49 @branchHint(.cold);
5050 _ = error_return_trace;
5151 if (builtin.is_test) {
5252 std.debug.panic("{s}", .{msg});
lib/compiler/aro/aro/Driver/Filesystem.zig+4-4
......@@ -4,7 +4,7 @@ const builtin = @import("builtin");
44const is_windows = builtin.os.tag == .windows;
55
66fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) ?[]const u8 {
7 @setCold(true);
7 @branchHint(.cold);
88 for (entries) |entry| {
99 if (mem.eql(u8, entry.path, path)) {
1010 const len = @min(entry.contents.len, buf.len);
......@@ -16,7 +16,7 @@ fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8)
1616}
1717
1818fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
19 @setCold(true);
19 @branchHint(.cold);
2020 if (mem.indexOfScalar(u8, name, '/') != null) {
2121 @memcpy(buf[0..name.len], name);
2222 return buf[0..name.len];
......@@ -35,7 +35,7 @@ fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, pa
3535}
3636
3737fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
38 @setCold(true);
38 @branchHint(.cold);
3939 for (entries) |entry| {
4040 if (mem.eql(u8, entry.path, path)) {
4141 return entry.executable;
......@@ -45,7 +45,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
4545}
4646
4747fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {
48 @setCold(true);
48 @branchHint(.cold);
4949 var buf: [std.fs.max_path_bytes]u8 = undefined;
5050 var fib = std.heap.FixedBufferAllocator.init(&buf);
5151 const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;
lib/compiler/aro/aro/Parser.zig+5-5
......@@ -385,12 +385,12 @@ fn errExpectedToken(p: *Parser, expected: Token.Id, actual: Token.Id) Error {
385385}
386386
387387pub fn errStr(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, str: []const u8) Compilation.Error!void {
388 @setCold(true);
388 @branchHint(.cold);
389389 return p.errExtra(tag, tok_i, .{ .str = str });
390390}
391391
392392pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diagnostics.Message.Extra) Compilation.Error!void {
393 @setCold(true);
393 @branchHint(.cold);
394394 const tok = p.pp.tokens.get(tok_i);
395395 var loc = tok.loc;
396396 if (tok_i != 0 and tok.id == .eof) {
......@@ -407,12 +407,12 @@ pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diag
407407}
408408
409409pub fn errTok(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex) Compilation.Error!void {
410 @setCold(true);
410 @branchHint(.cold);
411411 return p.errExtra(tag, tok_i, .{ .none = {} });
412412}
413413
414414pub fn err(p: *Parser, tag: Diagnostics.Tag) Compilation.Error!void {
415 @setCold(true);
415 @branchHint(.cold);
416416 return p.errExtra(tag, p.tok_i, .{ .none = {} });
417417}
418418
......@@ -638,7 +638,7 @@ fn pragma(p: *Parser) Compilation.Error!bool {
638638
639639/// Issue errors for top-level definitions whose type was never completed.
640640fn diagnoseIncompleteDefinitions(p: *Parser) !void {
641 @setCold(true);
641 @branchHint(.cold);
642642
643643 const node_slices = p.nodes.slice();
644644 const tags = node_slices.items(.tag);
lib/compiler/resinator/main.zig+4-4
......@@ -421,7 +421,7 @@ fn cliDiagnosticsToErrorBundle(
421421 gpa: std.mem.Allocator,
422422 diagnostics: *cli.Diagnostics,
423423) !ErrorBundle {
424 @setCold(true);
424 @branchHint(.cold);
425425
426426 var bundle: ErrorBundle.Wip = undefined;
427427 try bundle.init(gpa);
......@@ -468,7 +468,7 @@ fn diagnosticsToErrorBundle(
468468 diagnostics: *Diagnostics,
469469 mappings: SourceMappings,
470470) !ErrorBundle {
471 @setCold(true);
471 @branchHint(.cold);
472472
473473 var bundle: ErrorBundle.Wip = undefined;
474474 try bundle.init(gpa);
......@@ -559,7 +559,7 @@ fn flushErrorMessageIntoBundle(wip: *ErrorBundle.Wip, msg: ErrorBundle.ErrorMess
559559}
560560
561561fn errorStringToErrorBundle(allocator: std.mem.Allocator, comptime format: []const u8, args: anytype) !ErrorBundle {
562 @setCold(true);
562 @branchHint(.cold);
563563 var bundle: ErrorBundle.Wip = undefined;
564564 try bundle.init(allocator);
565565 errdefer bundle.deinit();
......@@ -574,7 +574,7 @@ fn aroDiagnosticsToErrorBundle(
574574 fail_msg: []const u8,
575575 comp: *aro.Compilation,
576576) !ErrorBundle {
577 @setCold(true);
577 @branchHint(.cold);
578578
579579 var bundle: ErrorBundle.Wip = undefined;
580580 try bundle.init(gpa);
lib/compiler_rt/aarch64_outline_atomics.zig+100-100
......@@ -2124,104 +2124,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.Naked) void {
21242124}
21252125
21262126comptime {
2127 @export(__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage });
2128 @export(__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage });
2129 @export(__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage });
2130 @export(__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage });
2131 @export(__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage });
2132 @export(__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage });
2133 @export(__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage });
2134 @export(__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage });
2135 @export(__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage });
2136 @export(__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage });
2137 @export(__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage });
2138 @export(__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage });
2139 @export(__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage });
2140 @export(__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage });
2141 @export(__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage });
2142 @export(__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage });
2143 @export(__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage });
2144 @export(__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage });
2145 @export(__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage });
2146 @export(__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage });
2147 @export(__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage });
2148 @export(__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage });
2149 @export(__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage });
2150 @export(__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage });
2151 @export(__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage });
2152 @export(__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage });
2153 @export(__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage });
2154 @export(__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage });
2155 @export(__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage });
2156 @export(__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage });
2157 @export(__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage });
2158 @export(__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage });
2159 @export(__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage });
2160 @export(__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage });
2161 @export(__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage });
2162 @export(__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage });
2163 @export(__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage });
2164 @export(__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage });
2165 @export(__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage });
2166 @export(__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage });
2167 @export(__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage });
2168 @export(__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage });
2169 @export(__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage });
2170 @export(__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage });
2171 @export(__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage });
2172 @export(__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage });
2173 @export(__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage });
2174 @export(__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage });
2175 @export(__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage });
2176 @export(__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage });
2177 @export(__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage });
2178 @export(__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage });
2179 @export(__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage });
2180 @export(__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage });
2181 @export(__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage });
2182 @export(__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage });
2183 @export(__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage });
2184 @export(__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage });
2185 @export(__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage });
2186 @export(__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage });
2187 @export(__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage });
2188 @export(__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage });
2189 @export(__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage });
2190 @export(__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage });
2191 @export(__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage });
2192 @export(__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage });
2193 @export(__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage });
2194 @export(__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage });
2195 @export(__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage });
2196 @export(__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage });
2197 @export(__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage });
2198 @export(__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage });
2199 @export(__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage });
2200 @export(__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage });
2201 @export(__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage });
2202 @export(__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage });
2203 @export(__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage });
2204 @export(__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage });
2205 @export(__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage });
2206 @export(__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage });
2207 @export(__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage });
2208 @export(__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage });
2209 @export(__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage });
2210 @export(__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage });
2211 @export(__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage });
2212 @export(__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage });
2213 @export(__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage });
2214 @export(__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage });
2215 @export(__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage });
2216 @export(__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage });
2217 @export(__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage });
2218 @export(__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage });
2219 @export(__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage });
2220 @export(__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage });
2221 @export(__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage });
2222 @export(__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage });
2223 @export(__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage });
2224 @export(__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage });
2225 @export(__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage });
2226 @export(__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage });
2127 @export(&__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage });
2128 @export(&__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage });
2129 @export(&__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage });
2130 @export(&__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage });
2131 @export(&__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage });
2132 @export(&__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage });
2133 @export(&__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage });
2134 @export(&__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage });
2135 @export(&__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage });
2136 @export(&__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage });
2137 @export(&__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage });
2138 @export(&__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage });
2139 @export(&__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage });
2140 @export(&__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage });
2141 @export(&__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage });
2142 @export(&__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage });
2143 @export(&__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage });
2144 @export(&__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage });
2145 @export(&__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage });
2146 @export(&__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage });
2147 @export(&__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage });
2148 @export(&__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage });
2149 @export(&__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage });
2150 @export(&__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage });
2151 @export(&__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage });
2152 @export(&__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage });
2153 @export(&__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage });
2154 @export(&__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage });
2155 @export(&__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage });
2156 @export(&__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage });
2157 @export(&__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage });
2158 @export(&__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage });
2159 @export(&__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage });
2160 @export(&__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage });
2161 @export(&__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage });
2162 @export(&__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage });
2163 @export(&__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage });
2164 @export(&__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage });
2165 @export(&__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage });
2166 @export(&__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage });
2167 @export(&__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage });
2168 @export(&__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage });
2169 @export(&__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage });
2170 @export(&__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage });
2171 @export(&__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage });
2172 @export(&__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage });
2173 @export(&__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage });
2174 @export(&__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage });
2175 @export(&__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage });
2176 @export(&__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage });
2177 @export(&__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage });
2178 @export(&__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage });
2179 @export(&__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage });
2180 @export(&__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage });
2181 @export(&__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage });
2182 @export(&__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage });
2183 @export(&__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage });
2184 @export(&__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage });
2185 @export(&__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage });
2186 @export(&__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage });
2187 @export(&__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage });
2188 @export(&__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage });
2189 @export(&__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage });
2190 @export(&__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage });
2191 @export(&__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage });
2192 @export(&__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage });
2193 @export(&__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage });
2194 @export(&__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage });
2195 @export(&__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage });
2196 @export(&__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage });
2197 @export(&__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage });
2198 @export(&__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage });
2199 @export(&__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage });
2200 @export(&__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage });
2201 @export(&__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage });
2202 @export(&__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage });
2203 @export(&__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage });
2204 @export(&__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage });
2205 @export(&__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage });
2206 @export(&__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage });
2207 @export(&__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage });
2208 @export(&__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage });
2209 @export(&__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage });
2210 @export(&__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage });
2211 @export(&__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage });
2212 @export(&__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage });
2213 @export(&__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage });
2214 @export(&__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage });
2215 @export(&__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage });
2216 @export(&__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage });
2217 @export(&__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage });
2218 @export(&__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage });
2219 @export(&__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage });
2220 @export(&__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage });
2221 @export(&__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage });
2222 @export(&__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage });
2223 @export(&__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage });
2224 @export(&__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage });
2225 @export(&__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage });
2226 @export(&__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage });
22272227}
lib/compiler_rt/absvdi2.zig+1-1
......@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
44pub const panic = common.panic;
55
66comptime {
7 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __absvdi2(a: i64) callconv(.C) i64 {
lib/compiler_rt/absvsi2.zig+1-1
......@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
44pub const panic = common.panic;
55
66comptime {
7 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __absvsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/absvti2.zig+1-1
......@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
44pub const panic = common.panic;
55
66comptime {
7 @export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __absvti2(a: i128) callconv(.C) i128 {
lib/compiler_rt/adddf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/addhf3.zig+1-1
......@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
44pub const panic = common.panic;
55
66comptime {
7 @export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __addhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/addo.zig+3-3
......@@ -5,9 +5,9 @@ const common = @import("./common.zig");
55pub const panic = @import("common.zig").panic;
66
77comptime {
8 @export(__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility });
1111}
1212
1313// addo - add overflow
lib/compiler_rt/addsf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/addtf3.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/addxf3.zig+1-1
......@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
44pub const panic = common.panic;
55
66comptime {
7 @export(__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/arm.zig+22-22
......@@ -10,39 +10,39 @@ pub const panic = common.panic;
1010comptime {
1111 if (!builtin.is_test) {
1212 if (arch.isArmOrThumb()) {
13 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });
1616
17 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
1919
20 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
2222
23 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility });
2626
27 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility });
28 @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility });
28 @export(&__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility });
3030
31 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility });
3434
35 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility });
36 @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });
37 @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });
35 @export(&__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility });
36 @export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });
37 @export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });
3838
3939 if (builtin.os.tag == .linux) {
40 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
40 @export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
4141 }
4242
4343 // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig
44 @export(__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility });
45 @export(__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });
44 @export(&__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility });
45 @export(&__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });
4646 }
4747 }
4848}
lib/compiler_rt/atomics.zig+76-76
......@@ -538,81 +538,81 @@ fn __atomic_fetch_umin_16(ptr: *u128, val: u128, model: i32) callconv(.C) u128 {
538538
539539comptime {
540540 if (supports_atomic_ops and builtin.object_format != .c) {
541 @export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility });
542 @export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility });
543 @export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility });
544 @export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility });
545
546 @export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility });
547 @export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility });
548 @export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility });
549 @export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility });
550 @export(__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility });
551
552 @export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility });
553 @export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility });
554 @export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility });
555 @export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility });
556 @export(__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility });
557
558 @export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility });
559 @export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility });
560 @export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility });
561 @export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility });
562 @export(__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility });
563
564 @export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility });
565 @export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility });
566 @export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility });
567 @export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility });
568 @export(__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility });
569
570 @export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility });
571 @export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility });
572 @export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility });
573 @export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility });
574 @export(__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility });
575
576 @export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility });
577 @export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility });
578 @export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility });
579 @export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility });
580 @export(__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility });
581
582 @export(__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility });
583 @export(__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility });
584 @export(__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility });
585 @export(__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility });
586 @export(__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility });
587
588 @export(__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility });
589 @export(__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility });
590 @export(__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility });
591 @export(__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility });
592 @export(__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility });
593
594 @export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility });
595 @export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility });
596 @export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility });
597 @export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility });
598 @export(__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility });
599
600 @export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility });
601 @export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility });
602 @export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility });
603 @export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility });
604 @export(__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility });
605
606 @export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility });
607 @export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility });
608 @export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility });
609 @export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility });
610 @export(__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility });
611
612 @export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility });
613 @export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility });
614 @export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility });
615 @export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility });
616 @export(__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility });
541 @export(&__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility });
542 @export(&__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility });
543 @export(&__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility });
544 @export(&__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility });
545
546 @export(&__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility });
547 @export(&__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility });
548 @export(&__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility });
549 @export(&__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility });
550 @export(&__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility });
551
552 @export(&__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility });
553 @export(&__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility });
554 @export(&__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility });
555 @export(&__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility });
556 @export(&__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility });
557
558 @export(&__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility });
559 @export(&__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility });
560 @export(&__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility });
561 @export(&__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility });
562 @export(&__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility });
563
564 @export(&__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility });
565 @export(&__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility });
566 @export(&__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility });
567 @export(&__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility });
568 @export(&__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility });
569
570 @export(&__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility });
571 @export(&__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility });
572 @export(&__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility });
573 @export(&__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility });
574 @export(&__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility });
575
576 @export(&__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility });
577 @export(&__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility });
578 @export(&__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility });
579 @export(&__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility });
580 @export(&__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility });
581
582 @export(&__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility });
583 @export(&__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility });
584 @export(&__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility });
585 @export(&__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility });
586 @export(&__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility });
587
588 @export(&__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility });
589 @export(&__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility });
590 @export(&__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility });
591 @export(&__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility });
592 @export(&__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility });
593
594 @export(&__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility });
595 @export(&__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility });
596 @export(&__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility });
597 @export(&__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility });
598 @export(&__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility });
599
600 @export(&__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility });
601 @export(&__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility });
602 @export(&__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility });
603 @export(&__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility });
604 @export(&__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility });
605
606 @export(&__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility });
607 @export(&__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility });
608 @export(&__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility });
609 @export(&__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility });
610 @export(&__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility });
611
612 @export(&__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility });
613 @export(&__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility });
614 @export(&__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility });
615 @export(&__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility });
616 @export(&__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility });
617617 }
618618}
lib/compiler_rt/aulldiv.zig+2-2
......@@ -9,8 +9,8 @@ pub const panic = common.panic;
99comptime {
1010 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {
1111 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });
13 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/aullrem.zig+2-2
......@@ -9,8 +9,8 @@ pub const panic = common.panic;
99comptime {
1010 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {
1111 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
13 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/bcmp.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const common = @import("./common.zig");
33
44comptime {
5 @export(bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility });
5 @export(&bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility });
66}
77
88pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int {
lib/compiler_rt/bitreverse.zig+3-3
......@@ -5,9 +5,9 @@ const common = @import("common.zig");
55pub const panic = common.panic;
66
77comptime {
8 @export(__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility });
1111}
1212
1313inline fn bitreverseXi2(comptime T: type, a: T) T {
lib/compiler_rt/bswap.zig+3-3
......@@ -5,9 +5,9 @@ const common = @import("common.zig");
55pub const panic = common.panic;
66
77comptime {
8 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility });
1111}
1212
1313// bswap - byteswap
lib/compiler_rt/ceil.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __ceilh(x: f16) callconv(.C) f16 {
lib/compiler_rt/clear_cache.zig+1-1
......@@ -175,7 +175,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
175175const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak;
176176
177177fn exportIt() void {
178 @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
178 @export(&clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
179179}
180180
181181// Darwin-only
lib/compiler_rt/cmp.zig+6-6
......@@ -6,12 +6,12 @@ const common = @import("common.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility });
1515}
1616
1717// cmp - signed compare
lib/compiler_rt/cmpdf2.zig+8-8
......@@ -7,15 +7,15 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_aeabi) {
10 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility });
1313 } else {
14 @export(__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility });
1919 }
2020}
2121
lib/compiler_rt/cmphf2.zig+5-5
......@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility });
1414}
1515
1616/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/cmpsf2.zig+8-8
......@@ -7,15 +7,15 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_aeabi) {
10 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility });
1313 } else {
14 @export(__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility });
1919 }
2020}
2121
lib/compiler_rt/cmptf2.zig+16-16
......@@ -7,24 +7,24 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_ppc_abi) {
10 @export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility });
1414 } else if (common.want_sparc_abi) {
15 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility });
16 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility });
18 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility });
19 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility });
20 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility });
21 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility });
2222 }
23 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility });
2828}
2929
3030/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/cmpxf2.zig+5-5
......@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility });
1414}
1515
1616/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/common.zig+1-1
......@@ -72,7 +72,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
7272pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
7373 _ = error_return_trace;
7474 if (builtin.is_test) {
75 @setCold(true);
75 @branchHint(.cold);
7676 std.debug.panic("{s}", .{msg});
7777 } else {
7878 unreachable;
lib/compiler_rt/cos.zig+7-7
......@@ -11,15 +11,15 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
1111const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1212
1313comptime {
14 @export(__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility });
1818 if (common.want_ppc_abi) {
19 @export(cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility });
2020 }
21 @export(cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility });
2323}
2424
2525pub fn __cosh(a: f16) callconv(.C) f16 {
lib/compiler_rt/count0bits.zig+9-9
......@@ -6,15 +6,15 @@ const common = @import("common.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility });
1818}
1919
2020// clz - count leading zeroes
lib/compiler_rt/divdc3.zig+1-1
......@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility });
88 }
99}
1010
lib/compiler_rt/divdf3.zig+2-2
......@@ -15,9 +15,9 @@ pub const panic = common.panic;
1515
1616comptime {
1717 if (common.want_aeabi) {
18 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility });
1919 } else {
20 @export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility });
2121 }
2222}
2323
lib/compiler_rt/divhc3.zig+1-1
......@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility });
88 }
99}
1010
lib/compiler_rt/divhf3.zig+1-1
......@@ -2,7 +2,7 @@ const common = @import("common.zig");
22const divsf3 = @import("./divsf3.zig");
33
44comptime {
5 @export(__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility });
5 @export(&__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility });
66}
77
88pub fn __divhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/divsc3.zig+1-1
......@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility });
88 }
99}
1010
lib/compiler_rt/divsf3.zig+2-2
......@@ -13,9 +13,9 @@ pub const panic = common.panic;
1313
1414comptime {
1515 if (common.want_aeabi) {
16 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility });
1717 } else {
18 @export(__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility });
1919 }
2020}
2121
lib/compiler_rt/divtc3.zig+2-2
......@@ -5,8 +5,8 @@ const Complex = @import("./mulc3.zig").Complex;
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
77 if (common.want_ppc_abi)
8 @export(__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility });
1010 }
1111}
1212
lib/compiler_rt/divtf3.zig+3-3
......@@ -9,11 +9,11 @@ pub const panic = common.panic;
99
1010comptime {
1111 if (common.want_ppc_abi) {
12 @export(__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility });
1313 } else if (common.want_sparc_abi) {
14 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility });
1515 }
16 @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility });
1717}
1818
1919pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/divti3.zig+2-2
......@@ -8,9 +8,9 @@ pub const panic = common.panic;
88
99comptime {
1010 if (common.want_windows_v2u64_abi) {
11 @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
1212 } else {
13 @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/divxc3.zig+1-1
......@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility });
88 }
99}
1010
lib/compiler_rt/divxf3.zig+1-1
......@@ -9,7 +9,7 @@ const wideMultiply = common.wideMultiply;
99pub const panic = common.panic;
1010
1111comptime {
12 @export(__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/emutls.zig+1-1
......@@ -19,7 +19,7 @@ pub const panic = common.panic;
1919
2020comptime {
2121 if (builtin.link_libc and (builtin.abi == .android or builtin.os.tag == .openbsd)) {
22 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });
2323 }
2424}
2525
lib/compiler_rt/exp.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility });
19 @export(expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __exph(a: f16) callconv(.C) f16 {
lib/compiler_rt/exp2.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __exp2h(x: f16) callconv(.C) f16 {
lib/compiler_rt/extenddftf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __extenddftf2(a: f64) callconv(.C) f128 {
lib/compiler_rt/extenddfxf2.zig+1-1
......@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __extenddfxf2(a: f64) callconv(.C) f80 {
lib/compiler_rt/extendhfdf2.zig+1-1
......@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;
44pub const panic = common.panic;
55
66comptime {
7 @export(__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.C) f64 {
lib/compiler_rt/extendhfsf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.gnu_f16_abi) {
8 @export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_aeabi) {
10 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.C) f32 {
lib/compiler_rt/extendhftf2.zig+1-1
......@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;
44pub const panic = common.panic;
55
66comptime {
7 @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __extendhftf2(a: common.F16T(f128)) callconv(.C) f128 {
lib/compiler_rt/extendhfxf2.zig+1-1
......@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __extendhfxf2(a: common.F16T(f80)) callconv(.C) f80 {
lib/compiler_rt/extendsfdf2.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/extendsftf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __extendsftf2(a: f32) callconv(.C) f128 {
lib/compiler_rt/extendsfxf2.zig+1-1
......@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __extendsfxf2(a: f32) callconv(.C) f80 {
lib/compiler_rt/extendxftf2.zig+1-1
......@@ -4,7 +4,7 @@ const common = @import("./common.zig");
44pub const panic = common.panic;
55
66comptime {
7 @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __extendxftf2(a: f80) callconv(.C) f128 {
lib/compiler_rt/fabs.zig+7-7
......@@ -6,15 +6,15 @@ const common = @import("common.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility });
10 @export(fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility });
1313 if (common.want_ppc_abi) {
14 @export(fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility });
1515 }
16 @export(fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility });
1818}
1919
2020pub fn __fabsh(a: f16) callconv(.C) f16 {
lib/compiler_rt/fixdfdi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixdfsi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixdfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixhfdi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixhfdi(a: f16) callconv(.C) i64 {
lib/compiler_rt/fixhfsi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixhfsi(a: f16) callconv(.C) i32 {
lib/compiler_rt/fixhfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixsfdi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixsfsi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixsfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixtfdi.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __fixtfdi(a: f128) callconv(.C) i64 {
lib/compiler_rt/fixtfsi.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __fixtfsi(a: f128) callconv(.C) i32 {
lib/compiler_rt/fixtfti.zig+3-3
......@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
1111 if (common.want_ppc_abi)
12 @export(__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/fixunsdfdi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixunsdfsi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixunsdfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixunshfdi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixunshfdi(a: f16) callconv(.C) u64 {
lib/compiler_rt/fixunshfsi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixunshfsi(a: f16) callconv(.C) u32 {
lib/compiler_rt/fixunshfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixunssfdi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixunssfsi.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/fixunssfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixunstfdi.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
lib/compiler_rt/fixunstfsi.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
lib/compiler_rt/fixunstfti.zig+3-3
......@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
1111 if (common.want_ppc_abi)
12 @export(__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/fixunsxfdi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixunsxfdi(a: f80) callconv(.C) u64 {
lib/compiler_rt/fixunsxfsi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixunsxfsi(a: f80) callconv(.C) u32 {
lib/compiler_rt/fixunsxfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/fixxfdi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixxfdi(a: f80) callconv(.C) i64 {
lib/compiler_rt/fixxfsi.zig+1-1
......@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44pub const panic = common.panic;
55
66comptime {
7 @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __fixxfsi(a: f80) callconv(.C) i32 {
lib/compiler_rt/fixxfti.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floatdidf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatdihf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatdihf(a: i64) callconv(.C) f16 {
lib/compiler_rt/floatdisf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatditf.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __floatditf(a: i64) callconv(.C) f128 {
lib/compiler_rt/floatdixf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatdixf(a: i64) callconv(.C) f80 {
lib/compiler_rt/floatsidf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatsihf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatsihf(a: i32) callconv(.C) f16 {
lib/compiler_rt/floatsisf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatsitf.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __floatsitf(a: i32) callconv(.C) f128 {
lib/compiler_rt/floatsixf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatsixf(a: i32) callconv(.C) f80 {
lib/compiler_rt/floattidf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floattihf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floattisf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floattitf.zig+3-3
......@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
1111 if (common.want_ppc_abi)
12 @export(__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/floattixf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floatundidf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatundihf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatundihf(a: u64) callconv(.C) f16 {
lib/compiler_rt/floatundisf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatunditf.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __floatunditf(a: u64) callconv(.C) f128 {
lib/compiler_rt/floatundixf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatundixf(a: u64) callconv(.C) f80 {
lib/compiler_rt/floatunsidf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatunsihf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __floatunsihf(a: u32) callconv(.C) f16 {
lib/compiler_rt/floatunsisf.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/floatunsitf.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __floatunsitf(a: u32) callconv(.C) f128 {
lib/compiler_rt/floatunsixf.zig+1-1
......@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44pub const panic = common.panic;
55
66comptime {
7 @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __floatunsixf(a: u32) callconv(.C) f80 {
lib/compiler_rt/floatuntidf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floatuntihf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floatuntisf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floatuntitf.zig+3-3
......@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
1111 if (common.want_ppc_abi)
12 @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
1414 }
1515}
1616
lib/compiler_rt/floatuntixf.zig+2-2
......@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
77comptime {
88 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
1010 } else {
11 @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
1212 }
1313}
1414
lib/compiler_rt/floor.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __floorh(x: f16) callconv(.C) f16 {
lib/compiler_rt/fma.zig+7-7
......@@ -13,15 +13,15 @@ const common = @import("common.zig");
1313pub const panic = common.panic;
1414
1515comptime {
16 @export(__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility });
17 @export(fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility });
2020 if (common.want_ppc_abi) {
21 @export(fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility });
2222 }
23 @export(fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility });
24 @export(fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility });
2525}
2626
2727pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 {
lib/compiler_rt/fmax.zig+7-7
......@@ -7,15 +7,15 @@ const common = @import("common.zig");
77pub const panic = common.panic;
88
99comptime {
10 @export(__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility });
1414 if (common.want_ppc_abi) {
15 @export(fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility });
1616 }
17 @export(fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility });
1919}
2020
2121pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/fmin.zig+7-7
......@@ -7,15 +7,15 @@ const common = @import("common.zig");
77pub const panic = common.panic;
88
99comptime {
10 @export(__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility });
1414 if (common.want_ppc_abi) {
15 @export(fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility });
1616 }
17 @export(fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility });
1919}
2020
2121pub fn __fminh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/fmod.zig+7-7
......@@ -9,15 +9,15 @@ const normalize = common.normalize;
99pub const panic = common.panic;
1010
1111comptime {
12 @export(__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility });
13 @export(fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility });
14 @export(fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility });
1616 if (common.want_ppc_abi) {
17 @export(fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility });
1818 }
19 @export(fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility });
20 @export(fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility });
2121}
2222
2323pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/gedf2.zig+4-4
......@@ -7,11 +7,11 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_aeabi) {
10 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility });
1212 } else {
13 @export(__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility });
1515 }
1616}
1717
lib/compiler_rt/gehf2.zig+2-2
......@@ -6,8 +6,8 @@ const comparef = @import("./comparef.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility });
1111}
1212
1313/// "These functions return a value greater than or equal to zero if neither
lib/compiler_rt/gesf2.zig+4-4
......@@ -7,11 +7,11 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_aeabi) {
10 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });
1212 } else {
13 @export(__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });
1515 }
1616}
1717
lib/compiler_rt/getf2.zig+4-4
......@@ -7,14 +7,14 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_ppc_abi) {
10 @export(__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });
1212 } else if (common.want_sparc_abi) {
1313 // These exports are handled in cmptf2.zig because gt and ge on sparc
1414 // are based on calling _Qp_cmp.
1515 }
16 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });
1818}
1919
2020/// "These functions return a value greater than or equal to zero if neither
lib/compiler_rt/gexf2.zig+2-2
......@@ -4,8 +4,8 @@ const comparef = @import("./comparef.zig");
44pub const panic = common.panic;
55
66comptime {
7 @export(__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility });
99}
1010
1111fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
lib/compiler_rt/int.zig+15-15
......@@ -15,24 +15,24 @@ const arm = @import("arm.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility });
2121 if (common.want_aeabi) {
22 @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility });
23 @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility });
2424 } else {
25 @export(__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility });
2727 }
28 @export(__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility });
30 @export(__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility });
31 @export(__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility });
34 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility });
35 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility });
28 @export(&__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility });
30 @export(&__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility });
34 @export(&__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility });
35 @export(&__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility });
3636}
3737
3838pub fn __divmodti4(a: i128, b: i128, rem: *i128) callconv(.C) i128 {
lib/compiler_rt/log.zig+7-7
......@@ -14,15 +14,15 @@ const common = @import("common.zig");
1414pub const panic = common.panic;
1515
1616comptime {
17 @export(__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility });
18 @export(logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility });
2121 if (common.want_ppc_abi) {
22 @export(logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility });
2323 }
24 @export(logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility });
25 @export(logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility });
2626}
2727
2828pub fn __logh(a: f16) callconv(.C) f16 {
lib/compiler_rt/log10.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __log10h(a: f16) callconv(.C) f16 {
lib/compiler_rt/log2.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __log2h(a: f16) callconv(.C) f16 {
lib/compiler_rt/memcmp.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const common = @import("./common.zig");
33
44comptime {
5 @export(memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility });
5 @export(&memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility });
66}
77
88pub fn memcmp(vl: [*]const u8, vr: [*]const u8, n: usize) callconv(.C) c_int {
lib/compiler_rt/memcpy.zig+1-1
......@@ -4,7 +4,7 @@ const builtin = @import("builtin");
44
55comptime {
66 if (builtin.object_format != .c) {
7 @export(memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility });
88 }
99}
1010
lib/compiler_rt/memmove.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const common = @import("./common.zig");
33
44comptime {
5 @export(memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility });
5 @export(&memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility });
66}
77
88pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {
lib/compiler_rt/memset.zig+2-2
......@@ -4,8 +4,8 @@ const builtin = @import("builtin");
44
55comptime {
66 if (builtin.object_format != .c) {
7 @export(memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility });
99 }
1010}
1111
lib/compiler_rt/modti3.zig+2-2
......@@ -11,9 +11,9 @@ pub const panic = common.panic;
1111
1212comptime {
1313 if (common.want_windows_v2u64_abi) {
14 @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
1515 } else {
16 @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
1717 }
1818}
1919
lib/compiler_rt/mulXi3.zig+5-5
......@@ -7,16 +7,16 @@ const native_endian = builtin.cpu.arch.endian();
77pub const panic = common.panic;
88
99comptime {
10 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility });
1111 if (common.want_aeabi) {
12 @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility });
1313 } else {
14 @export(__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility });
1515 }
1616 if (common.want_windows_v2u64_abi) {
17 @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
1818 } else {
19 @export(__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
2020 }
2121}
2222
lib/compiler_rt/muldc3.zig+1-1
......@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility });
99 }
1010}
1111
lib/compiler_rt/muldf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/mulhc3.zig+1-1
......@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility });
99 }
1010}
1111
lib/compiler_rt/mulhf3.zig+1-1
......@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;
44pub const panic = common.panic;
55
66comptime {
7 @export(__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __mulhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/mulo.zig+3-3
......@@ -6,9 +6,9 @@ const common = @import("common.zig");
66pub const panic = common.panic;
77
88comptime {
9 @export(__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility });
1212}
1313
1414// mulo - multiplication overflow
lib/compiler_rt/mulsc3.zig+1-1
......@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility });
99 }
1010}
1111
lib/compiler_rt/mulsf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/multc3.zig+2-2
......@@ -6,8 +6,8 @@ pub const panic = common.panic;
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
88 if (common.want_ppc_abi)
9 @export(__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/multf3.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/mulxc3.zig+1-1
......@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility });
99 }
1010}
1111
lib/compiler_rt/mulxf3.zig+1-1
......@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;
44pub const panic = common.panic;
55
66comptime {
7 @export(__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __mulxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/negXi2.zig+3-3
......@@ -13,9 +13,9 @@ const common = @import("common.zig");
1313pub const panic = common.panic;
1414
1515comptime {
16 @export(__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility });
1919}
2020
2121pub fn __negsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/negdf2.zig+2-2
......@@ -4,9 +4,9 @@ pub const panic = common.panic;
44
55comptime {
66 if (common.want_aeabi) {
7 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility });
88 } else {
9 @export(__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility });
1010 }
1111}
1212
lib/compiler_rt/neghf2.zig+1-1
......@@ -3,7 +3,7 @@ const common = @import("./common.zig");
33pub const panic = common.panic;
44
55comptime {
6 @export(__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility });
6 @export(&__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility });
77}
88
99fn __neghf2(a: f16) callconv(.C) f16 {
lib/compiler_rt/negsf2.zig+2-2
......@@ -4,9 +4,9 @@ pub const panic = common.panic;
44
55comptime {
66 if (common.want_aeabi) {
7 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility });
88 } else {
9 @export(__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility });
1010 }
1111}
1212
lib/compiler_rt/negtf2.zig+2-2
......@@ -4,8 +4,8 @@ pub const panic = common.panic;
44
55comptime {
66 if (common.want_ppc_abi)
7 @export(__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility });
99}
1010
1111fn __negtf2(a: f128) callconv(.C) f128 {
lib/compiler_rt/negv.zig+3-3
......@@ -8,9 +8,9 @@ const common = @import("common.zig");
88pub const panic = common.panic;
99
1010comptime {
11 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility });
1414}
1515
1616pub fn __negvsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/negxf2.zig+1-1
......@@ -3,7 +3,7 @@ const common = @import("./common.zig");
33pub const panic = common.panic;
44
55comptime {
6 @export(__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility });
6 @export(&__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility });
77}
88
99fn __negxf2(a: f80) callconv(.C) f80 {
lib/compiler_rt/os_version_check.zig+1-1
......@@ -9,7 +9,7 @@ const have_availability_version_check = builtin.os.tag.isDarwin() and
99
1010comptime {
1111 if (have_availability_version_check) {
12 @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });
12 @export(&__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });
1313 }
1414}
1515
lib/compiler_rt/parity.zig+3-3
......@@ -8,9 +8,9 @@ const common = @import("common.zig");
88pub const panic = common.panic;
99
1010comptime {
11 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility });
1414}
1515
1616pub fn __paritysi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/popcount.zig+3-3
......@@ -13,9 +13,9 @@ const common = @import("common.zig");
1313pub const panic = common.panic;
1414
1515comptime {
16 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility });
1919}
2020
2121pub fn __popcountsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/powiXf2.zig+6-6
......@@ -10,13 +10,13 @@ const std = @import("std");
1010pub const panic = common.panic;
1111
1212comptime {
13 @export(__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility });
1616 if (common.want_ppc_abi)
17 @export(__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility });
2020}
2121
2222inline fn powiXf2(comptime FT: type, a: FT, b: i32) FT {
lib/compiler_rt/round.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __roundh(x: f16) callconv(.C) f16 {
lib/compiler_rt/shift.zig+12-12
......@@ -7,22 +7,22 @@ pub const panic = common.panic;
77
88comptime {
99 // symbol compatibility with libgcc
10 @export(__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility });
1313
14 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility });
1717
1818 if (common.want_aeabi) {
19 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility });
2222 } else {
23 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility });
2626 }
2727}
2828
lib/compiler_rt/sin.zig+7-7
......@@ -19,15 +19,15 @@ const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1919pub const panic = common.panic;
2020
2121comptime {
22 @export(__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility });
23 @export(sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility });
24 @export(sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility });
2626 if (common.want_ppc_abi) {
27 @export(sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility });
2828 }
29 @export(sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility });
30 @export(sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility });
30 @export(&sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility });
3131}
3232
3333pub fn __sinh(x: f16) callconv(.C) f16 {
lib/compiler_rt/sincos.zig+7-7
......@@ -11,15 +11,15 @@ const common = @import("common.zig");
1111pub const panic = common.panic;
1212
1313comptime {
14 @export(__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility });
1818 if (common.want_ppc_abi) {
19 @export(sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility });
2020 }
21 @export(sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility });
2323}
2424
2525pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void {
lib/compiler_rt/sqrt.zig+7-7
......@@ -7,15 +7,15 @@ const common = @import("common.zig");
77pub const panic = common.panic;
88
99comptime {
10 @export(__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility });
11 @export(sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility });
1414 if (common.want_ppc_abi) {
15 @export(sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility });
1616 }
17 @export(sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility });
1919}
2020
2121pub fn __sqrth(x: f16) callconv(.C) f16 {
lib/compiler_rt/ssp.zig+10-10
......@@ -21,16 +21,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
2121extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;
2222
2323comptime {
24 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
28 @export(__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility });
30 @export(__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility });
31 @export(__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
28 @export(&__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility });
30 @export(&__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility });
3434}
3535
3636fn __stack_chk_fail() callconv(.C) noreturn {
lib/compiler_rt/stack_probe.zig+6-6
......@@ -16,16 +16,16 @@ comptime {
1616 if (builtin.os.tag == .windows) {
1717 // Default stack-probe functions emitted by LLVM
1818 if (is_mingw) {
19 @export(_chkstk, .{ .name = "_alloca", .linkage = linkage });
20 @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage });
19 @export(&_chkstk, .{ .name = "_alloca", .linkage = linkage });
20 @export(&___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage });
2121
2222 if (arch.isAARCH64()) {
23 @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage });
23 @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage });
2424 }
2525 } else if (!builtin.link_libc) {
2626 // This symbols are otherwise exported by MSVCRT.lib
27 @export(_chkstk, .{ .name = "_chkstk", .linkage = linkage });
28 @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage });
27 @export(&_chkstk, .{ .name = "_chkstk", .linkage = linkage });
28 @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage });
2929 }
3030 }
3131
......@@ -33,7 +33,7 @@ comptime {
3333 .x86,
3434 .x86_64,
3535 => {
36 @export(zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage });
36 @export(&zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage });
3737 },
3838 else => {},
3939 }
lib/compiler_rt/subdf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/subhf3.zig+1-1
......@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
44pub const panic = common.panic;
55
66comptime {
7 @export(__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __subhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/subo.zig+3-3
......@@ -10,9 +10,9 @@ const common = @import("common.zig");
1010pub const panic = common.panic;
1111
1212comptime {
13 @export(__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility });
1616}
1717
1818pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 {
lib/compiler_rt/subsf3.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/subtf3.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/subxf3.zig+1-1
......@@ -4,7 +4,7 @@ const common = @import("./common.zig");
44pub const panic = common.panic;
55
66comptime {
7 @export(__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __subxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/tan.zig+7-7
......@@ -21,15 +21,15 @@ const common = @import("common.zig");
2121pub const panic = common.panic;
2222
2323comptime {
24 @export(__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility });
25 @export(tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility });
26 @export(tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility });
2828 if (common.want_ppc_abi) {
29 @export(tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility });
3030 }
31 @export(tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility });
32 @export(tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility });
3333}
3434
3535pub fn __tanh(x: f16) callconv(.C) f16 {
lib/compiler_rt/trunc.zig+7-7
......@@ -15,15 +15,15 @@ const common = @import("common.zig");
1515pub const panic = common.panic;
1616
1717comptime {
18 @export(__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility });
19 @export(truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility });
2222 if (common.want_ppc_abi) {
23 @export(truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility });
2424 }
25 @export(truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility });
2727}
2828
2929pub fn __trunch(x: f16) callconv(.C) f16 {
lib/compiler_rt/truncdfhf2.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/truncdfsf2.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/truncsfhf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.gnu_f16_abi) {
8 @export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_aeabi) {
10 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T(f32) {
lib/compiler_rt/trunctfdf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
lib/compiler_rt/trunctfhf2.zig+1-1
......@@ -4,7 +4,7 @@ const truncf = @import("./truncf.zig").truncf;
44pub const panic = common.panic;
55
66comptime {
7 @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __trunctfhf2(a: f128) callconv(.C) common.F16T(f128) {
lib/compiler_rt/trunctfsf2.zig+3-3
......@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility });
1111 }
12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility });
1313}
1414
1515pub fn __trunctfsf2(a: f128) callconv(.C) f32 {
lib/compiler_rt/trunctfxf2.zig+1-1
......@@ -5,7 +5,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
55pub const panic = common.panic;
66
77comptime {
8 @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility });
99}
1010
1111pub fn __trunctfxf2(a: f128) callconv(.C) f80 {
lib/compiler_rt/truncxfdf2.zig+1-1
......@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __truncxfdf2(a: f80) callconv(.C) f64 {
lib/compiler_rt/truncxfhf2.zig+1-1
......@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __truncxfhf2(a: f80) callconv(.C) common.F16T(f80) {
lib/compiler_rt/truncxfsf2.zig+1-1
......@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
44pub const panic = common.panic;
55
66comptime {
7 @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010fn __truncxfsf2(a: f80) callconv(.C) f32 {
lib/compiler_rt/udivmodei4.zig+2-2
......@@ -7,8 +7,8 @@ const shl = std.math.shl;
77const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535
88
99comptime {
10 @export(__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility });
1212}
1313
1414const endian = builtin.cpu.arch.endian();
lib/compiler_rt/udivmodti4.zig+2-2
......@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_windows_v2u64_abi) {
10 @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
1111 } else {
12 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
1313 }
1414}
1515
lib/compiler_rt/udivti3.zig+2-2
......@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_windows_v2u64_abi) {
10 @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
1111 } else {
12 @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
1313 }
1414}
1515
lib/compiler_rt/umodti3.zig+2-2
......@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_windows_v2u64_abi) {
10 @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
1111 } else {
12 @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
1313 }
1414}
1515
lib/compiler_rt/unorddf2.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/unordhf2.zig+1-1
......@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");
44pub const panic = common.panic;
55
66comptime {
7 @export(__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __unordhf2(a: f16, b: f16) callconv(.C) i32 {
lib/compiler_rt/unordsf2.zig+2-2
......@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_aeabi) {
8 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility });
99 } else {
10 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility });
1111 }
1212}
1313
lib/compiler_rt/unordtf2.zig+2-2
......@@ -5,12 +5,12 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility });
99 } else if (common.want_sparc_abi) {
1010 // These exports are handled in cmptf2.zig because unordered comparisons
1111 // are based on calling _Qp_cmp.
1212 }
13 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility });
1414}
1515
1616fn __unordtf2(a: f128, b: f128) callconv(.C) i32 {
lib/compiler_rt/unordxf2.zig+1-1
......@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");
44pub const panic = common.panic;
55
66comptime {
7 @export(__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility });
88}
99
1010pub fn __unordxf2(a: f80, b: f80) callconv(.C) i32 {
lib/std/Thread/Futex.zig+4-4
......@@ -27,7 +27,7 @@ const atomic = std.atomic;
2727/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically
2828/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.
2929pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {
30 @setCold(true);
30 @branchHint(.cold);
3131
3232 Impl.wait(ptr, expect, null) catch |err| switch (err) {
3333 error.Timeout => unreachable, // null timeout meant to wait forever
......@@ -43,7 +43,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {
4343/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically
4444/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.
4545pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void {
46 @setCold(true);
46 @branchHint(.cold);
4747
4848 // Avoid calling into the OS for no-op timeouts.
4949 if (timeout_ns == 0) {
......@@ -56,7 +56,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er
5656
5757/// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`.
5858pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
59 @setCold(true);
59 @branchHint(.cold);
6060
6161 // Avoid calling into the OS if there's nothing to wake up.
6262 if (max_waiters == 0) {
......@@ -1048,7 +1048,7 @@ pub const Deadline = struct {
10481048 /// - A spurious wake occurs.
10491049 /// - The deadline expires; In which case `error.Timeout` is returned.
10501050 pub fn wait(self: *Deadline, ptr: *const atomic.Value(u32), expect: u32) error{Timeout}!void {
1051 @setCold(true);
1051 @branchHint(.cold);
10521052
10531053 // Check if we actually have a timeout to wait until.
10541054 // If not just wait "forever".
lib/std/Thread/Mutex.zig+1-1
......@@ -169,7 +169,7 @@ const FutexImpl = struct {
169169 }
170170
171171 fn lockSlow(self: *@This()) void {
172 @setCold(true);
172 @branchHint(.cold);
173173
174174 // Avoid doing an atomic swap below if we already know the state is contended.
175175 // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily.
lib/std/Thread/ResetEvent.zig+1-1
......@@ -107,7 +107,7 @@ const FutexImpl = struct {
107107 }
108108
109109 fn waitUntilSet(self: *Impl, timeout: ?u64) error{Timeout}!void {
110 @setCold(true);
110 @branchHint(.cold);
111111
112112 // Try to set the state from `unset` to `waiting` to indicate
113113 // to the set() thread that others are blocked on the ResetEvent.
lib/std/builtin.zig+26-7
......@@ -675,6 +675,25 @@ pub const ExternOptions = struct {
675675 is_thread_local: bool = false,
676676};
677677
678/// This data structure is used by the Zig language code generation and
679/// therefore must be kept in sync with the compiler implementation.
680pub const BranchHint = enum(u3) {
681 /// Equivalent to no hint given.
682 none,
683 /// This branch of control flow is more likely to be reached than its peers.
684 /// The optimizer should optimize for reaching it.
685 likely,
686 /// This branch of control flow is less likely to be reached than its peers.
687 /// The optimizer should optimize for not reaching it.
688 unlikely,
689 /// This branch of control flow is unlikely to *ever* be reached.
690 /// The optimizer may place it in a different page of memory to optimize other branches.
691 cold,
692 /// It is difficult to predict whether this branch of control flow will be reached.
693 /// The optimizer should avoid branching behavior with expensive mispredictions.
694 unpredictable,
695};
696
678697/// This enum is set by the compiler and communicates which compiler backend is
679698/// used to produce machine code.
680699/// Think carefully before deciding to observe this value. Nearly all code should
......@@ -760,7 +779,7 @@ else
760779/// This function is used by the Zig language code generation and
761780/// therefore must be kept in sync with the compiler implementation.
762781pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn {
763 @setCold(true);
782 @branchHint(.cold);
764783
765784 // For backends that cannot handle the language features depended on by the
766785 // default panic handler, we have a simpler panic handler:
......@@ -877,27 +896,27 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void
877896}
878897
879898pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {
880 @setCold(true);
899 @branchHint(.cold);
881900 std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
882901}
883902
884903pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {
885 @setCold(true);
904 @branchHint(.cold);
886905 std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
887906}
888907
889908pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
890 @setCold(true);
909 @branchHint(.cold);
891910 std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
892911}
893912
894913pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {
895 @setCold(true);
914 @branchHint(.cold);
896915 std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end });
897916}
898917
899918pub fn panicInactiveUnionField(active: anytype, wanted: @TypeOf(active)) noreturn {
900 @setCold(true);
919 @branchHint(.cold);
901920 std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{ @tagName(wanted), @tagName(active) });
902921}
903922
......@@ -930,7 +949,7 @@ pub const panic_messages = struct {
930949};
931950
932951pub noinline fn returnError(st: *StackTrace) void {
933 @setCold(true);
952 @branchHint(.cold);
934953 @setRuntimeSafety(false);
935954 addErrRetTraceAddr(st, @returnAddress());
936955}
lib/std/c.zig+1-1
......@@ -40,7 +40,7 @@ pub extern var _mh_execute_header: mach_hdr;
4040var dummy_execute_header: mach_hdr = undefined;
4141comptime {
4242 if (native_os.isDarwin()) {
43 @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });
43 @export(&dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });
4444 }
4545}
4646
lib/std/debug.zig+3-3
......@@ -409,7 +409,7 @@ pub fn assertReadable(slice: []const volatile u8) void {
409409}
410410
411411pub fn panic(comptime format: []const u8, args: anytype) noreturn {
412 @setCold(true);
412 @branchHint(.cold);
413413
414414 panicExtra(@errorReturnTrace(), @returnAddress(), format, args);
415415}
......@@ -422,7 +422,7 @@ pub fn panicExtra(
422422 comptime format: []const u8,
423423 args: anytype,
424424) noreturn {
425 @setCold(true);
425 @branchHint(.cold);
426426
427427 const size = 0x1000;
428428 const trunc_msg = "(msg truncated)";
......@@ -450,7 +450,7 @@ threadlocal var panic_stage: usize = 0;
450450// `panicImpl` could be useful in implementing a custom panic handler which
451451// calls the default handler (on supported platforms)
452452pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn {
453 @setCold(true);
453 @branchHint(.cold);
454454
455455 if (enable_segfault_handler) {
456456 // If a segfault happens while panicking, we want it to actually segfault, not trigger
lib/std/fmt/parse_float/convert_slow.zig+1-1
......@@ -36,7 +36,7 @@ pub fn getShift(n: usize) usize {
3636/// Note that this function needs a lot of stack space and is marked
3737/// cold to hint against inlining into the caller.
3838pub fn convertSlow(comptime T: type, s: []const u8) BiasedFp(T) {
39 @setCold(true);
39 @branchHint(.cold);
4040
4141 const MantissaT = mantissaType(T);
4242 const min_exponent = -(1 << (math.floatExponentBits(T) - 1)) + 1;
lib/std/hash/xxhash.zig+6-6
......@@ -593,7 +593,7 @@ pub const XxHash3 = struct {
593593 }
594594
595595 fn hash3(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
596 @setCold(true);
596 @branchHint(.cold);
597597 std.debug.assert(input.len > 0 and input.len < 4);
598598
599599 const flip: [2]u32 = @bitCast(secret[0..8].*);
......@@ -609,7 +609,7 @@ pub const XxHash3 = struct {
609609 }
610610
611611 fn hash8(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
612 @setCold(true);
612 @branchHint(.cold);
613613 std.debug.assert(input.len >= 4 and input.len <= 8);
614614
615615 const flip: [2]u64 = @bitCast(secret[8..24].*);
......@@ -625,7 +625,7 @@ pub const XxHash3 = struct {
625625 }
626626
627627 fn hash16(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
628 @setCold(true);
628 @branchHint(.cold);
629629 std.debug.assert(input.len > 8 and input.len <= 16);
630630
631631 const flip: [4]u64 = @bitCast(secret[24..56].*);
......@@ -641,7 +641,7 @@ pub const XxHash3 = struct {
641641 }
642642
643643 fn hash128(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
644 @setCold(true);
644 @branchHint(.cold);
645645 std.debug.assert(input.len > 16 and input.len <= 128);
646646
647647 var acc = XxHash64.prime_1 *% @as(u64, input.len);
......@@ -657,7 +657,7 @@ pub const XxHash3 = struct {
657657 }
658658
659659 fn hash240(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
660 @setCold(true);
660 @branchHint(.cold);
661661 std.debug.assert(input.len > 128 and input.len <= 240);
662662
663663 var acc = XxHash64.prime_1 *% @as(u64, input.len);
......@@ -676,7 +676,7 @@ pub const XxHash3 = struct {
676676 }
677677
678678 noinline fn hashLong(seed: u64, input: []const u8) u64 {
679 @setCold(true);
679 @branchHint(.cold);
680680 std.debug.assert(input.len >= 240);
681681
682682 const block_count = ((input.len - 1) / @sizeOf(Block)) * @sizeOf(Block);
lib/std/hash_map.zig+1-1
......@@ -1657,7 +1657,7 @@ pub fn HashMapUnmanaged(
16571657 }
16581658
16591659 fn grow(self: *Self, allocator: Allocator, new_capacity: Size, ctx: Context) Allocator.Error!void {
1660 @setCold(true);
1660 @branchHint(.cold);
16611661 const new_cap = @max(new_capacity, minimal_capacity);
16621662 assert(new_cap > self.capacity());
16631663 assert(std.math.isPowerOfTwo(new_cap));
lib/std/heap/WasmPageAllocator.zig+1-1
......@@ -61,7 +61,7 @@ const FreeBlock = struct {
6161 const not_found = maxInt(usize);
6262
6363 fn useRecycled(self: FreeBlock, num_pages: usize, log2_align: u8) usize {
64 @setCold(true);
64 @branchHint(.cold);
6565 for (self.data, 0..) |segment, i| {
6666 const spills_into_next = @as(i128, @bitCast(segment)) < 0;
6767 const has_enough_bits = @popCount(segment) >= num_pages;
lib/std/log.zig+1-1
......@@ -171,7 +171,7 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
171171 comptime format: []const u8,
172172 args: anytype,
173173 ) void {
174 @setCold(true);
174 @branchHint(.cold);
175175 log(.err, scope, format, args);
176176 }
177177
lib/std/once.zig+1-1
......@@ -25,7 +25,7 @@ pub fn Once(comptime f: fn () void) type {
2525 }
2626
2727 fn callSlow(self: *@This()) void {
28 @setCold(true);
28 @branchHint(.cold);
2929
3030 self.mutex.lock();
3131 defer self.mutex.unlock();
lib/std/os/emscripten.zig+2-2
......@@ -21,8 +21,8 @@ comptime {
2121 if (builtin.os.tag == .emscripten) {
2222 if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) {
2323 // Emscripten does not provide these symbols, so we must export our own
24 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong });
25 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong });
24 @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong });
25 @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong });
2626 }
2727 }
2828}
lib/std/os/linux.zig+1-1
......@@ -434,7 +434,7 @@ comptime {
434434 // Export this only when building executable, otherwise it is overriding
435435 // the libc implementation
436436 if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {
437 @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
437 @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
438438 }
439439}
440440
lib/std/posix.zig+1-1
......@@ -654,7 +654,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void {
654654/// it raises SIGABRT followed by SIGKILL and finally lo
655655/// Invokes the current signal handler for SIGABRT, if any.
656656pub fn abort() noreturn {
657 @setCold(true);
657 @branchHint(.cold);
658658 // MSVCRT abort() sometimes opens a popup window which is undesirable, so
659659 // even when linking libc on Windows we use our own abort implementation.
660660 // See https://github.com/ziglang/zig/issues/2071 for more details.
lib/std/sort/pdq.zig+2-2
......@@ -203,7 +203,7 @@ fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize {
203203///
204204/// returns `true` if the slice is sorted at the end. This function is `O(n)` worst-case.
205205fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {
206 @setCold(true);
206 @branchHint(.cold);
207207
208208 // maximum number of adjacent out-of-order pairs that will get shifted
209209 const max_steps = 5;
......@@ -247,7 +247,7 @@ fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {
247247}
248248
249249fn breakPatterns(a: usize, b: usize, context: anytype) void {
250 @setCold(true);
250 @branchHint(.cold);
251251
252252 const len = b - a;
253253 if (len < 8) return;
lib/std/start.zig+13-13
......@@ -31,38 +31,38 @@ comptime {
3131 if (builtin.output_mode == .Exe) {
3232 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
3333 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
34 @export(main2, .{ .name = "main" });
34 @export(&main2, .{ .name = "main" });
3535 }
3636 } else if (builtin.os.tag == .windows) {
3737 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {
38 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
38 @export(&wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
3939 }
4040 } else if (builtin.os.tag == .opencl) {
4141 if (@hasDecl(root, "main"))
42 @export(spirvMain2, .{ .name = "main" });
42 @export(&spirvMain2, .{ .name = "main" });
4343 } else {
4444 if (!@hasDecl(root, "_start")) {
45 @export(_start2, .{ .name = "_start" });
45 @export(&_start2, .{ .name = "_start" });
4646 }
4747 }
4848 }
4949 } else {
5050 if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
5151 if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
52 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
52 @export(&_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
5353 }
5454 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
5555 if (builtin.link_libc and @hasDecl(root, "main")) {
5656 if (native_arch.isWasm()) {
57 @export(mainWithoutEnv, .{ .name = "main" });
57 @export(&mainWithoutEnv, .{ .name = "main" });
5858 } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
59 @export(main, .{ .name = "main" });
59 @export(&main, .{ .name = "main" });
6060 }
6161 } else if (native_os == .windows) {
6262 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and
6363 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))
6464 {
65 @export(WinStartup, .{ .name = "wWinMainCRTStartup" });
65 @export(&WinStartup, .{ .name = "wWinMainCRTStartup" });
6666 } else if (@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and
6767 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))
6868 {
......@@ -70,10 +70,10 @@ comptime {
7070 } else if (@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup") and
7171 !@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup"))
7272 {
73 @export(wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" });
73 @export(&wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" });
7474 }
7575 } else if (native_os == .uefi) {
76 if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" });
76 if (!@hasDecl(root, "EfiMain")) @export(&EfiMain, .{ .name = "EfiMain" });
7777 } else if (native_os == .wasi) {
7878 const wasm_start_sym = switch (builtin.wasi_exec_model) {
7979 .reactor => "_initialize",
......@@ -82,14 +82,14 @@ comptime {
8282 if (!@hasDecl(root, wasm_start_sym) and @hasDecl(root, "main")) {
8383 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which
8484 // case it's not required to provide an entrypoint such as main.
85 @export(wasi_start, .{ .name = wasm_start_sym });
85 @export(&wasi_start, .{ .name = wasm_start_sym });
8686 }
8787 } else if (native_arch.isWasm() and native_os == .freestanding) {
8888 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which
8989 // case it's not required to provide an entrypoint such as main.
90 if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(wasm_freestanding_start, .{ .name = start_sym_name });
90 if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(&wasm_freestanding_start, .{ .name = start_sym_name });
9191 } else if (native_os != .other and native_os != .freestanding) {
92 if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name });
92 if (!@hasDecl(root, start_sym_name)) @export(&_start, .{ .name = start_sym_name });
9393 }
9494 }
9595 }
lib/std/zig/AstGen.zig+97-136
......@@ -811,18 +811,18 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
811811 .builtin_call_two, .builtin_call_two_comma => {
812812 if (node_datas[node].lhs == 0) {
813813 const params = [_]Ast.Node.Index{};
814 return builtinCall(gz, scope, ri, node, &params);
814 return builtinCall(gz, scope, ri, node, &params, false);
815815 } else if (node_datas[node].rhs == 0) {
816816 const params = [_]Ast.Node.Index{node_datas[node].lhs};
817 return builtinCall(gz, scope, ri, node, &params);
817 return builtinCall(gz, scope, ri, node, &params, false);
818818 } else {
819819 const params = [_]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
820 return builtinCall(gz, scope, ri, node, &params);
820 return builtinCall(gz, scope, ri, node, &params, false);
821821 }
822822 },
823823 .builtin_call, .builtin_call_comma => {
824824 const params = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
825 return builtinCall(gz, scope, ri, node, params);
825 return builtinCall(gz, scope, ri, node, params, false);
826826 },
827827
828828 .call_one,
......@@ -1017,16 +1017,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
10171017 .block_two, .block_two_semicolon => {
10181018 const statements = [2]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
10191019 if (node_datas[node].lhs == 0) {
1020 return blockExpr(gz, scope, ri, node, statements[0..0]);
1020 return blockExpr(gz, scope, ri, node, statements[0..0], .normal);
10211021 } else if (node_datas[node].rhs == 0) {
1022 return blockExpr(gz, scope, ri, node, statements[0..1]);
1022 return blockExpr(gz, scope, ri, node, statements[0..1], .normal);
10231023 } else {
1024 return blockExpr(gz, scope, ri, node, statements[0..2]);
1024 return blockExpr(gz, scope, ri, node, statements[0..2], .normal);
10251025 }
10261026 },
10271027 .block, .block_semicolon => {
10281028 const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
1029 return blockExpr(gz, scope, ri, node, statements);
1029 return blockExpr(gz, scope, ri, node, statements, .normal);
10301030 },
10311031 .enum_literal => return simpleStrTok(gz, ri, main_tokens[node], node, .enum_literal),
10321032 .error_value => return simpleStrTok(gz, ri, node_datas[node].rhs, node, .error_value),
......@@ -1241,7 +1241,7 @@ fn suspendExpr(
12411241 suspend_scope.suspend_node = node;
12421242 defer suspend_scope.unstack();
12431243
1244 const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node);
1244 const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node, .normal);
12451245 if (!gz.refIsNoReturn(body_result)) {
12461246 _ = try suspend_scope.addBreak(.break_inline, suspend_inst, .void_value);
12471247 }
......@@ -1362,7 +1362,7 @@ fn fnProtoExpr(
13621362 assert(param_type_node != 0);
13631363 var param_gz = block_scope.makeSubBlock(scope);
13641364 defer param_gz.unstack();
1365 const param_type = try fullBodyExpr(&param_gz, scope, coerced_type_ri, param_type_node);
1365 const param_type = try fullBodyExpr(&param_gz, scope, coerced_type_ri, param_type_node, .normal);
13661366 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);
13671367 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
13681368 const main_tokens = tree.nodes.items(.main_token);
......@@ -2040,13 +2040,13 @@ fn comptimeExpr(
20402040 else
20412041 stmts[0..2];
20422042
2043 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true);
2043 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true, .normal);
20442044 return rvalue(gz, ri, block_ref, node);
20452045 },
20462046 .block, .block_semicolon => {
20472047 const stmts = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
20482048 // Replace result location and copy back later - see above.
2049 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true);
2049 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true, .normal);
20502050 return rvalue(gz, ri, block_ref, node);
20512051 },
20522052 else => unreachable,
......@@ -2071,7 +2071,7 @@ fn comptimeExpr(
20712071 else
20722072 .none,
20732073 };
2074 const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node);
2074 const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node, .normal);
20752075 if (!gz.refIsNoReturn(block_result)) {
20762076 _ = try block_scope.addBreak(.@"break", block_inst, block_result);
20772077 }
......@@ -2311,6 +2311,7 @@ fn fullBodyExpr(
23112311 scope: *Scope,
23122312 ri: ResultInfo,
23132313 node: Ast.Node.Index,
2314 block_kind: BlockKind,
23142315) InnerError!Zir.Inst.Ref {
23152316 const tree = gz.astgen.tree;
23162317 const node_tags = tree.nodes.items(.tag);
......@@ -2340,21 +2341,24 @@ fn fullBodyExpr(
23402341 // Labeled blocks are tricky - forwarding result location information properly is non-trivial,
23412342 // plus if this block is exited with a `break_inline` we aren't allowed multiple breaks. This
23422343 // case is rare, so just treat it as a normal expression and create a nested block.
2343 return expr(gz, scope, ri, node);
2344 return blockExpr(gz, scope, ri, node, statements, block_kind);
23442345 }
23452346
23462347 var sub_gz = gz.makeSubBlock(scope);
2347 try blockExprStmts(&sub_gz, &sub_gz.base, statements);
2348 try blockExprStmts(&sub_gz, &sub_gz.base, statements, block_kind);
23482349
23492350 return rvalue(gz, ri, .void_value, node);
23502351}
23512352
2353const BlockKind = enum { normal, allow_branch_hint };
2354
23522355fn blockExpr(
23532356 gz: *GenZir,
23542357 scope: *Scope,
23552358 ri: ResultInfo,
23562359 block_node: Ast.Node.Index,
23572360 statements: []const Ast.Node.Index,
2361 kind: BlockKind,
23582362) InnerError!Zir.Inst.Ref {
23592363 const astgen = gz.astgen;
23602364 const tree = astgen.tree;
......@@ -2365,7 +2369,7 @@ fn blockExpr(
23652369 if (token_tags[lbrace - 1] == .colon and
23662370 token_tags[lbrace - 2] == .identifier)
23672371 {
2368 return labeledBlockExpr(gz, scope, ri, block_node, statements, false);
2372 return labeledBlockExpr(gz, scope, ri, block_node, statements, false, kind);
23692373 }
23702374
23712375 if (!gz.is_comptime) {
......@@ -2380,7 +2384,7 @@ fn blockExpr(
23802384 var block_scope = gz.makeSubBlock(scope);
23812385 defer block_scope.unstack();
23822386
2383 try blockExprStmts(&block_scope, &block_scope.base, statements);
2387 try blockExprStmts(&block_scope, &block_scope.base, statements, kind);
23842388
23852389 if (!block_scope.endsWithNoReturn()) {
23862390 // As our last action before the break, "pop" the error trace if needed
......@@ -2391,7 +2395,7 @@ fn blockExpr(
23912395 try block_scope.setBlockBody(block_inst);
23922396 } else {
23932397 var sub_gz = gz.makeSubBlock(scope);
2394 try blockExprStmts(&sub_gz, &sub_gz.base, statements);
2398 try blockExprStmts(&sub_gz, &sub_gz.base, statements, kind);
23952399 }
23962400
23972401 return rvalue(gz, ri, .void_value, block_node);
......@@ -2436,6 +2440,7 @@ fn labeledBlockExpr(
24362440 block_node: Ast.Node.Index,
24372441 statements: []const Ast.Node.Index,
24382442 force_comptime: bool,
2443 block_kind: BlockKind,
24392444) InnerError!Zir.Inst.Ref {
24402445 const astgen = gz.astgen;
24412446 const tree = astgen.tree;
......@@ -2476,7 +2481,7 @@ fn labeledBlockExpr(
24762481 if (force_comptime) block_scope.is_comptime = true;
24772482 defer block_scope.unstack();
24782483
2479 try blockExprStmts(&block_scope, &block_scope.base, statements);
2484 try blockExprStmts(&block_scope, &block_scope.base, statements, block_kind);
24802485 if (!block_scope.endsWithNoReturn()) {
24812486 // As our last action before the return, "pop" the error trace if needed
24822487 _ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node);
......@@ -2495,7 +2500,7 @@ fn labeledBlockExpr(
24952500 }
24962501}
24972502
2498fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index) !void {
2503fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index, block_kind: BlockKind) !void {
24992504 const astgen = gz.astgen;
25002505 const tree = astgen.tree;
25012506 const node_tags = tree.nodes.items(.tag);
......@@ -2509,7 +2514,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
25092514
25102515 var noreturn_src_node: Ast.Node.Index = 0;
25112516 var scope = parent_scope;
2512 for (statements) |statement| {
2517 for (statements, 0..) |statement, stmt_idx| {
25132518 if (noreturn_src_node != 0) {
25142519 try astgen.appendErrorNodeNotes(
25152520 statement,
......@@ -2524,6 +2529,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
25242529 },
25252530 );
25262531 }
2532 const allow_branch_hint = switch (block_kind) {
2533 .normal => false,
2534 .allow_branch_hint => stmt_idx == 0,
2535 };
25272536 var inner_node = statement;
25282537 while (true) {
25292538 switch (node_tags[inner_node]) {
......@@ -2567,6 +2576,30 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
25672576 .for_simple,
25682577 .@"for", => _ = try forExpr(gz, scope, .{ .rl = .none }, inner_node, tree.fullFor(inner_node).?, true),
25692578
2579 // These cases are here to allow branch hints.
2580 .builtin_call_two, .builtin_call_two_comma => {
2581 try emitDbgNode(gz, inner_node);
2582 const ri: ResultInfo = .{ .rl = .none };
2583 const result = if (node_data[inner_node].lhs == 0) r: {
2584 break :r try builtinCall(gz, scope, ri, inner_node, &.{}, allow_branch_hint);
2585 } else if (node_data[inner_node].rhs == 0) r: {
2586 break :r try builtinCall(gz, scope, ri, inner_node, &.{node_data[inner_node].lhs}, allow_branch_hint);
2587 } else r: {
2588 break :r try builtinCall(gz, scope, ri, inner_node, &.{
2589 node_data[inner_node].lhs,
2590 node_data[inner_node].rhs,
2591 }, allow_branch_hint);
2592 };
2593 noreturn_src_node = try addEnsureResult(gz, result, inner_node);
2594 },
2595 .builtin_call, .builtin_call_comma => {
2596 try emitDbgNode(gz, inner_node);
2597 const ri: ResultInfo = .{ .rl = .none };
2598 const params = tree.extra_data[node_data[inner_node].lhs..node_data[inner_node].rhs];
2599 const result = try builtinCall(gz, scope, ri, inner_node, params, allow_branch_hint);
2600 noreturn_src_node = try addEnsureResult(gz, result, inner_node);
2601 },
2602
25702603 else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node),
25712604 // zig fmt: on
25722605 }
......@@ -2827,7 +2860,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
28272860 .fence,
28282861 .set_float_mode,
28292862 .set_align_stack,
2830 .set_cold,
2863 .branch_hint,
28312864 => break :b true,
28322865 else => break :b false,
28332866 },
......@@ -2861,7 +2894,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
28612894 .ensure_result_non_error,
28622895 .ensure_err_union_payload_void,
28632896 .@"export",
2864 .export_value,
28652897 .set_eval_branch_quota,
28662898 .atomic_store,
28672899 .store_node,
......@@ -4155,7 +4187,7 @@ fn fnDecl(
41554187 assert(param_type_node != 0);
41564188 var param_gz = decl_gz.makeSubBlock(scope);
41574189 defer param_gz.unstack();
4158 const param_type = try fullBodyExpr(&param_gz, params_scope, coerced_type_ri, param_type_node);
4190 const param_type = try fullBodyExpr(&param_gz, params_scope, coerced_type_ri, param_type_node, .normal);
41594191 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);
41604192 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
41614193
......@@ -4277,7 +4309,7 @@ fn fnDecl(
42774309 var ret_gz = decl_gz.makeSubBlock(params_scope);
42784310 defer ret_gz.unstack();
42794311 const ret_ref: Zir.Inst.Ref = inst: {
4280 const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type);
4312 const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type, .normal);
42814313 if (ret_gz.instructionsSlice().len == 0) {
42824314 // In this case we will send a len=0 body which can be encoded more efficiently.
42834315 break :inst inst;
......@@ -4352,7 +4384,7 @@ fn fnDecl(
43524384 const lbrace_line = astgen.source_line - decl_gz.decl_line;
43534385 const lbrace_column = astgen.source_column;
43544386
4355 _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node);
4387 _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node, .allow_branch_hint);
43564388 try checkUsed(gz, &fn_gz.base, params_scope);
43574389
43584390 if (!fn_gz.endsWithNoReturn()) {
......@@ -4553,20 +4585,20 @@ fn globalVarDecl(
45534585
45544586 var align_gz = block_scope.makeSubBlock(scope);
45554587 if (var_decl.ast.align_node != 0) {
4556 const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node);
4588 const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node, .normal);
45574589 _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, align_inst, node);
45584590 }
45594591
45604592 var linksection_gz = align_gz.makeSubBlock(scope);
45614593 if (var_decl.ast.section_node != 0) {
4562 const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node);
4594 const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node, .normal);
45634595 _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node);
45644596 }
45654597
45664598 var addrspace_gz = linksection_gz.makeSubBlock(scope);
45674599 if (var_decl.ast.addrspace_node != 0) {
45684600 const addrspace_ty = try addrspace_gz.addBuiltinValue(var_decl.ast.addrspace_node, .address_space);
4569 const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node);
4601 const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node, .normal);
45704602 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);
45714603 }
45724604
......@@ -4623,7 +4655,7 @@ fn comptimeDecl(
46234655 };
46244656 defer decl_block.unstack();
46254657
4626 const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node);
4658 const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node, .normal);
46274659 if (decl_block.isEmpty() or !decl_block.refIsNoReturn(block_result)) {
46284660 _ = try decl_block.addBreak(.break_inline, decl_inst, .void_value);
46294661 }
......@@ -4844,7 +4876,7 @@ fn testDecl(
48444876 const lbrace_line = astgen.source_line - decl_block.decl_line;
48454877 const lbrace_column = astgen.source_column;
48464878
4847 const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node);
4879 const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node, .normal);
48484880 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
48494881
48504882 // As our last action before the return, "pop" the error trace if needed
......@@ -6113,7 +6145,7 @@ fn orelseCatchExpr(
61136145 break :blk &err_val_scope.base;
61146146 };
61156147
6116 const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs);
6148 const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs, .allow_branch_hint);
61176149 if (!else_scope.endsWithNoReturn()) {
61186150 // As our last action before the break, "pop" the error trace if needed
61196151 if (do_err_trace)
......@@ -6281,7 +6313,7 @@ fn boolBinOp(
62816313
62826314 var rhs_scope = gz.makeSubBlock(scope);
62836315 defer rhs_scope.unstack();
6284 const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs);
6316 const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs, .allow_branch_hint);
62856317 if (!gz.refIsNoReturn(rhs)) {
62866318 _ = try rhs_scope.addBreakWithSrcNode(.break_inline, bool_br, rhs, node_datas[node].rhs);
62876319 }
......@@ -6425,7 +6457,7 @@ fn ifExpr(
64256457 }
64266458 };
64276459
6428 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node);
6460 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node, .allow_branch_hint);
64296461 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
64306462 if (!then_scope.endsWithNoReturn()) {
64316463 _ = try then_scope.addBreakWithSrcNode(.@"break", block, then_result, then_node);
......@@ -6467,7 +6499,7 @@ fn ifExpr(
64676499 break :s &else_scope.base;
64686500 }
64696501 };
6470 const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node);
6502 const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node, .allow_branch_hint);
64716503 if (!else_scope.endsWithNoReturn()) {
64726504 // As our last action before the break, "pop" the error trace if needed
64736505 if (do_err_trace)
......@@ -6576,7 +6608,7 @@ fn whileExpr(
65766608 } = c: {
65776609 if (while_full.error_token) |_| {
65786610 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };
6579 const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr);
6611 const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal);
65806612 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_err_ptr else .is_non_err;
65816613 break :c .{
65826614 .inst = err_union,
......@@ -6584,14 +6616,14 @@ fn whileExpr(
65846616 };
65856617 } else if (while_full.payload_token) |_| {
65866618 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };
6587 const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr);
6619 const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal);
65886620 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
65896621 break :c .{
65906622 .inst = optional,
65916623 .bool_bit = try cond_scope.addUnNode(tag, optional, while_full.ast.cond_expr),
65926624 };
65936625 } else {
6594 const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr);
6626 const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr, .normal);
65956627 break :c .{
65966628 .inst = cond,
65976629 .bool_bit = cond,
......@@ -6716,7 +6748,7 @@ fn whileExpr(
67166748 continue_scope.instructions_top = continue_scope.instructions.items.len;
67176749 {
67186750 try emitDbgNode(&continue_scope, then_node);
6719 const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node);
6751 const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node, .allow_branch_hint);
67206752 _ = try addEnsureResult(&continue_scope, unused_result, then_node);
67216753 }
67226754 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
......@@ -6762,7 +6794,7 @@ fn whileExpr(
67626794 // control flow apply to outer loops; not this one.
67636795 loop_scope.continue_block = .none;
67646796 loop_scope.break_block = .none;
6765 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node);
6797 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint);
67666798 if (is_statement) {
67676799 _ = try addEnsureResult(&else_scope, else_result, else_node);
67686800 }
......@@ -7030,7 +7062,7 @@ fn forExpr(
70307062 break :blk capture_sub_scope;
70317063 };
70327064
7033 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node);
7065 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node, .allow_branch_hint);
70347066 _ = try addEnsureResult(&then_scope, then_result, then_node);
70357067
70367068 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
......@@ -7049,7 +7081,7 @@ fn forExpr(
70497081 // control flow apply to outer loops; not this one.
70507082 loop_scope.continue_block = .none;
70517083 loop_scope.break_block = .none;
7052 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node);
7084 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint);
70537085 if (is_statement) {
70547086 _ = try addEnsureResult(&else_scope, else_result, else_node);
70557087 }
......@@ -7526,7 +7558,7 @@ fn switchExprErrUnion(
75267558 }
75277559
75287560 const target_expr_node = case.ast.target_expr;
7529 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node);
7561 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint);
75307562 // check capture_scope, not err_scope to avoid false positive unused error capture
75317563 try checkUsed(parent_gz, &case_scope.base, err_scope.parent);
75327564 const uses_err = err_scope.used != 0 or err_scope.discarded != 0;
......@@ -7987,7 +8019,7 @@ fn switchExpr(
79878019 try case_scope.addDbgVar(.dbg_var_val, dbg_var_tag_name, dbg_var_tag_inst);
79888020 }
79898021 const target_expr_node = case.ast.target_expr;
7990 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node);
8022 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint);
79918023 try checkUsed(parent_gz, &case_scope.base, sub_scope);
79928024 if (!parent_gz.refIsNoReturn(case_result)) {
79938025 _ = try case_scope.addBreakWithSrcNode(.@"break", switch_block, case_result, target_expr_node);
......@@ -9155,6 +9187,7 @@ fn builtinCall(
91559187 ri: ResultInfo,
91569188 node: Ast.Node.Index,
91579189 params: []const Ast.Node.Index,
9190 allow_branch_hint: bool,
91589191) InnerError!Zir.Inst.Ref {
91599192 const astgen = gz.astgen;
91609193 const tree = astgen.tree;
......@@ -9188,6 +9221,18 @@ fn builtinCall(
91889221 return astgen.failNode(node, "'{s}' outside function scope", .{builtin_name});
91899222
91909223 switch (info.tag) {
9224 .branch_hint => {
9225 if (!allow_branch_hint) {
9226 return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{});
9227 }
9228 const hint_ty = try gz.addBuiltinValue(node, .branch_hint);
9229 const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0]);
9230 _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{
9231 .node = gz.nodeIndexToRelative(node),
9232 .operand = hint_val,
9233 });
9234 return rvalue(gz, ri, .void_value, node);
9235 },
91919236 .import => {
91929237 const node_tags = tree.nodes.items(.tag);
91939238 const operand_node = params[0];
......@@ -9249,87 +9294,11 @@ fn builtinCall(
92499294 // zig fmt: on
92509295
92519296 .@"export" => {
9297 const exported = try expr(gz, scope, .{ .rl = .none }, params[0]);
92529298 const export_options_ty = try gz.addBuiltinValue(node, .export_options);
9253 const node_tags = tree.nodes.items(.tag);
9254 const node_datas = tree.nodes.items(.data);
9255 // This function causes a Decl to be exported. The first parameter is not an expression,
9256 // but an identifier of the Decl to be exported.
9257 var namespace: Zir.Inst.Ref = .none;
9258 var decl_name: Zir.NullTerminatedString = .empty;
9259 switch (node_tags[params[0]]) {
9260 .identifier => {
9261 const ident_token = main_tokens[params[0]];
9262 if (isPrimitive(tree.tokenSlice(ident_token))) {
9263 return astgen.failTok(ident_token, "unable to export primitive value", .{});
9264 }
9265 decl_name = try astgen.identAsString(ident_token);
9266
9267 var s = scope;
9268 var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already
9269 while (true) switch (s.tag) {
9270 .local_val => {
9271 const local_val = s.cast(Scope.LocalVal).?;
9272 if (local_val.name == decl_name) {
9273 local_val.used = ident_token;
9274 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9275 .operand = local_val.inst,
9276 .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]),
9277 });
9278 return rvalue(gz, ri, .void_value, node);
9279 }
9280 s = local_val.parent;
9281 },
9282 .local_ptr => {
9283 const local_ptr = s.cast(Scope.LocalPtr).?;
9284 if (local_ptr.name == decl_name) {
9285 if (!local_ptr.maybe_comptime)
9286 return astgen.failNode(params[0], "unable to export runtime-known value", .{});
9287 local_ptr.used = ident_token;
9288 const loaded = try gz.addUnNode(.load, local_ptr.ptr, node);
9289 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9290 .operand = loaded,
9291 .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]),
9292 });
9293 return rvalue(gz, ri, .void_value, node);
9294 }
9295 s = local_ptr.parent;
9296 },
9297 .gen_zir => s = s.cast(GenZir).?.parent,
9298 .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent,
9299 .namespace => {
9300 const ns = s.cast(Scope.Namespace).?;
9301 if (ns.decls.get(decl_name)) |i| {
9302 if (found_already) |f| {
9303 return astgen.failNodeNotes(node, "ambiguous reference", .{}, &.{
9304 try astgen.errNoteNode(f, "declared here", .{}),
9305 try astgen.errNoteNode(i, "also declared here", .{}),
9306 });
9307 }
9308 // We found a match but must continue looking for ambiguous references to decls.
9309 found_already = i;
9310 }
9311 s = ns.parent;
9312 },
9313 .top => break,
9314 };
9315 if (found_already == null) {
9316 const ident_name = try astgen.identifierTokenString(ident_token);
9317 return astgen.failNode(params[0], "use of undeclared identifier '{s}'", .{ident_name});
9318 }
9319 },
9320 .field_access => {
9321 const namespace_node = node_datas[params[0]].lhs;
9322 namespace = try typeExpr(gz, scope, namespace_node);
9323 const dot_token = main_tokens[params[0]];
9324 const field_ident = dot_token + 1;
9325 decl_name = try astgen.identAsString(field_ident);
9326 },
9327 else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}),
9328 }
93299299 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]);
93309300 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
9331 .namespace = namespace,
9332 .decl_name = decl_name,
9301 .exported = exported,
93339302 .options = options,
93349303 });
93359304 return rvalue(gz, ri, .void_value, node);
......@@ -9371,14 +9340,6 @@ fn builtinCall(
93719340 });
93729341 return rvalue(gz, ri, .void_value, node);
93739342 },
9374 .set_cold => {
9375 const order = try expr(gz, scope, ri, params[0]);
9376 _ = try gz.addExtendedPayload(.set_cold, Zir.Inst.UnNode{
9377 .node = gz.nodeIndexToRelative(node),
9378 .operand = order,
9379 });
9380 return rvalue(gz, ri, .void_value, node);
9381 },
93829343
93839344 .src => {
93849345 // Incorporate the source location into the source hash, so that
......@@ -10040,7 +10001,7 @@ fn cImport(
1004010001 defer block_scope.unstack();
1004110002
1004210003 const block_inst = try gz.makeBlockInst(.c_import, node);
10043 const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node);
10004 const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node, .normal);
1004410005 _ = try gz.addUnNode(.ensure_result_used, block_result, node);
1004510006 if (!gz.refIsNoReturn(block_result)) {
1004610007 _ = try block_scope.addBreak(.break_inline, block_inst, .void_value);
......@@ -10123,7 +10084,7 @@ fn callExpr(
1012310084 defer arg_block.unstack();
1012410085
1012510086 // `call_inst` is reused to provide the param type.
10126 const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node);
10087 const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node, .normal);
1012710088 _ = try arg_block.addBreakWithSrcNode(.break_inline, call_index, arg_ref, param_node);
1012810089
1012910090 const body = arg_block.instructionsSlice();
......@@ -11474,7 +11435,7 @@ fn appendErrorNodeNotes(
1147411435 args: anytype,
1147511436 notes: []const u32,
1147611437) Allocator.Error!void {
11477 @setCold(true);
11438 @branchHint(.cold);
1147811439 const string_bytes = &astgen.string_bytes;
1147911440 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
1148011441 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
......@@ -11565,7 +11526,7 @@ fn appendErrorTokNotesOff(
1156511526 args: anytype,
1156611527 notes: []const u32,
1156711528) !void {
11568 @setCold(true);
11529 @branchHint(.cold);
1156911530 const gpa = astgen.gpa;
1157011531 const string_bytes = &astgen.string_bytes;
1157111532 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
......@@ -11602,7 +11563,7 @@ fn errNoteTokOff(
1160211563 comptime format: []const u8,
1160311564 args: anytype,
1160411565) Allocator.Error!u32 {
11605 @setCold(true);
11566 @branchHint(.cold);
1160611567 const string_bytes = &astgen.string_bytes;
1160711568 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
1160811569 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
......@@ -11621,7 +11582,7 @@ fn errNoteNode(
1162111582 comptime format: []const u8,
1162211583 args: anytype,
1162311584) Allocator.Error!u32 {
11624 @setCold(true);
11585 @branchHint(.cold);
1162511586 const string_bytes = &astgen.string_bytes;
1162611587 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
1162711588 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
lib/std/zig/AstRlAnnotate.zig+4-1
......@@ -829,6 +829,10 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
829829 }
830830 switch (info.tag) {
831831 .import => return false,
832 .branch_hint => {
833 _ = try astrl.expr(args[0], block, ResultInfo.type_only);
834 return false;
835 },
832836 .compile_log, .TypeOf => {
833837 for (args) |arg_node| {
834838 _ = try astrl.expr(arg_node, block, ResultInfo.none);
......@@ -907,7 +911,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
907911 .fence,
908912 .set_float_mode,
909913 .set_align_stack,
910 .set_cold,
911914 .type_info,
912915 .work_item_id,
913916 .work_group_size,
lib/std/zig/BuiltinFn.zig+9-9
......@@ -14,6 +14,7 @@ pub const Tag = enum {
1414 bit_offset_of,
1515 int_from_bool,
1616 bit_size_of,
17 branch_hint,
1718 breakpoint,
1819 disable_instrumentation,
1920 mul_add,
......@@ -82,7 +83,6 @@ pub const Tag = enum {
8283 return_address,
8384 select,
8485 set_align_stack,
85 set_cold,
8686 set_eval_branch_quota,
8787 set_float_mode,
8888 set_runtime_safety,
......@@ -256,6 +256,14 @@ pub const list = list: {
256256 .param_count = 1,
257257 },
258258 },
259 .{
260 "@branchHint",
261 .{
262 .tag = .branch_hint,
263 .param_count = 1,
264 .illegal_outside_function = true,
265 },
266 },
259267 .{
260268 "@breakpoint",
261269 .{
......@@ -744,14 +752,6 @@ pub const list = list: {
744752 .illegal_outside_function = true,
745753 },
746754 },
747 .{
748 "@setCold",
749 .{
750 .tag = .set_cold,
751 .param_count = 1,
752 .illegal_outside_function = true,
753 },
754 },
755755 .{
756756 "@setEvalBranchQuota",
757757 .{
lib/std/zig/Parse.zig+6-6
......@@ -81,7 +81,7 @@ fn addExtra(p: *Parse, extra: anytype) Allocator.Error!Node.Index {
8181}
8282
8383fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {
84 @setCold(true);
84 @branchHint(.cold);
8585 try p.warnMsg(.{
8686 .tag = .expected_token,
8787 .token = p.tok_i,
......@@ -90,12 +90,12 @@ fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {
9090}
9191
9292fn warn(p: *Parse, error_tag: AstError.Tag) error{OutOfMemory}!void {
93 @setCold(true);
93 @branchHint(.cold);
9494 try p.warnMsg(.{ .tag = error_tag, .token = p.tok_i });
9595}
9696
9797fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {
98 @setCold(true);
98 @branchHint(.cold);
9999 switch (msg.tag) {
100100 .expected_semi_after_decl,
101101 .expected_semi_after_stmt,
......@@ -141,12 +141,12 @@ fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {
141141}
142142
143143fn fail(p: *Parse, tag: Ast.Error.Tag) error{ ParseError, OutOfMemory } {
144 @setCold(true);
144 @branchHint(.cold);
145145 return p.failMsg(.{ .tag = tag, .token = p.tok_i });
146146}
147147
148148fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMemory } {
149 @setCold(true);
149 @branchHint(.cold);
150150 return p.failMsg(.{
151151 .tag = .expected_token,
152152 .token = p.tok_i,
......@@ -155,7 +155,7 @@ fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMe
155155}
156156
157157fn failMsg(p: *Parse, msg: Ast.Error) error{ ParseError, OutOfMemory } {
158 @setCold(true);
158 @branchHint(.cold);
159159 try p.warnMsg(msg);
160160 return error.ParseError;
161161}
lib/std/zig/Zir.zig+9-26
......@@ -431,14 +431,9 @@ pub const Inst = struct {
431431 error_union_type,
432432 /// `error.Foo` syntax. Uses the `str_tok` field of the Data union.
433433 error_value,
434 /// Implements the `@export` builtin function, based on either an identifier to a Decl,
435 /// or field access of a Decl. The thing being exported is the Decl.
434 /// Implements the `@export` builtin function.
436435 /// Uses the `pl_node` union field. Payload is `Export`.
437436 @"export",
438 /// Implements the `@export` builtin function, based on a comptime-known value.
439 /// The thing being exported is the comptime-known value which is the operand.
440 /// Uses the `pl_node` union field. Payload is `ExportValue`.
441 export_value,
442437 /// Given a pointer to a struct or object that contains virtual fields, returns a pointer
443438 /// to the named field. The field name is stored in string_bytes. Used by a.b syntax.
444439 /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field.
......@@ -1093,7 +1088,6 @@ pub const Inst = struct {
10931088 .ensure_result_non_error,
10941089 .ensure_err_union_payload_void,
10951090 .@"export",
1096 .export_value,
10971091 .field_ptr,
10981092 .field_val,
10991093 .field_ptr_named,
......@@ -1314,7 +1308,6 @@ pub const Inst = struct {
13141308 .validate_deref,
13151309 .validate_destructure,
13161310 .@"export",
1317 .export_value,
13181311 .set_runtime_safety,
13191312 .memcpy,
13201313 .memset,
......@@ -1553,7 +1546,7 @@ pub const Inst = struct {
15531546 => false,
15541547
15551548 .extended => switch (data.extended.opcode) {
1556 .fence, .set_cold, .breakpoint, .disable_instrumentation => true,
1549 .fence, .branch_hint, .breakpoint, .disable_instrumentation => true,
15571550 else => false,
15581551 },
15591552 };
......@@ -1637,7 +1630,6 @@ pub const Inst = struct {
16371630 .error_union_type = .pl_node,
16381631 .error_value = .str_tok,
16391632 .@"export" = .pl_node,
1640 .export_value = .pl_node,
16411633 .field_ptr = .pl_node,
16421634 .field_val = .pl_node,
16431635 .field_ptr_named = .pl_node,
......@@ -1962,9 +1954,6 @@ pub const Inst = struct {
19621954 /// Implement builtin `@setAlignStack`.
19631955 /// `operand` is payload index to `UnNode`.
19641956 set_align_stack,
1965 /// Implements `@setCold`.
1966 /// `operand` is payload index to `UnNode`.
1967 set_cold,
19681957 /// Implements the `@errorCast` builtin.
19691958 /// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
19701959 error_cast,
......@@ -2059,6 +2048,10 @@ pub const Inst = struct {
20592048 /// `operand` is `src_node: i32`.
20602049 /// `small` is an `Inst.BuiltinValue`.
20612050 builtin_value,
2051 /// Provide a `@branchHint` for the current block.
2052 /// `operand` is payload index to `UnNode`.
2053 /// `small` is unused.
2054 branch_hint,
20622055
20632056 pub const InstData = struct {
20642057 opcode: Extended,
......@@ -3150,6 +3143,7 @@ pub const Inst = struct {
31503143 export_options,
31513144 extern_options,
31523145 type_info,
3146 branch_hint,
31533147 // Values
31543148 calling_convention_c,
31553149 calling_convention_inline,
......@@ -3425,17 +3419,7 @@ pub const Inst = struct {
34253419 };
34263420
34273421 pub const Export = struct {
3428 /// If present, this is referring to a Decl via field access, e.g. `a.b`.
3429 /// If omitted, this is referring to a Decl via identifier, e.g. `a`.
3430 namespace: Ref,
3431 /// Null-terminated string index.
3432 decl_name: NullTerminatedString,
3433 options: Ref,
3434 };
3435
3436 pub const ExportValue = struct {
3437 /// The comptime value to export.
3438 operand: Ref,
3422 exported: Ref,
34393423 options: Ref,
34403424 };
34413425
......@@ -3793,7 +3777,6 @@ fn findDeclsInner(
37933777 .error_union_type,
37943778 .error_value,
37953779 .@"export",
3796 .export_value,
37973780 .field_ptr,
37983781 .field_val,
37993782 .field_ptr_named,
......@@ -3981,7 +3964,6 @@ fn findDeclsInner(
39813964 .fence,
39823965 .set_float_mode,
39833966 .set_align_stack,
3984 .set_cold,
39853967 .error_cast,
39863968 .await_nosuspend,
39873969 .breakpoint,
......@@ -4005,6 +3987,7 @@ fn findDeclsInner(
40053987 .closure_get,
40063988 .field_parent_ptr,
40073989 .builtin_value,
3990 .branch_hint,
40083991 => return,
40093992
40103993 // `@TypeOf` has a body.
src/Air.zig+109-6
......@@ -433,13 +433,18 @@ pub const Inst = struct {
433433 /// In the case of non-error, control flow proceeds to the next instruction
434434 /// after the `try`, with the result of this instruction being the unwrapped
435435 /// payload value, as if `unwrap_errunion_payload` was executed on the operand.
436 /// The error branch is considered to have a branch hint of `.unlikely`.
436437 /// Uses the `pl_op` field. Payload is `Try`.
437438 @"try",
439 /// Same as `try` except the error branch hint is `.cold`.
440 try_cold,
438441 /// Same as `try` except the operand is a pointer to an error union, and the
439442 /// result is a pointer to the payload. Result is as if `unwrap_errunion_payload_ptr`
440443 /// was executed on the operand.
441444 /// Uses the `ty_pl` field. Payload is `TryPtr`.
442445 try_ptr,
446 /// Same as `try_ptr` except the error branch hint is `.cold`.
447 try_ptr_cold,
443448 /// Notes the beginning of a source code statement and marks the line and column.
444449 /// Result type is always void.
445450 /// Uses the `dbg_stmt` field.
......@@ -1116,11 +1121,20 @@ pub const Call = struct {
11161121pub const CondBr = struct {
11171122 then_body_len: u32,
11181123 else_body_len: u32,
1124 branch_hints: BranchHints,
1125 pub const BranchHints = packed struct(u32) {
1126 true: std.builtin.BranchHint,
1127 false: std.builtin.BranchHint,
1128 _: u26 = 0,
1129 };
11191130};
11201131
11211132/// Trailing:
1122/// * 0. `Case` for each `cases_len`
1123/// * 1. the else body, according to `else_body_len`.
1133/// * 0. `BranchHint` for each `cases_len + 1`. bit-packed into `u32`
1134/// elems such that each `u32` contains up to 10x `BranchHint`.
1135/// LSBs are first case. Final hint is `else`.
1136/// * 1. `Case` for each `cases_len`
1137/// * 2. the else body, according to `else_body_len`.
11241138pub const SwitchBr = struct {
11251139 cases_len: u32,
11261140 else_body_len: u32,
......@@ -1380,6 +1394,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
13801394 .ptr_add,
13811395 .ptr_sub,
13821396 .try_ptr,
1397 .try_ptr_cold,
13831398 => return datas[@intFromEnum(inst)].ty_pl.ty.toType(),
13841399
13851400 .not,
......@@ -1500,7 +1515,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
15001515 return air.typeOf(extra.lhs, ip);
15011516 },
15021517
1503 .@"try" => {
1518 .@"try", .try_cold => {
15041519 const err_union_ty = air.typeOf(datas[@intFromEnum(inst)].pl_op.operand, ip);
15051520 return Type.fromInterned(ip.indexToKey(err_union_ty.ip_index).error_union_type.payload_type);
15061521 },
......@@ -1524,9 +1539,8 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
15241539 inline for (fields) |field| {
15251540 @field(result, field.name) = switch (field.type) {
15261541 u32 => air.extra[i],
1527 Inst.Ref => @as(Inst.Ref, @enumFromInt(air.extra[i])),
1528 i32 => @as(i32, @bitCast(air.extra[i])),
1529 InternPool.Index => @as(InternPool.Index, @enumFromInt(air.extra[i])),
1542 InternPool.Index, Inst.Ref => @enumFromInt(air.extra[i]),
1543 i32, CondBr.BranchHints => @bitCast(air.extra[i]),
15301544 else => @compileError("bad field type: " ++ @typeName(field.type)),
15311545 };
15321546 i += 1;
......@@ -1593,7 +1607,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
15931607 .cond_br,
15941608 .switch_br,
15951609 .@"try",
1610 .try_cold,
15961611 .try_ptr,
1612 .try_ptr_cold,
15971613 .dbg_stmt,
15981614 .dbg_inline_block,
15991615 .dbg_var_ptr,
......@@ -1796,4 +1812,91 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
17961812 };
17971813}
17981814
1815pub const UnwrappedSwitch = struct {
1816 air: *const Air,
1817 operand: Inst.Ref,
1818 cases_len: u32,
1819 else_body_len: u32,
1820 branch_hints_start: u32,
1821 cases_start: u32,
1822
1823 /// Asserts that `case_idx < us.cases_len`.
1824 pub fn getHint(us: UnwrappedSwitch, case_idx: u32) std.builtin.BranchHint {
1825 assert(case_idx < us.cases_len);
1826 return us.getHintInner(case_idx);
1827 }
1828 pub fn getElseHint(us: UnwrappedSwitch) std.builtin.BranchHint {
1829 return us.getHintInner(us.cases_len);
1830 }
1831 fn getHintInner(us: UnwrappedSwitch, idx: u32) std.builtin.BranchHint {
1832 const bag = us.air.extra[us.branch_hints_start..][idx / 10];
1833 const bits: u3 = @truncate(bag >> @intCast(3 * (idx % 10)));
1834 return @enumFromInt(bits);
1835 }
1836
1837 pub fn iterateCases(us: UnwrappedSwitch) CaseIterator {
1838 return .{
1839 .air = us.air,
1840 .cases_len = us.cases_len,
1841 .else_body_len = us.else_body_len,
1842 .next_case = 0,
1843 .extra_index = us.cases_start,
1844 };
1845 }
1846 pub const CaseIterator = struct {
1847 air: *const Air,
1848 cases_len: u32,
1849 else_body_len: u32,
1850 next_case: u32,
1851 extra_index: u32,
1852
1853 pub fn next(it: *CaseIterator) ?Case {
1854 if (it.next_case == it.cases_len) return null;
1855 const idx = it.next_case;
1856 it.next_case += 1;
1857
1858 const extra = it.air.extraData(SwitchBr.Case, it.extra_index);
1859 var extra_index = extra.end;
1860 const items: []const Inst.Ref = @ptrCast(it.air.extra[extra_index..][0..extra.data.items_len]);
1861 extra_index += items.len;
1862 const body: []const Inst.Index = @ptrCast(it.air.extra[extra_index..][0..extra.data.body_len]);
1863 extra_index += body.len;
1864 it.extra_index = @intCast(extra_index);
1865
1866 return .{
1867 .idx = idx,
1868 .items = items,
1869 .body = body,
1870 };
1871 }
1872 /// Only valid to call once all cases have been iterated, i.e. `next` returns `null`.
1873 /// Returns the body of the "default" (`else`) case.
1874 pub fn elseBody(it: *CaseIterator) []const Inst.Index {
1875 assert(it.next_case == it.cases_len);
1876 return @ptrCast(it.air.extra[it.extra_index..][0..it.else_body_len]);
1877 }
1878 pub const Case = struct {
1879 idx: u32,
1880 items: []const Inst.Ref,
1881 body: []const Inst.Index,
1882 };
1883 };
1884};
1885
1886pub fn unwrapSwitch(air: *const Air, switch_inst: Inst.Index) UnwrappedSwitch {
1887 const inst = air.instructions.get(@intFromEnum(switch_inst));
1888 assert(inst.tag == .switch_br);
1889 const pl_op = inst.data.pl_op;
1890 const extra = air.extraData(SwitchBr, pl_op.payload);
1891 const hint_bag_count = std.math.divCeil(usize, extra.data.cases_len + 1, 10) catch unreachable;
1892 return .{
1893 .air = air,
1894 .operand = pl_op.operand,
1895 .cases_len = extra.data.cases_len,
1896 .else_body_len = extra.data.else_body_len,
1897 .branch_hints_start = @intCast(extra.end),
1898 .cases_start = @intCast(extra.end + hint_bag_count),
1899 };
1900}
1901
17991902pub const typesFullyResolved = @import("Air/types_resolved.zig").typesFullyResolved;
src/Air/types_resolved.zig+9-22
......@@ -344,7 +344,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
344344 if (!checkRef(data.pl_op.operand, zcu)) return false;
345345 },
346346
347 .@"try" => {
347 .@"try", .try_cold => {
348348 const extra = air.extraData(Air.Try, data.pl_op.payload);
349349 if (!checkRef(data.pl_op.operand, zcu)) return false;
350350 if (!checkBody(
......@@ -354,7 +354,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
354354 )) return false;
355355 },
356356
357 .try_ptr => {
357 .try_ptr, .try_ptr_cold => {
358358 const extra = air.extraData(Air.TryPtr, data.ty_pl.payload);
359359 if (!checkType(data.ty_pl.ty.toType(), zcu)) return false;
360360 if (!checkRef(extra.data.ptr, zcu)) return false;
......@@ -381,27 +381,14 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
381381 },
382382
383383 .switch_br => {
384 const extra = air.extraData(Air.SwitchBr, data.pl_op.payload);
385 if (!checkRef(data.pl_op.operand, zcu)) return false;
386 var extra_index = extra.end;
387 for (0..extra.data.cases_len) |_| {
388 const case = air.extraData(Air.SwitchBr.Case, extra_index);
389 extra_index = case.end;
390 const items: []const Air.Inst.Ref = @ptrCast(air.extra[extra_index..][0..case.data.items_len]);
391 extra_index += case.data.items_len;
392 for (items) |item| if (!checkRef(item, zcu)) return false;
393 if (!checkBody(
394 air,
395 @ptrCast(air.extra[extra_index..][0..case.data.body_len]),
396 zcu,
397 )) return false;
398 extra_index += case.data.body_len;
384 const switch_br = air.unwrapSwitch(inst);
385 if (!checkRef(switch_br.operand, zcu)) return false;
386 var it = switch_br.iterateCases();
387 while (it.next()) |case| {
388 for (case.items) |item| if (!checkRef(item, zcu)) return false;
389 if (!checkBody(air, case.body, zcu)) return false;
399390 }
400 if (!checkBody(
401 air,
402 @ptrCast(air.extra[extra_index..][0..extra.data.else_body_len]),
403 zcu,
404 )) return false;
391 if (!checkBody(air, it.elseBody(), zcu)) return false;
405392 },
406393
407394 .assembly => {
src/Compilation.zig+4-4
......@@ -5785,7 +5785,7 @@ fn failCObj(
57855785 comptime format: []const u8,
57865786 args: anytype,
57875787) SemaError {
5788 @setCold(true);
5788 @branchHint(.cold);
57895789 const diag_bundle = blk: {
57905790 const diag_bundle = try comp.gpa.create(CObject.Diag.Bundle);
57915791 diag_bundle.* = .{};
......@@ -5809,7 +5809,7 @@ fn failCObjWithOwnedDiagBundle(
58095809 c_object: *CObject,
58105810 diag_bundle: *CObject.Diag.Bundle,
58115811) SemaError {
5812 @setCold(true);
5812 @branchHint(.cold);
58135813 assert(diag_bundle.diags.len > 0);
58145814 {
58155815 comp.mutex.lock();
......@@ -5825,7 +5825,7 @@ fn failCObjWithOwnedDiagBundle(
58255825}
58265826
58275827fn failWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, comptime format: []const u8, args: anytype) SemaError {
5828 @setCold(true);
5828 @branchHint(.cold);
58295829 var bundle: ErrorBundle.Wip = undefined;
58305830 try bundle.init(comp.gpa);
58315831 errdefer bundle.deinit();
......@@ -5852,7 +5852,7 @@ fn failWin32ResourceWithOwnedBundle(
58525852 win32_resource: *Win32Resource,
58535853 err_bundle: ErrorBundle,
58545854) SemaError {
5855 @setCold(true);
5855 @branchHint(.cold);
58565856 {
58575857 comp.mutex.lock();
58585858 defer comp.mutex.unlock();
src/InternPool.zig+17-18
......@@ -2121,6 +2121,17 @@ pub const Key = union(enum) {
21212121 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
21222122 }
21232123
2124 pub fn setBranchHint(func: Func, ip: *InternPool, hint: std.builtin.BranchHint) void {
2125 const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex;
2126 extra_mutex.lock();
2127 defer extra_mutex.unlock();
2128
2129 const analysis_ptr = func.analysisPtr(ip);
2130 var analysis = analysis_ptr.*;
2131 analysis.branch_hint = hint;
2132 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
2133 }
2134
21242135 /// Returns a pointer that becomes invalid after any additions to the `InternPool`.
21252136 fn zirBodyInstPtr(func: Func, ip: *InternPool) *TrackedInst.Index {
21262137 const extra = ip.getLocalShared(func.tid).extra.acquire();
......@@ -5575,7 +5586,7 @@ pub const Tag = enum(u8) {
55755586/// to be part of the type of the function.
55765587pub const FuncAnalysis = packed struct(u32) {
55775588 state: State,
5578 is_cold: bool,
5589 branch_hint: std.builtin.BranchHint,
55795590 is_noinline: bool,
55805591 calls_or_awaits_errorable_fn: bool,
55815592 stack_alignment: Alignment,
......@@ -5583,7 +5594,7 @@ pub const FuncAnalysis = packed struct(u32) {
55835594 inferred_error_set: bool,
55845595 disable_instrumentation: bool,
55855596
5586 _: u19 = 0,
5597 _: u17 = 0,
55875598
55885599 pub const State = enum(u2) {
55895600 /// The runtime function has never been referenced.
......@@ -8636,7 +8647,7 @@ pub fn getFuncDecl(
86368647 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{
86378648 .analysis = .{
86388649 .state = .unreferenced,
8639 .is_cold = false,
8650 .branch_hint = .none,
86408651 .is_noinline = key.is_noinline,
86418652 .calls_or_awaits_errorable_fn = false,
86428653 .stack_alignment = .none,
......@@ -8740,7 +8751,7 @@ pub fn getFuncDeclIes(
87408751 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{
87418752 .analysis = .{
87428753 .state = .unreferenced,
8743 .is_cold = false,
8754 .branch_hint = .none,
87448755 .is_noinline = key.is_noinline,
87458756 .calls_or_awaits_errorable_fn = false,
87468757 .stack_alignment = .none,
......@@ -8932,7 +8943,7 @@ pub fn getFuncInstance(
89328943 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{
89338944 .analysis = .{
89348945 .state = .unreferenced,
8935 .is_cold = false,
8946 .branch_hint = .none,
89368947 .is_noinline = arg.is_noinline,
89378948 .calls_or_awaits_errorable_fn = false,
89388949 .stack_alignment = .none,
......@@ -9032,7 +9043,7 @@ pub fn getFuncInstanceIes(
90329043 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{
90339044 .analysis = .{
90349045 .state = .unreferenced,
9035 .is_cold = false,
9046 .branch_hint = .none,
90369047 .is_noinline = arg.is_noinline,
90379048 .calls_or_awaits_errorable_fn = false,
90389049 .stack_alignment = .none,
......@@ -11853,18 +11864,6 @@ pub fn funcSetDisableInstrumentation(ip: *InternPool, func: Index) void {
1185311864 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
1185411865}
1185511866
11856pub fn funcSetCold(ip: *InternPool, func: Index, is_cold: bool) void {
11857 const unwrapped_func = func.unwrap(ip);
11858 const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex;
11859 extra_mutex.lock();
11860 defer extra_mutex.unlock();
11861
11862 const analysis_ptr = ip.funcAnalysisPtr(func);
11863 var analysis = analysis_ptr.*;
11864 analysis.is_cold = is_cold;
11865 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
11866}
11867
1186811867pub fn funcZirBodyInst(ip: *const InternPool, func: Index) TrackedInst.Index {
1186911868 const unwrapped_func = func.unwrap(ip);
1187011869 const item = unwrapped_func.getItem(ip);
src/Liveness.zig+15-21
......@@ -658,10 +658,10 @@ pub fn categorizeOperand(
658658
659659 return .complex;
660660 },
661 .@"try" => {
661 .@"try", .try_cold => {
662662 return .complex;
663663 },
664 .try_ptr => {
664 .try_ptr, .try_ptr_cold => {
665665 return .complex;
666666 },
667667 .loop => {
......@@ -1254,8 +1254,8 @@ fn analyzeInst(
12541254 },
12551255 .loop => return analyzeInstLoop(a, pass, data, inst),
12561256
1257 .@"try" => return analyzeInstCondBr(a, pass, data, inst, .@"try"),
1258 .try_ptr => return analyzeInstCondBr(a, pass, data, inst, .try_ptr),
1257 .@"try", .try_cold => return analyzeInstCondBr(a, pass, data, inst, .@"try"),
1258 .try_ptr, .try_ptr_cold => return analyzeInstCondBr(a, pass, data, inst, .try_ptr),
12591259 .cond_br => return analyzeInstCondBr(a, pass, data, inst, .cond_br),
12601260 .switch_br => return analyzeInstSwitchBr(a, pass, data, inst),
12611261
......@@ -1674,21 +1674,18 @@ fn analyzeInstSwitchBr(
16741674 const inst_datas = a.air.instructions.items(.data);
16751675 const pl_op = inst_datas[@intFromEnum(inst)].pl_op;
16761676 const condition = pl_op.operand;
1677 const switch_br = a.air.extraData(Air.SwitchBr, pl_op.payload);
1677 const switch_br = a.air.unwrapSwitch(inst);
16781678 const gpa = a.gpa;
1679 const ncases = switch_br.data.cases_len;
1679 const ncases = switch_br.cases_len;
16801680
16811681 switch (pass) {
16821682 .loop_analysis => {
1683 var air_extra_index: usize = switch_br.end;
1684 for (0..ncases) |_| {
1685 const case = a.air.extraData(Air.SwitchBr.Case, air_extra_index);
1686 const case_body: []const Air.Inst.Index = @ptrCast(a.air.extra[case.end + case.data.items_len ..][0..case.data.body_len]);
1687 air_extra_index = case.end + case.data.items_len + case_body.len;
1688 try analyzeBody(a, pass, data, case_body);
1683 var it = switch_br.iterateCases();
1684 while (it.next()) |case| {
1685 try analyzeBody(a, pass, data, case.body);
16891686 }
16901687 { // else
1691 const else_body: []const Air.Inst.Index = @ptrCast(a.air.extra[air_extra_index..][0..switch_br.data.else_body_len]);
1688 const else_body = it.elseBody();
16921689 try analyzeBody(a, pass, data, else_body);
16931690 }
16941691 },
......@@ -1706,16 +1703,13 @@ fn analyzeInstSwitchBr(
17061703 @memset(case_live_sets, .{});
17071704 defer for (case_live_sets) |*live_set| live_set.deinit(gpa);
17081705
1709 var air_extra_index: usize = switch_br.end;
1710 for (case_live_sets[0..ncases]) |*live_set| {
1711 const case = a.air.extraData(Air.SwitchBr.Case, air_extra_index);
1712 const case_body: []const Air.Inst.Index = @ptrCast(a.air.extra[case.end + case.data.items_len ..][0..case.data.body_len]);
1713 air_extra_index = case.end + case.data.items_len + case_body.len;
1714 try analyzeBody(a, pass, data, case_body);
1715 live_set.* = data.live_set.move();
1706 var case_it = switch_br.iterateCases();
1707 while (case_it.next()) |case| {
1708 try analyzeBody(a, pass, data, case.body);
1709 case_live_sets[case.idx] = data.live_set.move();
17161710 }
17171711 { // else
1718 const else_body: []const Air.Inst.Index = @ptrCast(a.air.extra[air_extra_index..][0..switch_br.data.else_body_len]);
1712 const else_body = case_it.elseBody();
17191713 try analyzeBody(a, pass, data, else_body);
17201714 case_live_sets[ncases] = data.live_set.move();
17211715 }
src/Liveness/Verify.zig+11-22
......@@ -374,7 +374,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
374374 },
375375
376376 // control flow
377 .@"try" => {
377 .@"try", .try_cold => {
378378 const pl_op = data[@intFromEnum(inst)].pl_op;
379379 const extra = self.air.extraData(Air.Try, pl_op.payload);
380380 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
......@@ -396,7 +396,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
396396
397397 try self.verifyInst(inst);
398398 },
399 .try_ptr => {
399 .try_ptr, .try_ptr_cold => {
400400 const ty_pl = data[@intFromEnum(inst)].ty_pl;
401401 const extra = self.air.extraData(Air.TryPtr, ty_pl.payload);
402402 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
......@@ -509,44 +509,33 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
509509 try self.verifyInst(inst);
510510 },
511511 .switch_br => {
512 const pl_op = data[@intFromEnum(inst)].pl_op;
513 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
514 var extra_index = switch_br.end;
515 var case_i: u32 = 0;
512 const switch_br = self.air.unwrapSwitch(inst);
516513 const switch_br_liveness = try self.liveness.getSwitchBr(
517514 self.gpa,
518515 inst,
519 switch_br.data.cases_len + 1,
516 switch_br.cases_len + 1,
520517 );
521518 defer self.gpa.free(switch_br_liveness.deaths);
522519
523 try self.verifyOperand(inst, pl_op.operand, self.liveness.operandDies(inst, 0));
520 try self.verifyOperand(inst, switch_br.operand, self.liveness.operandDies(inst, 0));
524521
525522 var live = self.live.move();
526523 defer live.deinit(self.gpa);
527524
528 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
529 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
530 const items = @as(
531 []const Air.Inst.Ref,
532 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]),
533 );
534 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
535 extra_index = case.end + items.len + case_body.len;
536
525 var it = switch_br.iterateCases();
526 while (it.next()) |case| {
537527 self.live.deinit(self.gpa);
538528 self.live = try live.clone(self.gpa);
539529
540 for (switch_br_liveness.deaths[case_i]) |death| try self.verifyDeath(inst, death);
541 try self.verifyBody(case_body);
530 for (switch_br_liveness.deaths[case.idx]) |death| try self.verifyDeath(inst, death);
531 try self.verifyBody(case.body);
542532 }
543533
544 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
534 const else_body = it.elseBody();
545535 if (else_body.len > 0) {
546536 self.live.deinit(self.gpa);
547537 self.live = try live.clone(self.gpa);
548
549 for (switch_br_liveness.deaths[case_i]) |death| try self.verifyDeath(inst, death);
538 for (switch_br_liveness.deaths[switch_br.cases_len]) |death| try self.verifyDeath(inst, death);
550539 try self.verifyBody(else_body);
551540 }
552541
src/Sema.zig+319-174
......@@ -118,6 +118,10 @@ dependencies: std.AutoArrayHashMapUnmanaged(InternPool.Dependee, void) = .{},
118118/// by `analyzeCall`.
119119allow_memoize: bool = true,
120120
121/// The `BranchHint` for the current branch of runtime control flow.
122/// This state is on `Sema` so that `cold` hints can be propagated up through blocks with less special handling.
123branch_hint: ?std.builtin.BranchHint = null,
124
121125const MaybeComptimeAlloc = struct {
122126 /// The runtime index of the `alloc` instruction.
123127 runtime_index: Value.RuntimeIndex,
......@@ -892,7 +896,12 @@ pub fn deinit(sema: *Sema) void {
892896/// Performs semantic analysis of a ZIR body which is behind a runtime condition. If comptime
893897/// control flow happens here, Sema will convert it to runtime control flow by introducing post-hoc
894898/// blocks where necessary.
895fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) !void {
899/// Returns the branch hint for this branch.
900fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) !std.builtin.BranchHint {
901 const parent_hint = sema.branch_hint;
902 defer sema.branch_hint = parent_hint;
903 sema.branch_hint = null;
904
896905 sema.analyzeBodyInner(block, body) catch |err| switch (err) {
897906 error.ComptimeBreak => {
898907 const zir_datas = sema.code.instructions.items(.data);
......@@ -902,6 +911,8 @@ fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.In
902911 },
903912 else => |e| return e,
904913 };
914
915 return sema.branch_hint orelse .none;
905916}
906917
907918/// Semantically analyze a ZIR function body. It is guranteed by AstGen that such a body cannot
......@@ -1304,11 +1315,6 @@ fn analyzeBodyInner(
13041315 i += 1;
13051316 continue;
13061317 },
1307 .set_cold => {
1308 try sema.zirSetCold(block, extended);
1309 i += 1;
1310 continue;
1311 },
13121318 .breakpoint => {
13131319 if (!block.is_comptime) {
13141320 _ = try block.addNoOp(.breakpoint);
......@@ -1326,6 +1332,11 @@ fn analyzeBodyInner(
13261332 i += 1;
13271333 continue;
13281334 },
1335 .branch_hint => {
1336 try sema.zirBranchHint(block, extended);
1337 i += 1;
1338 continue;
1339 },
13291340 .value_placeholder => unreachable, // never appears in a body
13301341 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),
13311342 .builtin_value => try sema.zirBuiltinValue(extended),
......@@ -1442,11 +1453,6 @@ fn analyzeBodyInner(
14421453 i += 1;
14431454 continue;
14441455 },
1445 .export_value => {
1446 try sema.zirExportValue(block, inst);
1447 i += 1;
1448 continue;
1449 },
14501456 .set_runtime_safety => {
14511457 try sema.zirSetRuntimeSafety(block, inst);
14521458 i += 1;
......@@ -2465,7 +2471,7 @@ fn addFieldErrNote(
24652471 comptime format: []const u8,
24662472 args: anytype,
24672473) !void {
2468 @setCold(true);
2474 @branchHint(.cold);
24692475 const type_src = container_ty.srcLocOrNull(sema.pt.zcu) orelse return;
24702476 const field_src: LazySrcLoc = .{
24712477 .base_node_inst = type_src.base_node_inst,
......@@ -2501,7 +2507,7 @@ pub fn fail(
25012507}
25022508
25032509pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg) error{ AnalysisFail, OutOfMemory } {
2504 @setCold(true);
2510 @branchHint(.cold);
25052511 const gpa = sema.gpa;
25062512 const zcu = sema.pt.zcu;
25072513
......@@ -5732,6 +5738,13 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
57325738 if (block.is_comptime) {
57335739 return sema.fail(block, src, "encountered @panic at comptime", .{});
57345740 }
5741
5742 // We only apply the first hint in a branch.
5743 // This allows user-provided hints to override implicit cold hints.
5744 if (sema.branch_hint == null) {
5745 sema.branch_hint = .cold;
5746 }
5747
57355748 try sema.panicWithMsg(block, src, coerced_msg, .@"@panic");
57365749}
57375750
......@@ -6279,73 +6292,72 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
62796292 const ip = &zcu.intern_pool;
62806293 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
62816294 const extra = sema.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;
6282 const src = block.nodeOffset(inst_data.src_node);
6283 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
6284 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
6285 const decl_name = try ip.getOrPutString(
6286 zcu.gpa,
6287 pt.tid,
6288 sema.code.nullTerminatedString(extra.decl_name),
6289 .no_embedded_nulls,
6290 );
6291 const nav_index = if (extra.namespace != .none) index_blk: {
6292 const container_ty = try sema.resolveType(block, operand_src, extra.namespace);
6293 const container_namespace = container_ty.getNamespaceIndex(zcu);
6294
6295 const lookup = try sema.lookupInNamespace(block, operand_src, container_namespace, decl_name, false) orelse
6296 return sema.failWithBadMemberAccess(block, container_ty, operand_src, decl_name);
62976295
6298 break :index_blk lookup.nav;
6299 } else try sema.lookupIdentifier(block, operand_src, decl_name);
6300 const options = try sema.resolveExportOptions(block, options_src, extra.options);
6301
6302 try sema.ensureNavResolved(src, nav_index);
6303
6304 // Make sure to export the owner Nav if applicable.
6305 const exported_nav = switch (ip.indexToKey(ip.getNav(nav_index).status.resolved.val)) {
6306 .variable => |v| v.owner_nav,
6307 .@"extern" => |e| e.owner_nav,
6308 .func => |f| f.owner_nav,
6309 else => nav_index,
6310 };
6311 try sema.analyzeExport(block, src, options, exported_nav);
6312}
6313
6314fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
6315 const tracy = trace(@src());
6316 defer tracy.end();
6317
6318 const pt = sema.pt;
6319 const zcu = pt.zcu;
6320 const ip = &zcu.intern_pool;
6321 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6322 const extra = sema.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;
63236296 const src = block.nodeOffset(inst_data.src_node);
6324 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
6297 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
63256298 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
6326 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, .{
6299
6300 const ptr = try sema.resolveInst(extra.exported);
6301 const ptr_val = try sema.resolveConstDefinedValue(block, ptr_src, ptr, .{
63276302 .needed_comptime_reason = "export target must be comptime-known",
63286303 });
6304 const ptr_ty = ptr_val.typeOf(zcu);
6305
63296306 const options = try sema.resolveExportOptions(block, options_src, extra.options);
6330 if (options.linkage == .internal)
6331 return;
63326307
6333 // If the value has an owner Nav, export that instead.
6334 const maybe_owner_nav = switch (ip.indexToKey(operand.toIntern())) {
6335 .variable => |v| v.owner_nav,
6336 .@"extern" => |e| e.owner_nav,
6337 .func => |f| f.owner_nav,
6338 else => null,
6339 };
6340 if (maybe_owner_nav) |owner_nav| {
6341 return sema.analyzeExport(block, src, options, owner_nav);
6342 } else {
6343 try sema.exports.append(zcu.gpa, .{
6344 .opts = options,
6345 .src = src,
6346 .exported = .{ .uav = operand.toIntern() },
6347 .status = .in_progress,
6348 });
6308 {
6309 if (ptr_ty.zigTypeTag(zcu) != .Pointer) {
6310 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
6311 }
6312 const ptr_ty_info = ptr_ty.ptrInfo(zcu);
6313 if (ptr_ty_info.flags.size == .Slice) {
6314 return sema.fail(block, ptr_src, "export target cannot be slice", .{});
6315 }
6316 if (ptr_ty_info.packed_offset.host_size != 0) {
6317 return sema.fail(block, ptr_src, "export target cannot be bit-pointer", .{});
6318 }
6319 }
6320
6321 const ptr_info = ip.indexToKey(ptr_val.toIntern()).ptr;
6322 switch (ptr_info.base_addr) {
6323 .comptime_alloc, .int, .comptime_field => return sema.fail(block, ptr_src, "export target must be a global variable or a comptime-known constant", .{}),
6324 .eu_payload, .opt_payload, .field, .arr_elem => return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{}),
6325 .uav => |uav| {
6326 if (ptr_info.byte_offset != 0) {
6327 return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{});
6328 }
6329 if (options.linkage == .internal) return;
6330 const export_ty = Value.fromInterned(uav.val).typeOf(zcu);
6331 if (!try sema.validateExternType(export_ty, .other)) {
6332 return sema.failWithOwnedErrorMsg(block, msg: {
6333 const msg = try sema.errMsg(src, "unable to export type '{}'", .{export_ty.fmt(pt)});
6334 errdefer msg.destroy(sema.gpa);
6335 try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other);
6336 try sema.addDeclaredHereNote(msg, export_ty);
6337 break :msg msg;
6338 });
6339 }
6340 try sema.exports.append(zcu.gpa, .{
6341 .opts = options,
6342 .src = src,
6343 .exported = .{ .uav = uav.val },
6344 .status = .in_progress,
6345 });
6346 },
6347 .nav => |nav| {
6348 if (ptr_info.byte_offset != 0) {
6349 return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{});
6350 }
6351 try sema.ensureNavResolved(src, nav);
6352 // Make sure to export the owner Nav if applicable.
6353 const exported_nav = switch (ip.indexToKey(ip.getNav(nav).status.resolved.val)) {
6354 .variable => |v| v.owner_nav,
6355 .@"extern" => |e| e.owner_nav,
6356 .func => |f| f.owner_nav,
6357 else => nav,
6358 };
6359 try sema.analyzeExport(block, src, options, exported_nav);
6360 },
63496361 }
63506362}
63516363
......@@ -6424,25 +6436,6 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
64246436 sema.allow_memoize = false;
64256437}
64266438
6427fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
6428 const pt = sema.pt;
6429 const zcu = pt.zcu;
6430 const ip = &zcu.intern_pool;
6431 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6432 const operand_src = block.builtinCallArgSrc(extra.node, 0);
6433 const is_cold = try sema.resolveConstBool(block, operand_src, extra.operand, .{
6434 .needed_comptime_reason = "operand to @setCold must be comptime-known",
6435 });
6436 // TODO: should `@setCold` apply to the parent in an inline call?
6437 // See also #20642 and friends.
6438 const func = switch (sema.owner.unwrap()) {
6439 .func => |func| func,
6440 .cau => return, // does nothing outside a function
6441 };
6442 ip.funcSetCold(func, is_cold);
6443 sema.allow_memoize = false;
6444}
6445
64466439fn zirDisableInstrumentation(sema: *Sema) CompileError!void {
64476440 const pt = sema.pt;
64486441 const zcu = pt.zcu;
......@@ -6897,13 +6890,20 @@ fn popErrorReturnTrace(
68976890 @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block
68986891
68996892 const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);
6900 try sema.air_instructions.append(gpa, .{ .tag = .cond_br, .data = .{ .pl_op = .{
6901 .operand = is_non_error_inst,
6902 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
6903 .then_body_len = @intCast(then_block.instructions.items.len),
6904 .else_body_len = @intCast(else_block.instructions.items.len),
6905 }),
6906 } } });
6893 try sema.air_instructions.append(gpa, .{
6894 .tag = .cond_br,
6895 .data = .{
6896 .pl_op = .{
6897 .operand = is_non_error_inst,
6898 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
6899 .then_body_len = @intCast(then_block.instructions.items.len),
6900 .else_body_len = @intCast(else_block.instructions.items.len),
6901 // weight against error branch
6902 .branch_hints = .{ .true = .likely, .false = .unlikely },
6903 }),
6904 },
6905 },
6906 });
69076907 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
69086908 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
69096909
......@@ -10960,6 +10960,11 @@ const SwitchProngAnalysis = struct {
1096010960 sema.code.instructions.items(.data)[@intFromEnum(spa.switch_block_inst)].pl_node.src_node,
1096110961 );
1096210962
10963 // We can propagate `.cold` hints from this branch since it's comptime-known
10964 // to be taken from the parent branch.
10965 const parent_hint = sema.branch_hint;
10966 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
10967
1096310968 if (has_tag_capture) {
1096410969 const tag_ref = try spa.analyzeTagCapture(child_block, capture_src, inline_case_capture);
1096510970 sema.inst_map.putAssumeCapacity(spa.tag_capture_inst, tag_ref);
......@@ -10996,6 +11001,7 @@ const SwitchProngAnalysis = struct {
1099611001
1099711002 /// Analyze a switch prong which may have peers at runtime.
1099811003 /// Uses `analyzeBodyRuntimeBreak`. Sets up captures as needed.
11004 /// Returns the `BranchHint` for the prong.
1099911005 fn analyzeProngRuntime(
1100011006 spa: SwitchProngAnalysis,
1100111007 case_block: *Block,
......@@ -11013,7 +11019,7 @@ const SwitchProngAnalysis = struct {
1101311019 /// Whether this prong has an inline tag capture. If `true`, then
1101411020 /// `inline_case_capture` cannot be `.none`.
1101511021 has_tag_capture: bool,
11016 ) CompileError!void {
11022 ) CompileError!std.builtin.BranchHint {
1101711023 const sema = spa.sema;
1101811024
1101911025 if (has_tag_capture) {
......@@ -11039,7 +11045,7 @@ const SwitchProngAnalysis = struct {
1103911045
1104011046 if (sema.typeOf(capture_ref).isNoReturn(sema.pt.zcu)) {
1104111047 // No need to analyze any further, the prong is unreachable
11042 return;
11048 return .none;
1104311049 }
1104411050
1104511051 sema.inst_map.putAssumeCapacity(spa.switch_block_inst, capture_ref);
......@@ -11308,10 +11314,17 @@ const SwitchProngAnalysis = struct {
1130811314
1130911315 const prong_count = field_indices.len - in_mem_coercible.count();
1131011316
11311 const estimated_extra = prong_count * 6; // 2 for Case, 1 item, probably 3 insts
11317 const estimated_extra = prong_count * 6 + (prong_count / 10); // 2 for Case, 1 item, probably 3 insts; plus hints
1131211318 var cases_extra = try std.ArrayList(u32).initCapacity(sema.gpa, estimated_extra);
1131311319 defer cases_extra.deinit();
1131411320
11321 {
11322 // All branch hints are `.none`, so just add zero elems.
11323 comptime assert(@intFromEnum(std.builtin.BranchHint.none) == 0);
11324 const need_elems = std.math.divCeil(usize, prong_count + 1, 10) catch unreachable;
11325 try cases_extra.appendNTimes(0, need_elems);
11326 }
11327
1131511328 {
1131611329 // Non-bitcast cases
1131711330 var it = in_mem_coercible.iterator(.{ .kind = .unset });
......@@ -11734,7 +11747,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
1173411747 sub_block.need_debug_scope = null; // this body is emitted regardless
1173511748 defer sub_block.instructions.deinit(gpa);
1173611749
11737 try sema.analyzeBodyRuntimeBreak(&sub_block, non_error_case.body);
11750 const non_error_hint = try sema.analyzeBodyRuntimeBreak(&sub_block, non_error_case.body);
1173811751 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);
1173911752 defer gpa.free(true_instructions);
1174011753
......@@ -11788,6 +11801,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
1178811801 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
1178911802 .then_body_len = @intCast(true_instructions.len),
1179011803 .else_body_len = @intCast(sub_block.instructions.items.len),
11804 .branch_hints = .{ .true = non_error_hint, .false = .none },
1179111805 }),
1179211806 } },
1179311807 });
......@@ -12492,6 +12506,9 @@ fn analyzeSwitchRuntimeBlock(
1249212506 var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra);
1249312507 defer cases_extra.deinit(gpa);
1249412508
12509 var branch_hints = try std.ArrayListUnmanaged(std.builtin.BranchHint).initCapacity(gpa, scalar_cases_len);
12510 defer branch_hints.deinit(gpa);
12511
1249512512 var case_block = child_block.makeSubBlock();
1249612513 case_block.runtime_loop = null;
1249712514 case_block.runtime_cond = operand_src;
......@@ -12522,10 +12539,13 @@ fn analyzeSwitchRuntimeBlock(
1252212539 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;
1252312540 } else true;
1252412541
12525 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {
12526 // nothing to do here
12527 } else if (analyze_body) {
12528 try spa.analyzeProngRuntime(
12542 const prong_hint: std.builtin.BranchHint = if (err_set and
12543 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12544 h: {
12545 // nothing to do here. weight against error branch
12546 break :h .unlikely;
12547 } else if (analyze_body) h: {
12548 break :h try spa.analyzeProngRuntime(
1252912549 &case_block,
1253012550 .normal,
1253112551 body,
......@@ -12538,10 +12558,12 @@ fn analyzeSwitchRuntimeBlock(
1253812558 if (info.is_inline) item else .none,
1253912559 info.has_tag_capture,
1254012560 );
12541 } else {
12561 } else h: {
1254212562 _ = try case_block.addNoOp(.unreach);
12543 }
12563 break :h .none;
12564 };
1254412565
12566 try branch_hints.append(gpa, prong_hint);
1254512567 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1254612568 cases_extra.appendAssumeCapacity(1); // items_len
1254712569 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
......@@ -12551,6 +12573,7 @@ fn analyzeSwitchRuntimeBlock(
1255112573
1255212574 var is_first = true;
1255312575 var prev_cond_br: Air.Inst.Index = undefined;
12576 var prev_hint: std.builtin.BranchHint = undefined;
1255412577 var first_else_body: []const Air.Inst.Index = &.{};
1255512578 defer gpa.free(first_else_body);
1255612579 var prev_then_body: []const Air.Inst.Index = &.{};
......@@ -12612,7 +12635,7 @@ fn analyzeSwitchRuntimeBlock(
1261212635 } }));
1261312636 emit_bb = true;
1261412637
12615 try spa.analyzeProngRuntime(
12638 const prong_hint = try spa.analyzeProngRuntime(
1261612639 &case_block,
1261712640 .normal,
1261812641 body,
......@@ -12625,6 +12648,7 @@ fn analyzeSwitchRuntimeBlock(
1262512648 item_ref,
1262612649 info.has_tag_capture,
1262712650 );
12651 try branch_hints.append(gpa, prong_hint);
1262812652
1262912653 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1263012654 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -12655,8 +12679,8 @@ fn analyzeSwitchRuntimeBlock(
1265512679 } }));
1265612680 emit_bb = true;
1265712681
12658 if (analyze_body) {
12659 try spa.analyzeProngRuntime(
12682 const prong_hint: std.builtin.BranchHint = if (analyze_body) h: {
12683 break :h try spa.analyzeProngRuntime(
1266012684 &case_block,
1266112685 .normal,
1266212686 body,
......@@ -12669,9 +12693,11 @@ fn analyzeSwitchRuntimeBlock(
1266912693 item,
1267012694 info.has_tag_capture,
1267112695 );
12672 } else {
12696 } else h: {
1267312697 _ = try case_block.addNoOp(.unreach);
12674 }
12698 break :h .none;
12699 };
12700 try branch_hints.append(gpa, prong_hint);
1267512701
1267612702 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1267712703 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -12703,10 +12729,13 @@ fn analyzeSwitchRuntimeBlock(
1270312729
1270412730 const body = sema.code.bodySlice(extra_index, info.body_len);
1270512731 extra_index += info.body_len;
12706 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {
12707 // nothing to do here
12708 } else if (analyze_body) {
12709 try spa.analyzeProngRuntime(
12732 const prong_hint: std.builtin.BranchHint = if (err_set and
12733 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12734 h: {
12735 // nothing to do here. weight against error branch
12736 break :h .unlikely;
12737 } else if (analyze_body) h: {
12738 break :h try spa.analyzeProngRuntime(
1271012739 &case_block,
1271112740 .normal,
1271212741 body,
......@@ -12719,10 +12748,12 @@ fn analyzeSwitchRuntimeBlock(
1271912748 .none,
1272012749 false,
1272112750 );
12722 } else {
12751 } else h: {
1272312752 _ = try case_block.addNoOp(.unreach);
12724 }
12753 break :h .none;
12754 };
1272512755
12756 try branch_hints.append(gpa, prong_hint);
1272612757 try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len +
1272712758 case_block.instructions.items.len);
1272812759
......@@ -12790,23 +12821,24 @@ fn analyzeSwitchRuntimeBlock(
1279012821
1279112822 const body = sema.code.bodySlice(extra_index, info.body_len);
1279212823 extra_index += info.body_len;
12793 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {
12794 // nothing to do here
12795 } else {
12796 try spa.analyzeProngRuntime(
12797 &case_block,
12798 .normal,
12799 body,
12800 info.capture,
12801 child_block.src(.{ .switch_capture = .{
12802 .switch_node_offset = switch_node_offset,
12803 .case_idx = .{ .kind = .multi, .index = @intCast(multi_i) },
12804 } }),
12805 items,
12806 .none,
12807 false,
12808 );
12809 }
12824 const prong_hint: std.builtin.BranchHint = if (err_set and
12825 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12826 h: {
12827 // nothing to do here. weight against error branch
12828 break :h .unlikely;
12829 } else try spa.analyzeProngRuntime(
12830 &case_block,
12831 .normal,
12832 body,
12833 info.capture,
12834 child_block.src(.{ .switch_capture = .{
12835 .switch_node_offset = switch_node_offset,
12836 .case_idx = .{ .kind = .multi, .index = @intCast(multi_i) },
12837 } }),
12838 items,
12839 .none,
12840 false,
12841 );
1281012842
1281112843 if (is_first) {
1281212844 is_first = false;
......@@ -12818,10 +12850,10 @@ fn analyzeSwitchRuntimeBlock(
1281812850 @typeInfo(Air.CondBr).Struct.fields.len + prev_then_body.len + cond_body.len,
1281912851 );
1282012852
12821 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload =
12822 sema.addExtraAssumeCapacity(Air.CondBr{
12853 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
1282312854 .then_body_len = @intCast(prev_then_body.len),
1282412855 .else_body_len = @intCast(cond_body.len),
12856 .branch_hints = .{ .true = prev_hint, .false = .none },
1282512857 });
1282612858 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));
1282712859 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cond_body));
......@@ -12829,6 +12861,7 @@ fn analyzeSwitchRuntimeBlock(
1282912861 gpa.free(prev_then_body);
1283012862 prev_then_body = try case_block.instructions.toOwnedSlice(gpa);
1283112863 prev_cond_br = new_cond_br;
12864 prev_hint = prong_hint;
1283212865 }
1283312866 }
1283412867
......@@ -12860,8 +12893,8 @@ fn analyzeSwitchRuntimeBlock(
1286012893 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
1286112894 emit_bb = true;
1286212895
12863 if (analyze_body) {
12864 try spa.analyzeProngRuntime(
12896 const prong_hint: std.builtin.BranchHint = if (analyze_body) h: {
12897 break :h try spa.analyzeProngRuntime(
1286512898 &case_block,
1286612899 .special,
1286712900 special.body,
......@@ -12874,9 +12907,11 @@ fn analyzeSwitchRuntimeBlock(
1287412907 item_ref,
1287512908 special.has_tag_capture,
1287612909 );
12877 } else {
12910 } else h: {
1287812911 _ = try case_block.addNoOp(.unreach);
12879 }
12912 break :h .none;
12913 };
12914 try branch_hints.append(gpa, prong_hint);
1288012915
1288112916 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1288212917 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -12909,7 +12944,7 @@ fn analyzeSwitchRuntimeBlock(
1290912944 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
1291012945 emit_bb = true;
1291112946
12912 try spa.analyzeProngRuntime(
12947 const prong_hint = try spa.analyzeProngRuntime(
1291312948 &case_block,
1291412949 .special,
1291512950 special.body,
......@@ -12922,6 +12957,7 @@ fn analyzeSwitchRuntimeBlock(
1292212957 item_ref,
1292312958 special.has_tag_capture,
1292412959 );
12960 try branch_hints.append(gpa, prong_hint);
1292512961
1292612962 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1292712963 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -12943,7 +12979,7 @@ fn analyzeSwitchRuntimeBlock(
1294312979 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
1294412980 emit_bb = true;
1294512981
12946 try spa.analyzeProngRuntime(
12982 const prong_hint = try spa.analyzeProngRuntime(
1294712983 &case_block,
1294812984 .special,
1294912985 special.body,
......@@ -12956,6 +12992,7 @@ fn analyzeSwitchRuntimeBlock(
1295612992 item_ref,
1295712993 special.has_tag_capture,
1295812994 );
12995 try branch_hints.append(gpa, prong_hint);
1295912996
1296012997 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1296112998 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -12974,7 +13011,7 @@ fn analyzeSwitchRuntimeBlock(
1297413011 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
1297513012 emit_bb = true;
1297613013
12977 try spa.analyzeProngRuntime(
13014 const prong_hint = try spa.analyzeProngRuntime(
1297813015 &case_block,
1297913016 .special,
1298013017 special.body,
......@@ -12987,6 +13024,7 @@ fn analyzeSwitchRuntimeBlock(
1298713024 .bool_true,
1298813025 special.has_tag_capture,
1298913026 );
13027 try branch_hints.append(gpa, prong_hint);
1299013028
1299113029 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1299213030 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -13003,7 +13041,7 @@ fn analyzeSwitchRuntimeBlock(
1300313041 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
1300413042 emit_bb = true;
1300513043
13006 try spa.analyzeProngRuntime(
13044 const prong_hint = try spa.analyzeProngRuntime(
1300713045 &case_block,
1300813046 .special,
1300913047 special.body,
......@@ -13016,6 +13054,7 @@ fn analyzeSwitchRuntimeBlock(
1301613054 .bool_false,
1301713055 special.has_tag_capture,
1301813056 );
13057 try branch_hints.append(gpa, prong_hint);
1301913058
1302013059 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1302113060 cases_extra.appendAssumeCapacity(1); // items_len
......@@ -13051,12 +13090,13 @@ fn analyzeSwitchRuntimeBlock(
1305113090 } else false
1305213091 else
1305313092 true;
13054 if (special.body.len != 0 and err_set and
13093 const else_hint: std.builtin.BranchHint = if (special.body.len != 0 and err_set and
1305513094 try sema.maybeErrorUnwrap(&case_block, special.body, operand, operand_src, allow_err_code_unwrap))
13056 {
13057 // nothing to do here
13058 } else if (special.body.len != 0 and analyze_body and !special.is_inline) {
13059 try spa.analyzeProngRuntime(
13095 h: {
13096 // nothing to do here. weight against error branch
13097 break :h .unlikely;
13098 } else if (special.body.len != 0 and analyze_body and !special.is_inline) h: {
13099 break :h try spa.analyzeProngRuntime(
1306013100 &case_block,
1306113101 .special,
1306213102 special.body,
......@@ -13069,7 +13109,7 @@ fn analyzeSwitchRuntimeBlock(
1306913109 .none,
1307013110 false,
1307113111 );
13072 } else {
13112 } else h: {
1307313113 // We still need a terminator in this block, but we have proven
1307413114 // that it is unreachable.
1307513115 if (case_block.wantSafety()) {
......@@ -13078,33 +13118,57 @@ fn analyzeSwitchRuntimeBlock(
1307813118 } else {
1307913119 _ = try case_block.addNoOp(.unreach);
1308013120 }
13081 }
13121 // Safety check / unreachable branches are cold.
13122 break :h .cold;
13123 };
1308213124
1308313125 if (is_first) {
13126 try branch_hints.append(gpa, else_hint);
1308413127 final_else_body = case_block.instructions.items;
1308513128 } else {
13129 try branch_hints.append(gpa, .none); // we have the range conditionals first
1308613130 try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len +
1308713131 @typeInfo(Air.CondBr).Struct.fields.len + case_block.instructions.items.len);
1308813132
13089 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload =
13090 sema.addExtraAssumeCapacity(Air.CondBr{
13133 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
1309113134 .then_body_len = @intCast(prev_then_body.len),
1309213135 .else_body_len = @intCast(case_block.instructions.items.len),
13136 .branch_hints = .{ .true = prev_hint, .false = else_hint },
1309313137 });
1309413138 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));
1309513139 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));
1309613140 final_else_body = first_else_body;
1309713141 }
13142 } else {
13143 try branch_hints.append(gpa, .none);
1309813144 }
1309913145
13146 assert(branch_hints.items.len == cases_len + 1);
13147
1310013148 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).Struct.fields.len +
13101 cases_extra.items.len + final_else_body.len);
13149 cases_extra.items.len + final_else_body.len +
13150 (std.math.divCeil(usize, branch_hints.items.len, 10) catch unreachable)); // branch hints
1310213151
1310313152 const payload_index = sema.addExtraAssumeCapacity(Air.SwitchBr{
1310413153 .cases_len = @intCast(cases_len),
1310513154 .else_body_len = @intCast(final_else_body.len),
1310613155 });
1310713156
13157 {
13158 // Add branch hints.
13159 var cur_bag: u32 = 0;
13160 for (branch_hints.items, 0..) |hint, idx| {
13161 const idx_in_bag = idx % 10;
13162 cur_bag |= @as(u32, @intFromEnum(hint)) << @intCast(idx_in_bag * 3);
13163 if (idx_in_bag == 9) {
13164 sema.air_extra.appendAssumeCapacity(cur_bag);
13165 cur_bag = 0;
13166 }
13167 }
13168 if (branch_hints.items.len % 10 != 0) {
13169 sema.air_extra.appendAssumeCapacity(cur_bag);
13170 }
13171 }
1310813172 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items));
1310913173 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(final_else_body));
1311013174
......@@ -19165,6 +19229,10 @@ fn zirBoolBr(
1916519229 const lhs_result: Air.Inst.Ref = if (is_bool_or) .bool_true else .bool_false;
1916619230 _ = try lhs_block.addBr(block_inst, lhs_result);
1916719231
19232 const parent_hint = sema.branch_hint;
19233 defer sema.branch_hint = parent_hint;
19234 sema.branch_hint = null;
19235
1916819236 const rhs_result = try sema.resolveInlineBody(rhs_block, body, inst);
1916919237 const rhs_noret = sema.typeOf(rhs_result).isNoReturn(zcu);
1917019238 const coerced_rhs_result = if (!rhs_noret) rhs: {
......@@ -19173,7 +19241,17 @@ fn zirBoolBr(
1917319241 break :rhs coerced_result;
1917419242 } else rhs_result;
1917519243
19176 const result = sema.finishCondBr(parent_block, &child_block, &then_block, &else_block, lhs, block_inst);
19244 const rhs_hint = sema.branch_hint orelse .none;
19245
19246 const result = try sema.finishCondBr(
19247 parent_block,
19248 &child_block,
19249 &then_block,
19250 &else_block,
19251 lhs,
19252 block_inst,
19253 if (is_bool_or) .{ .true = .none, .false = rhs_hint } else .{ .true = rhs_hint, .false = .none },
19254 );
1917719255 if (!rhs_noret) {
1917819256 if (try sema.resolveDefinedValue(rhs_block, rhs_src, coerced_rhs_result)) |rhs_val| {
1917919257 if (is_bool_or and rhs_val.toBool()) {
......@@ -19195,6 +19273,7 @@ fn finishCondBr(
1919519273 else_block: *Block,
1919619274 cond: Air.Inst.Ref,
1919719275 block_inst: Air.Inst.Index,
19276 branch_hints: Air.CondBr.BranchHints,
1919819277) !Air.Inst.Ref {
1919919278 const gpa = sema.gpa;
1920019279
......@@ -19205,6 +19284,7 @@ fn finishCondBr(
1920519284 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
1920619285 .then_body_len = @intCast(then_block.instructions.items.len),
1920719286 .else_body_len = @intCast(else_block.instructions.items.len),
19287 .branch_hints = branch_hints,
1920819288 });
1920919289 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
1921019290 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
......@@ -19339,6 +19419,11 @@ fn zirCondbr(
1933919419 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {
1934019420 const body = if (cond_val.toBool()) then_body else else_body;
1934119421
19422 // We can propagate `.cold` hints from this branch since it's comptime-known
19423 // to be taken from the parent branch.
19424 const parent_hint = sema.branch_hint;
19425 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19426
1934219427 try sema.maybeErrorUnwrapCondbr(parent_block, body, extra.data.condition, cond_src);
1934319428 // We use `analyzeBodyInner` since we want to propagate any comptime control flow to the caller.
1934419429 return sema.analyzeBodyInner(parent_block, body);
......@@ -19355,7 +19440,7 @@ fn zirCondbr(
1935519440 sub_block.need_debug_scope = null; // this body is emitted regardless
1935619441 defer sub_block.instructions.deinit(gpa);
1935719442
19358 try sema.analyzeBodyRuntimeBreak(&sub_block, then_body);
19443 const true_hint = try sema.analyzeBodyRuntimeBreak(&sub_block, then_body);
1935919444 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);
1936019445 defer gpa.free(true_instructions);
1936119446
......@@ -19371,11 +19456,13 @@ fn zirCondbr(
1937119456 break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand);
1937219457 };
1937319458
19374 if (err_cond != null and try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?, cond_src, false)) {
19375 // nothing to do
19376 } else {
19377 try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);
19378 }
19459 const false_hint: std.builtin.BranchHint = if (err_cond != null and
19460 try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?, cond_src, false))
19461 h: {
19462 // nothing to do here. weight against error branch
19463 break :h .unlikely;
19464 } else try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);
19465
1937919466 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +
1938019467 true_instructions.len + sub_block.instructions.items.len);
1938119468 _ = try parent_block.addInst(.{
......@@ -19385,6 +19472,7 @@ fn zirCondbr(
1938519472 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
1938619473 .then_body_len = @intCast(true_instructions.len),
1938719474 .else_body_len = @intCast(sub_block.instructions.items.len),
19475 .branch_hints = .{ .true = true_hint, .false = false_hint },
1938819476 }),
1938919477 } },
1939019478 });
......@@ -19409,6 +19497,11 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1940919497 }
1941019498 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);
1941119499 if (is_non_err != .none) {
19500 // We can propagate `.cold` hints from this branch since it's comptime-known
19501 // to be taken from the parent branch.
19502 const parent_hint = sema.branch_hint;
19503 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19504
1941219505 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;
1941319506 if (is_non_err_val.toBool()) {
1941419507 return sema.analyzeErrUnionPayload(parent_block, src, err_union_ty, err_union, operand_src, false);
......@@ -19422,13 +19515,19 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1942219515 var sub_block = parent_block.makeSubBlock();
1942319516 defer sub_block.instructions.deinit(sema.gpa);
1942419517
19518 const parent_hint = sema.branch_hint;
19519 defer sema.branch_hint = parent_hint;
19520
1942519521 // This body is guaranteed to end with noreturn and has no breaks.
1942619522 try sema.analyzeBodyInner(&sub_block, body);
1942719523
19524 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.
19525 const is_cold = sema.branch_hint == .cold;
19526
1942819527 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).Struct.fields.len +
1942919528 sub_block.instructions.items.len);
1943019529 const try_inst = try parent_block.addInst(.{
19431 .tag = .@"try",
19530 .tag = if (is_cold) .try_cold else .@"try",
1943219531 .data = .{ .pl_op = .{
1943319532 .operand = err_union,
1943419533 .payload = sema.addExtraAssumeCapacity(Air.Try{
......@@ -19458,6 +19557,11 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
1945819557 }
1945919558 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);
1946019559 if (is_non_err != .none) {
19560 // We can propagate `.cold` hints from this branch since it's comptime-known
19561 // to be taken from the parent branch.
19562 const parent_hint = sema.branch_hint;
19563 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19564
1946119565 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;
1946219566 if (is_non_err_val.toBool()) {
1946319567 return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false);
......@@ -19471,9 +19575,15 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
1947119575 var sub_block = parent_block.makeSubBlock();
1947219576 defer sub_block.instructions.deinit(sema.gpa);
1947319577
19578 const parent_hint = sema.branch_hint;
19579 defer sema.branch_hint = parent_hint;
19580
1947419581 // This body is guaranteed to end with noreturn and has no breaks.
1947519582 try sema.analyzeBodyInner(&sub_block, body);
1947619583
19584 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.
19585 const is_cold = sema.branch_hint == .cold;
19586
1947719587 const operand_ty = sema.typeOf(operand);
1947819588 const ptr_info = operand_ty.ptrInfo(zcu);
1947919589 const res_ty = try pt.ptrTypeSema(.{
......@@ -19489,7 +19599,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
1948919599 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).Struct.fields.len +
1949019600 sub_block.instructions.items.len);
1949119601 const try_inst = try parent_block.addInst(.{
19492 .tag = .try_ptr,
19602 .tag = if (is_cold) .try_ptr_cold else .try_ptr,
1949319603 .data = .{ .ty_pl = .{
1949419604 .ty = res_ty_ref,
1949519605 .payload = sema.addExtraAssumeCapacity(Air.TryPtr{
......@@ -19741,6 +19851,8 @@ fn retWithErrTracing(
1974119851 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
1974219852 .then_body_len = @intCast(then_block.instructions.items.len),
1974319853 .else_body_len = @intCast(else_block.instructions.items.len),
19854 // weight against error branch
19855 .branch_hints = .{ .true = .likely, .false = .unlikely },
1974419856 });
1974519857 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
1974619858 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
......@@ -26753,6 +26865,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr
2675326865 .export_options => "ExportOptions",
2675426866 .extern_options => "ExternOptions",
2675526867 .type_info => "Type",
26868 .branch_hint => "BranchHint",
2675626869
2675726870 // Values are handled here.
2675826871 .calling_convention_c => {
......@@ -26778,6 +26891,27 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr
2677826891 return Air.internedToRef(ty.toIntern());
2677926892}
2678026893
26894fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
26895 const pt = sema.pt;
26896 const zcu = pt.zcu;
26897
26898 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
26899 const uncoerced_hint = try sema.resolveInst(extra.operand);
26900 const operand_src = block.builtinCallArgSrc(extra.node, 0);
26901
26902 const hint_ty = try pt.getBuiltinType("BranchHint");
26903 const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src);
26904 const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{
26905 .needed_comptime_reason = "operand to '@branchHint' must be comptime-known",
26906 });
26907
26908 // We only apply the first hint in a branch.
26909 // This allows user-provided hints to override implicit cold hints.
26910 if (sema.branch_hint == null) {
26911 sema.branch_hint = zcu.toEnum(std.builtin.BranchHint, hint_val);
26912 }
26913}
26914
2678126915fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void {
2678226916 if (block.is_comptime) {
2678326917 const msg = msg: {
......@@ -27333,13 +27467,17 @@ fn addSafetyCheckExtra(
2733327467
2733427468 sema.air_instructions.appendAssumeCapacity(.{
2733527469 .tag = .cond_br,
27336 .data = .{ .pl_op = .{
27337 .operand = ok,
27338 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
27339 .then_body_len = 1,
27340 .else_body_len = @intCast(fail_block.instructions.items.len),
27341 }),
27342 } },
27470 .data = .{
27471 .pl_op = .{
27472 .operand = ok,
27473 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
27474 .then_body_len = 1,
27475 .else_body_len = @intCast(fail_block.instructions.items.len),
27476 // safety check failure branch is cold
27477 .branch_hints = .{ .true = .likely, .false = .cold },
27478 }),
27479 },
27480 },
2734327481 });
2734427482 sema.air_extra.appendAssumeCapacity(@intFromEnum(br_inst));
2734527483 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(fail_block.instructions.items));
......@@ -27536,6 +27674,7 @@ fn safetyCheckFormatted(
2753627674 try sema.addSafetyCheckExtra(parent_block, ok, &fail_block);
2753727675}
2753827676
27677/// This does not set `sema.branch_hint`.
2753927678fn safetyPanic(sema: *Sema, block: *Block, src: LazySrcLoc, panic_id: Zcu.PanicId) CompileError!void {
2754027679 const msg_nav_index = try sema.preparePanicId(block, src, panic_id);
2754127680 const msg_inst = try sema.analyzeNavVal(block, src, msg_nav_index);
......@@ -37185,7 +37324,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
3718537324 inline for (fields) |field| {
3718637325 sema.air_extra.appendAssumeCapacity(switch (field.type) {
3718737326 u32 => @field(extra, field.name),
37188 i32 => @bitCast(@field(extra, field.name)),
37327 i32, Air.CondBr.BranchHints => @bitCast(@field(extra, field.name)),
3718937328 Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(extra, field.name)),
3719037329 else => @compileError("bad field type: " ++ @typeName(field.type)),
3719137330 });
......@@ -38253,6 +38392,12 @@ fn maybeDerefSliceAsArray(
3825338392
3825438393fn analyzeUnreachable(sema: *Sema, block: *Block, src: LazySrcLoc, safety_check: bool) !void {
3825538394 if (safety_check and block.wantSafety()) {
38395 // We only apply the first hint in a branch.
38396 // This allows user-provided hints to override implicit cold hints.
38397 if (sema.branch_hint == null) {
38398 sema.branch_hint = .cold;
38399 }
38400
3825638401 try sema.safetyPanic(block, src, .unreach);
3825738402 } else {
3825838403 _ = try block.addNoOp(.unreach);
src/Zcu/PerThread.zig+2
......@@ -2188,6 +2188,8 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!
21882188 });
21892189 }
21902190
2191 func.setBranchHint(ip, sema.branch_hint orelse .none);
2192
21912193 // If we don't get an error return trace from a caller, create our own.
21922194 if (func.analysisUnordered(ip).calls_or_awaits_errorable_fn and
21932195 zcu.comp.config.any_error_tracing and
src/arch/aarch64/CodeGen.zig+18-24
......@@ -795,7 +795,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
795795 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
796796
797797 .@"try" => try self.airTry(inst),
798 .try_cold => try self.airTry(inst),
798799 .try_ptr => try self.airTryPtr(inst),
800 .try_ptr_cold => try self.airTryPtr(inst),
799801
800802 .dbg_stmt => try self.airDbgStmt(inst),
801803 .dbg_inline_block => try self.airDbgInlineBlock(inst),
......@@ -5092,25 +5094,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
50925094}
50935095
50945096fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5095 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
5096 const condition_ty = self.typeOf(pl_op.operand);
5097 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
5097 const switch_br = self.air.unwrapSwitch(inst);
5098 const condition_ty = self.typeOf(switch_br.operand);
50985099 const liveness = try self.liveness.getSwitchBr(
50995100 self.gpa,
51005101 inst,
5101 switch_br.data.cases_len + 1,
5102 switch_br.cases_len + 1,
51025103 );
51035104 defer self.gpa.free(liveness.deaths);
51045105
5105 var extra_index: usize = switch_br.end;
5106 var case_i: u32 = 0;
5107 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
5108 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
5109 const items = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[case.end..][0..case.data.items_len]));
5110 assert(items.len > 0);
5111 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
5112 extra_index = case.end + items.len + case_body.len;
5113
5106 var it = switch_br.iterateCases();
5107 while (it.next()) |case| {
51145108 // For every item, we compare it to condition and branch into
51155109 // the prong if they are equal. After we compared to all
51165110 // items, we branch into the next prong (or if no other prongs
......@@ -5126,11 +5120,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51265120 // prong: ...
51275121 // ...
51285122 // out: ...
5129 const branch_into_prong_relocs = try self.gpa.alloc(u32, items.len);
5123 const branch_into_prong_relocs = try self.gpa.alloc(u32, case.items.len);
51305124 defer self.gpa.free(branch_into_prong_relocs);
51315125
5132 for (items, 0..) |item, idx| {
5133 const cmp_result = try self.cmp(.{ .inst = pl_op.operand }, .{ .inst = item }, condition_ty, .neq);
5126 for (case.items, 0..) |item, idx| {
5127 const cmp_result = try self.cmp(.{ .inst = switch_br.operand }, .{ .inst = item }, condition_ty, .neq);
51345128 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);
51355129 }
51365130
......@@ -5156,11 +5150,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51565150 _ = self.branch_stack.pop();
51575151 }
51585152
5159 try self.ensureProcessDeathCapacity(liveness.deaths[case_i].len);
5160 for (liveness.deaths[case_i]) |operand| {
5153 try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len);
5154 for (liveness.deaths[case.idx]) |operand| {
51615155 self.processDeath(operand);
51625156 }
5163 try self.genBody(case_body);
5157 try self.genBody(case.body);
51645158
51655159 // Revert to the previous register and stack allocation state.
51665160 var saved_case_branch = self.branch_stack.pop();
......@@ -5178,8 +5172,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51785172 try self.performReloc(branch_away_from_prong_reloc);
51795173 }
51805174
5181 if (switch_br.data.else_body_len > 0) {
5182 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
5175 if (switch_br.else_body_len > 0) {
5176 const else_body = it.elseBody();
51835177
51845178 // Capture the state of register and stack allocation state so that we can revert to it.
51855179 const parent_next_stack_offset = self.next_stack_offset;
......@@ -5218,7 +5212,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
52185212 // in airCondBr.
52195213 }
52205214
5221 return self.finishAir(inst, .unreach, .{ pl_op.operand, .none, .none });
5215 return self.finishAir(inst, .unreach, .{ switch_br.operand, .none, .none });
52225216}
52235217
52245218fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {
......@@ -6363,14 +6357,14 @@ fn wantSafety(self: *Self) bool {
63636357}
63646358
63656359fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6366 @setCold(true);
6360 @branchHint(.cold);
63676361 assert(self.err_msg == null);
63686362 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);
63696363 return error.CodegenFail;
63706364}
63716365
63726366fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6373 @setCold(true);
6367 @branchHint(.cold);
63746368 assert(self.err_msg == null);
63756369 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);
63766370 return error.CodegenFail;
src/arch/aarch64/Emit.zig+1-1
......@@ -430,7 +430,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {
430430}
431431
432432fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
433 @setCold(true);
433 @branchHint(.cold);
434434 assert(emit.err_msg == null);
435435 const comp = emit.bin_file.comp;
436436 const gpa = comp.gpa;
src/arch/arm/CodeGen.zig+18-24
......@@ -782,7 +782,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
782782 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
783783
784784 .@"try" => try self.airTry(inst),
785 .try_cold => try self.airTry(inst),
785786 .try_ptr => try self.airTryPtr(inst),
787 .try_ptr_cold => try self.airTryPtr(inst),
786788
787789 .dbg_stmt => try self.airDbgStmt(inst),
788790 .dbg_inline_block => try self.airDbgInlineBlock(inst),
......@@ -5040,25 +5042,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
50405042}
50415043
50425044fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5043 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
5044 const condition_ty = self.typeOf(pl_op.operand);
5045 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
5045 const switch_br = self.air.unwrapSwitch(inst);
5046 const condition_ty = self.typeOf(switch_br.operand);
50465047 const liveness = try self.liveness.getSwitchBr(
50475048 self.gpa,
50485049 inst,
5049 switch_br.data.cases_len + 1,
5050 switch_br.cases_len + 1,
50505051 );
50515052 defer self.gpa.free(liveness.deaths);
50525053
5053 var extra_index: usize = switch_br.end;
5054 var case_i: u32 = 0;
5055 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
5056 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
5057 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
5058 assert(items.len > 0);
5059 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
5060 extra_index = case.end + items.len + case_body.len;
5061
5054 var it = switch_br.iterateCases();
5055 while (it.next()) |case| {
50625056 // For every item, we compare it to condition and branch into
50635057 // the prong if they are equal. After we compared to all
50645058 // items, we branch into the next prong (or if no other prongs
......@@ -5074,11 +5068,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
50745068 // prong: ...
50755069 // ...
50765070 // out: ...
5077 const branch_into_prong_relocs = try self.gpa.alloc(u32, items.len);
5071 const branch_into_prong_relocs = try self.gpa.alloc(u32, case.items.len);
50785072 defer self.gpa.free(branch_into_prong_relocs);
50795073
5080 for (items, 0..) |item, idx| {
5081 const cmp_result = try self.cmp(.{ .inst = pl_op.operand }, .{ .inst = item }, condition_ty, .neq);
5074 for (case.items, 0..) |item, idx| {
5075 const cmp_result = try self.cmp(.{ .inst = switch_br.operand }, .{ .inst = item }, condition_ty, .neq);
50825076 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);
50835077 }
50845078
......@@ -5104,11 +5098,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51045098 _ = self.branch_stack.pop();
51055099 }
51065100
5107 try self.ensureProcessDeathCapacity(liveness.deaths[case_i].len);
5108 for (liveness.deaths[case_i]) |operand| {
5101 try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len);
5102 for (liveness.deaths[case.idx]) |operand| {
51095103 self.processDeath(operand);
51105104 }
5111 try self.genBody(case_body);
5105 try self.genBody(case.body);
51125106
51135107 // Revert to the previous register and stack allocation state.
51145108 var saved_case_branch = self.branch_stack.pop();
......@@ -5126,8 +5120,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51265120 try self.performReloc(branch_away_from_prong_reloc);
51275121 }
51285122
5129 if (switch_br.data.else_body_len > 0) {
5130 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
5123 if (switch_br.else_body_len > 0) {
5124 const else_body = it.elseBody();
51315125
51325126 // Capture the state of register and stack allocation state so that we can revert to it.
51335127 const parent_next_stack_offset = self.next_stack_offset;
......@@ -5166,7 +5160,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
51665160 // in airCondBr.
51675161 }
51685162
5169 return self.finishAir(inst, .unreach, .{ pl_op.operand, .none, .none });
5163 return self.finishAir(inst, .unreach, .{ switch_br.operand, .none, .none });
51705164}
51715165
51725166fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {
......@@ -6319,7 +6313,7 @@ fn wantSafety(self: *Self) bool {
63196313}
63206314
63216315fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6322 @setCold(true);
6316 @branchHint(.cold);
63236317 assert(self.err_msg == null);
63246318 const gpa = self.gpa;
63256319 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
......@@ -6327,7 +6321,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
63276321}
63286322
63296323fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6330 @setCold(true);
6324 @branchHint(.cold);
63316325 assert(self.err_msg == null);
63326326 const gpa = self.gpa;
63336327 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/arm/Emit.zig+1-1
......@@ -348,7 +348,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {
348348}
349349
350350fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
351 @setCold(true);
351 @branchHint(.cold);
352352 assert(emit.err_msg == null);
353353 const comp = emit.bin_file.comp;
354354 const gpa = comp.gpa;
src/arch/riscv64/CodeGen.zig+18-25
......@@ -1640,7 +1640,9 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
16401640 .addrspace_cast => return func.fail("TODO: addrspace_cast", .{}),
16411641
16421642 .@"try" => try func.airTry(inst),
1643 .try_cold => try func.airTry(inst),
16431644 .try_ptr => return func.fail("TODO: try_ptr", .{}),
1645 .try_ptr_cold => return func.fail("TODO: try_ptr_cold", .{}),
16441646
16451647 .dbg_var_ptr,
16461648 .dbg_var_val,
......@@ -5659,38 +5661,30 @@ fn lowerBlock(func: *Func, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
56595661}
56605662
56615663fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
5662 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
5663 const condition_ty = func.typeOf(pl_op.operand);
5664 const switch_br = func.air.extraData(Air.SwitchBr, pl_op.payload);
5665 var extra_index: usize = switch_br.end;
5666 var case_i: u32 = 0;
5667 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.data.cases_len + 1);
5664 const switch_br = func.air.unwrapSwitch(inst);
5665
5666 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.cases_len + 1);
56685667 defer func.gpa.free(liveness.deaths);
56695668
5670 const condition = try func.resolveInst(pl_op.operand);
5669 const condition = try func.resolveInst(switch_br.operand);
5670 const condition_ty = func.typeOf(switch_br.operand);
56715671
56725672 // If the condition dies here in this switch instruction, process
56735673 // that death now instead of later as this has an effect on
56745674 // whether it needs to be spilled in the branches
56755675 if (func.liveness.operandDies(inst, 0)) {
5676 if (pl_op.operand.toIndex()) |op_inst| try func.processDeath(op_inst);
5676 if (switch_br.operand.toIndex()) |op_inst| try func.processDeath(op_inst);
56775677 }
56785678
56795679 func.scope_generation += 1;
56805680 const state = try func.saveState();
56815681
5682 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
5683 const case = func.air.extraData(Air.SwitchBr.Case, extra_index);
5684 const items: []const Air.Inst.Ref =
5685 @ptrCast(func.air.extra[case.end..][0..case.data.items_len]);
5686 const case_body: []const Air.Inst.Index =
5687 @ptrCast(func.air.extra[case.end + items.len ..][0..case.data.body_len]);
5688 extra_index = case.end + items.len + case_body.len;
5689
5690 var relocs = try func.gpa.alloc(Mir.Inst.Index, items.len);
5682 var it = switch_br.iterateCases();
5683 while (it.next()) |case| {
5684 var relocs = try func.gpa.alloc(Mir.Inst.Index, case.items.len);
56915685 defer func.gpa.free(relocs);
56925686
5693 for (items, relocs, 0..) |item, *reloc, i| {
5687 for (case.items, relocs, 0..) |item, *reloc, i| {
56945688 const item_mcv = try func.resolveInst(item);
56955689
56965690 const cond_lock = switch (condition) {
......@@ -5724,10 +5718,10 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
57245718 reloc.* = try func.condBr(condition_ty, .{ .register = cmp_reg });
57255719 }
57265720
5727 for (liveness.deaths[case_i]) |operand| try func.processDeath(operand);
5721 for (liveness.deaths[case.idx]) |operand| try func.processDeath(operand);
57285722
57295723 for (relocs[0 .. relocs.len - 1]) |reloc| func.performReloc(reloc);
5730 try func.genBody(case_body);
5724 try func.genBody(case.body);
57315725 try func.restoreState(state, &.{}, .{
57325726 .emit_instructions = false,
57335727 .update_tracking = true,
......@@ -5738,9 +5732,8 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
57385732 func.performReloc(relocs[relocs.len - 1]);
57395733 }
57405734
5741 if (switch_br.data.else_body_len > 0) {
5742 const else_body: []const Air.Inst.Index =
5743 @ptrCast(func.air.extra[extra_index..][0..switch_br.data.else_body_len]);
5735 if (switch_br.else_body_len > 0) {
5736 const else_body = it.elseBody();
57445737
57455738 const else_deaths = liveness.deaths.len - 1;
57465739 for (liveness.deaths[else_deaths]) |operand| try func.processDeath(operand);
......@@ -8230,14 +8223,14 @@ fn wantSafety(func: *Func) bool {
82308223}
82318224
82328225fn fail(func: *Func, comptime format: []const u8, args: anytype) InnerError {
8233 @setCold(true);
8226 @branchHint(.cold);
82348227 assert(func.err_msg == null);
82358228 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);
82368229 return error.CodegenFail;
82378230}
82388231
82398232fn failSymbol(func: *Func, comptime format: []const u8, args: anytype) InnerError {
8240 @setCold(true);
8233 @branchHint(.cold);
82418234 assert(func.err_msg == null);
82428235 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);
82438236 return error.CodegenFail;
src/arch/riscv64/Lower.zig+1-1
......@@ -583,7 +583,7 @@ fn pushPopRegList(lower: *Lower, comptime spilling: bool, reg_list: Mir.Register
583583}
584584
585585pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {
586 @setCold(true);
586 @branchHint(.cold);
587587 assert(lower.err_msg == null);
588588 lower.err_msg = try ErrorMsg.create(lower.allocator, lower.src_loc, format, args);
589589 return error.LowerFail;
src/arch/sparc64/CodeGen.zig+3-1
......@@ -637,7 +637,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
637637 .addrspace_cast => @panic("TODO try self.airAddrSpaceCast(int)"),
638638
639639 .@"try" => try self.airTry(inst),
640 .try_cold => try self.airTry(inst),
640641 .try_ptr => @panic("TODO try self.airTryPtr(inst)"),
642 .try_ptr_cold => @panic("TODO try self.airTryPtrCold(inst)"),
641643
642644 .dbg_stmt => try self.airDbgStmt(inst),
643645 .dbg_inline_block => try self.airDbgInlineBlock(inst),
......@@ -3531,7 +3533,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type)
35313533}
35323534
35333535fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
3534 @setCold(true);
3536 @branchHint(.cold);
35353537 assert(self.err_msg == null);
35363538 const gpa = self.gpa;
35373539 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/sparc64/Emit.zig+1-1
......@@ -511,7 +511,7 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void {
511511}
512512
513513fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
514 @setCold(true);
514 @branchHint(.cold);
515515 assert(emit.err_msg == null);
516516 const comp = emit.bin_file.comp;
517517 const gpa = comp.gpa;
src/arch/wasm/CodeGen.zig+16-20
......@@ -1913,7 +1913,9 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19131913 .get_union_tag => func.airGetUnionTag(inst),
19141914
19151915 .@"try" => func.airTry(inst),
1916 .try_cold => func.airTry(inst),
19161917 .try_ptr => func.airTryPtr(inst),
1918 .try_ptr_cold => func.airTryPtr(inst),
19171919
19181920 .dbg_stmt => func.airDbgStmt(inst),
19191921 .dbg_inline_block => func.airDbgInlineBlock(inst),
......@@ -4041,37 +4043,31 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
40414043 const zcu = pt.zcu;
40424044 // result type is always 'noreturn'
40434045 const blocktype = wasm.block_empty;
4044 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
4045 const target = try func.resolveInst(pl_op.operand);
4046 const target_ty = func.typeOf(pl_op.operand);
4047 const switch_br = func.air.extraData(Air.SwitchBr, pl_op.payload);
4048 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.data.cases_len + 1);
4046 const switch_br = func.air.unwrapSwitch(inst);
4047 const target = try func.resolveInst(switch_br.operand);
4048 const target_ty = func.typeOf(switch_br.operand);
4049 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.cases_len + 1);
40494050 defer func.gpa.free(liveness.deaths);
40504051
4051 var extra_index: usize = switch_br.end;
4052 var case_i: u32 = 0;
4053
40544052 // a list that maps each value with its value and body based on the order inside the list.
40554053 const CaseValue = struct { integer: i32, value: Value };
40564054 var case_list = try std.ArrayList(struct {
40574055 values: []const CaseValue,
40584056 body: []const Air.Inst.Index,
4059 }).initCapacity(func.gpa, switch_br.data.cases_len);
4057 }).initCapacity(func.gpa, switch_br.cases_len);
40604058 defer for (case_list.items) |case| {
40614059 func.gpa.free(case.values);
40624060 } else case_list.deinit();
40634061
40644062 var lowest_maybe: ?i32 = null;
40654063 var highest_maybe: ?i32 = null;
4066 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
4067 const case = func.air.extraData(Air.SwitchBr.Case, extra_index);
4068 const items: []const Air.Inst.Ref = @ptrCast(func.air.extra[case.end..][0..case.data.items_len]);
4069 const case_body: []const Air.Inst.Index = @ptrCast(func.air.extra[case.end + items.len ..][0..case.data.body_len]);
4070 extra_index = case.end + items.len + case_body.len;
4071 const values = try func.gpa.alloc(CaseValue, items.len);
4064
4065 var it = switch_br.iterateCases();
4066 while (it.next()) |case| {
4067 const values = try func.gpa.alloc(CaseValue, case.items.len);
40724068 errdefer func.gpa.free(values);
40734069
4074 for (items, 0..) |ref, i| {
4070 for (case.items, 0..) |ref, i| {
40754071 const item_val = (try func.air.value(ref, pt)).?;
40764072 const int_val = func.valueAsI32(item_val);
40774073 if (lowest_maybe == null or int_val < lowest_maybe.?) {
......@@ -4083,7 +4079,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
40834079 values[i] = .{ .integer = int_val, .value = item_val };
40844080 }
40854081
4086 case_list.appendAssumeCapacity(.{ .values = values, .body = case_body });
4082 case_list.appendAssumeCapacity(.{ .values = values, .body = case.body });
40874083 try func.startBlock(.block, blocktype);
40884084 }
40894085
......@@ -4097,7 +4093,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
40974093 // TODO: Benchmark this to find a proper value, LLVM seems to draw the line at '40~45'.
40984094 const is_sparse = highest - lowest > 50 or target_ty.bitSize(zcu) > 32;
40994095
4100 const else_body: []const Air.Inst.Index = @ptrCast(func.air.extra[extra_index..][0..switch_br.data.else_body_len]);
4096 const else_body = it.elseBody();
41014097 const has_else_body = else_body.len != 0;
41024098 if (has_else_body) {
41034099 try func.startBlock(.block, blocktype);
......@@ -4140,11 +4136,11 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
41404136 // for errors that are not present in any branch. This is fine as this default
41414137 // case will never be hit for those cases but we do save runtime cost and size
41424138 // by using a jump table for this instead of if-else chains.
4143 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) case_i else unreachable;
4139 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) switch_br.cases_len else unreachable;
41444140 };
41454141 func.mir_extra.appendAssumeCapacity(idx);
41464142 } else if (has_else_body) {
4147 func.mir_extra.appendAssumeCapacity(case_i); // default branch
4143 func.mir_extra.appendAssumeCapacity(switch_br.cases_len); // default branch
41484144 }
41494145 try func.endBlock();
41504146 }
src/arch/wasm/Emit.zig+1-1
......@@ -252,7 +252,7 @@ fn offset(self: Emit) u32 {
252252}
253253
254254fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
255 @setCold(true);
255 @branchHint(.cold);
256256 std.debug.assert(emit.error_msg == null);
257257 const comp = emit.bin_file.base.comp;
258258 const zcu = comp.zcu.?;
src/arch/x86_64/CodeGen.zig+17-25
......@@ -2262,7 +2262,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
22622262 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
22632263
22642264 .@"try" => try self.airTry(inst),
2265 .try_cold => try self.airTry(inst), // TODO
22652266 .try_ptr => try self.airTryPtr(inst),
2267 .try_ptr_cold => try self.airTryPtr(inst), // TODO
22662268
22672269 .dbg_stmt => try self.airDbgStmt(inst),
22682270 .dbg_inline_block => try self.airDbgInlineBlock(inst),
......@@ -13631,38 +13633,29 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
1363113633}
1363213634
1363313635fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
13634 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
13635 const condition = try self.resolveInst(pl_op.operand);
13636 const condition_ty = self.typeOf(pl_op.operand);
13637 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
13638 var extra_index: usize = switch_br.end;
13639 var case_i: u32 = 0;
13640 const liveness = try self.liveness.getSwitchBr(self.gpa, inst, switch_br.data.cases_len + 1);
13636 const switch_br = self.air.unwrapSwitch(inst);
13637 const condition = try self.resolveInst(switch_br.operand);
13638 const condition_ty = self.typeOf(switch_br.operand);
13639 const liveness = try self.liveness.getSwitchBr(self.gpa, inst, switch_br.cases_len + 1);
1364113640 defer self.gpa.free(liveness.deaths);
1364213641
1364313642 // If the condition dies here in this switch instruction, process
1364413643 // that death now instead of later as this has an effect on
1364513644 // whether it needs to be spilled in the branches
1364613645 if (self.liveness.operandDies(inst, 0)) {
13647 if (pl_op.operand.toIndex()) |op_inst| try self.processDeath(op_inst);
13646 if (switch_br.operand.toIndex()) |op_inst| try self.processDeath(op_inst);
1364813647 }
1364913648
1365013649 self.scope_generation += 1;
1365113650 const state = try self.saveState();
1365213651
13653 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
13654 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
13655 const items: []const Air.Inst.Ref =
13656 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
13657 const case_body: []const Air.Inst.Index =
13658 @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
13659 extra_index = case.end + items.len + case_body.len;
13660
13661 var relocs = try self.gpa.alloc(Mir.Inst.Index, items.len);
13652 var it = switch_br.iterateCases();
13653 while (it.next()) |case| {
13654 var relocs = try self.gpa.alloc(Mir.Inst.Index, case.items.len);
1366213655 defer self.gpa.free(relocs);
1366313656
1366413657 try self.spillEflagsIfOccupied();
13665 for (items, relocs, 0..) |item, *reloc, i| {
13658 for (case.items, relocs, 0..) |item, *reloc, i| {
1366613659 const item_mcv = try self.resolveInst(item);
1366713660 const cc: Condition = switch (condition) {
1366813661 .eflags => |cc| switch (item_mcv.immediate) {
......@@ -13678,10 +13671,10 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
1367813671 reloc.* = try self.asmJccReloc(if (i < relocs.len - 1) cc else cc.negate(), undefined);
1367913672 }
1368013673
13681 for (liveness.deaths[case_i]) |operand| try self.processDeath(operand);
13674 for (liveness.deaths[case.idx]) |operand| try self.processDeath(operand);
1368213675
1368313676 for (relocs[0 .. relocs.len - 1]) |reloc| self.performReloc(reloc);
13684 try self.genBody(case_body);
13677 try self.genBody(case.body);
1368513678 try self.restoreState(state, &.{}, .{
1368613679 .emit_instructions = false,
1368713680 .update_tracking = true,
......@@ -13692,9 +13685,8 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
1369213685 self.performReloc(relocs[relocs.len - 1]);
1369313686 }
1369413687
13695 if (switch_br.data.else_body_len > 0) {
13696 const else_body: []const Air.Inst.Index =
13697 @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
13688 if (switch_br.else_body_len > 0) {
13689 const else_body = it.elseBody();
1369813690
1369913691 const else_deaths = liveness.deaths.len - 1;
1370013692 for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);
......@@ -19211,7 +19203,7 @@ fn resolveCallingConventionValues(
1921119203}
1921219204
1921319205fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
19214 @setCold(true);
19206 @branchHint(.cold);
1921519207 assert(self.err_msg == null);
1921619208 const gpa = self.gpa;
1921719209 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
......@@ -19219,7 +19211,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
1921919211}
1922019212
1922119213fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
19222 @setCold(true);
19214 @branchHint(.cold);
1922319215 assert(self.err_msg == null);
1922419216 const gpa = self.gpa;
1922519217 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/x86_64/Lower.zig+1-1
......@@ -293,7 +293,7 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {
293293}
294294
295295pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {
296 @setCold(true);
296 @branchHint(.cold);
297297 assert(lower.err_msg == null);
298298 lower.err_msg = try Zcu.ErrorMsg.create(lower.allocator, lower.src_loc, format, args);
299299 return error.LowerFail;
src/codegen/c.zig+20-25
......@@ -626,7 +626,7 @@ pub const DeclGen = struct {
626626 }
627627
628628 fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {
629 @setCold(true);
629 @branchHint(.cold);
630630 const zcu = dg.pt.zcu;
631631 const src_loc = zcu.navSrcLoc(dg.pass.nav);
632632 dg.error_msg = try Zcu.ErrorMsg.create(dg.gpa, src_loc, format, args);
......@@ -1786,7 +1786,7 @@ pub const DeclGen = struct {
17861786 else => unreachable,
17871787 }
17881788 }
1789 if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).is_cold)
1789 if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).branch_hint == .cold)
17901790 try w.writeAll("zig_cold ");
17911791 if (fn_info.return_type == .noreturn_type) try w.writeAll("zig_noreturn ");
17921792
......@@ -3290,8 +3290,10 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
32903290 .prefetch => try airPrefetch(f, inst),
32913291 .addrspace_cast => return f.fail("TODO: C backend: implement addrspace_cast", .{}),
32923292
3293 .@"try" => try airTry(f, inst),
3294 .try_ptr => try airTryPtr(f, inst),
3293 .@"try" => try airTry(f, inst),
3294 .try_cold => try airTry(f, inst),
3295 .try_ptr => try airTryPtr(f, inst),
3296 .try_ptr_cold => try airTryPtr(f, inst),
32953297
32963298 .dbg_stmt => try airDbgStmt(f, inst),
32973299 .dbg_inline_block => try airDbgInlineBlock(f, inst),
......@@ -4988,11 +4990,10 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
49884990fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
49894991 const pt = f.object.dg.pt;
49904992 const zcu = pt.zcu;
4991 const pl_op = f.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
4992 const condition = try f.resolveInst(pl_op.operand);
4993 try reap(f, inst, &.{pl_op.operand});
4994 const condition_ty = f.typeOf(pl_op.operand);
4995 const switch_br = f.air.extraData(Air.SwitchBr, pl_op.payload);
4993 const switch_br = f.air.unwrapSwitch(inst);
4994 const condition = try f.resolveInst(switch_br.operand);
4995 try reap(f, inst, &.{switch_br.operand});
4996 const condition_ty = f.typeOf(switch_br.operand);
49964997 const writer = f.object.writer();
49974998
49984999 try writer.writeAll("switch (");
......@@ -5013,22 +5014,16 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
50135014 f.object.indent_writer.pushIndent();
50145015
50155016 const gpa = f.object.dg.gpa;
5016 const liveness = try f.liveness.getSwitchBr(gpa, inst, switch_br.data.cases_len + 1);
5017 const liveness = try f.liveness.getSwitchBr(gpa, inst, switch_br.cases_len + 1);
50175018 defer gpa.free(liveness.deaths);
50185019
50195020 // On the final iteration we do not need to fix any state. This is because, like in the `else`
50205021 // branch of a `cond_br`, our parent has to do it for this entire body anyway.
5021 const last_case_i = switch_br.data.cases_len - @intFromBool(switch_br.data.else_body_len == 0);
5022
5023 var extra_index: usize = switch_br.end;
5024 for (0..switch_br.data.cases_len) |case_i| {
5025 const case = f.air.extraData(Air.SwitchBr.Case, extra_index);
5026 const items = @as([]const Air.Inst.Ref, @ptrCast(f.air.extra[case.end..][0..case.data.items_len]));
5027 const case_body: []const Air.Inst.Index =
5028 @ptrCast(f.air.extra[case.end + items.len ..][0..case.data.body_len]);
5029 extra_index = case.end + case.data.items_len + case_body.len;
5022 const last_case_i = switch_br.cases_len - @intFromBool(switch_br.else_body_len == 0);
50305023
5031 for (items) |item| {
5024 var it = switch_br.iterateCases();
5025 while (it.next()) |case| {
5026 for (case.items) |item| {
50325027 try f.object.indent_writer.insertNewline();
50335028 try writer.writeAll("case ");
50345029 const item_value = try f.air.value(item, pt);
......@@ -5046,19 +5041,19 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
50465041 }
50475042 try writer.writeByte(' ');
50485043
5049 if (case_i != last_case_i) {
5050 try genBodyResolveState(f, inst, liveness.deaths[case_i], case_body, false);
5044 if (case.idx != last_case_i) {
5045 try genBodyResolveState(f, inst, liveness.deaths[case.idx], case.body, false);
50515046 } else {
5052 for (liveness.deaths[case_i]) |death| {
5047 for (liveness.deaths[case.idx]) |death| {
50535048 try die(f, inst, death.toRef());
50545049 }
5055 try genBody(f, case_body);
5050 try genBody(f, case.body);
50565051 }
50575052
50585053 // The case body must be noreturn so we don't need to insert a break.
50595054 }
50605055
5061 const else_body: []const Air.Inst.Index = @ptrCast(f.air.extra[extra_index..][0..switch_br.data.else_body_len]);
5056 const else_body = it.elseBody();
50625057 try f.object.indent_writer.insertNewline();
50635058 if (else_body.len > 0) {
50645059 // Note that this must be the last case (i.e. the `last_case_i` case was not hit above)
src/codegen/llvm.zig+160-75
......@@ -898,9 +898,9 @@ pub const Object = struct {
898898 const i32_2 = try builder.intConst(.i32, 2);
899899 const i32_3 = try builder.intConst(.i32, 3);
900900 const debug_info_version = try builder.debugModuleFlag(
901 try builder.debugConstant(i32_2),
901 try builder.metadataConstant(i32_2),
902902 try builder.metadataString("Debug Info Version"),
903 try builder.debugConstant(i32_3),
903 try builder.metadataConstant(i32_3),
904904 );
905905
906906 switch (comp.config.debug_format) {
......@@ -908,9 +908,9 @@ pub const Object = struct {
908908 .dwarf => |f| {
909909 const i32_4 = try builder.intConst(.i32, 4);
910910 const dwarf_version = try builder.debugModuleFlag(
911 try builder.debugConstant(i32_2),
911 try builder.metadataConstant(i32_2),
912912 try builder.metadataString("Dwarf Version"),
913 try builder.debugConstant(i32_4),
913 try builder.metadataConstant(i32_4),
914914 );
915915 switch (f) {
916916 .@"32" => {
......@@ -921,9 +921,9 @@ pub const Object = struct {
921921 },
922922 .@"64" => {
923923 const dwarf64 = try builder.debugModuleFlag(
924 try builder.debugConstant(i32_2),
924 try builder.metadataConstant(i32_2),
925925 try builder.metadataString("DWARF64"),
926 try builder.debugConstant(.@"1"),
926 try builder.metadataConstant(.@"1"),
927927 );
928928 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{
929929 debug_info_version,
......@@ -935,9 +935,9 @@ pub const Object = struct {
935935 },
936936 .code_view => {
937937 const code_view = try builder.debugModuleFlag(
938 try builder.debugConstant(i32_2),
938 try builder.metadataConstant(i32_2),
939939 try builder.metadataString("CodeView"),
940 try builder.debugConstant(.@"1"),
940 try builder.metadataConstant(.@"1"),
941941 );
942942 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{
943943 debug_info_version,
......@@ -1122,12 +1122,12 @@ pub const Object = struct {
11221122
11231123 self.builder.debugForwardReferenceSetType(
11241124 self.debug_enums_fwd_ref,
1125 try self.builder.debugTuple(self.debug_enums.items),
1125 try self.builder.metadataTuple(self.debug_enums.items),
11261126 );
11271127
11281128 self.builder.debugForwardReferenceSetType(
11291129 self.debug_globals_fwd_ref,
1130 try self.builder.debugTuple(self.debug_globals.items),
1130 try self.builder.metadataTuple(self.debug_globals.items),
11311131 );
11321132 }
11331133 }
......@@ -1369,7 +1369,7 @@ pub const Object = struct {
13691369 _ = try attributes.removeFnAttr(.alignstack);
13701370 }
13711371
1372 if (func_analysis.is_cold) {
1372 if (func_analysis.branch_hint == .cold) {
13731373 try attributes.addFnAttr(.cold, &o.builder);
13741374 } else {
13751375 _ = try attributes.removeFnAttr(.cold);
......@@ -1978,7 +1978,7 @@ pub const Object = struct {
19781978 try o.lowerDebugType(int_ty),
19791979 ty.abiSize(zcu) * 8,
19801980 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
1981 try o.builder.debugTuple(enumerators),
1981 try o.builder.metadataTuple(enumerators),
19821982 );
19831983
19841984 try o.debug_type_map.put(gpa, ty, debug_enum_type);
......@@ -2087,7 +2087,7 @@ pub const Object = struct {
20872087 .none, // Underlying type
20882088 ty.abiSize(zcu) * 8,
20892089 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2090 try o.builder.debugTuple(&.{
2090 try o.builder.metadataTuple(&.{
20912091 debug_ptr_type,
20922092 debug_len_type,
20932093 }),
......@@ -2167,10 +2167,10 @@ pub const Object = struct {
21672167 try o.lowerDebugType(ty.childType(zcu)),
21682168 ty.abiSize(zcu) * 8,
21692169 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2170 try o.builder.debugTuple(&.{
2170 try o.builder.metadataTuple(&.{
21712171 try o.builder.debugSubrange(
2172 try o.builder.debugConstant(try o.builder.intConst(.i64, 0)),
2173 try o.builder.debugConstant(try o.builder.intConst(.i64, ty.arrayLen(zcu))),
2172 try o.builder.metadataConstant(try o.builder.intConst(.i64, 0)),
2173 try o.builder.metadataConstant(try o.builder.intConst(.i64, ty.arrayLen(zcu))),
21742174 ),
21752175 }),
21762176 );
......@@ -2210,10 +2210,10 @@ pub const Object = struct {
22102210 debug_elem_type,
22112211 ty.abiSize(zcu) * 8,
22122212 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2213 try o.builder.debugTuple(&.{
2213 try o.builder.metadataTuple(&.{
22142214 try o.builder.debugSubrange(
2215 try o.builder.debugConstant(try o.builder.intConst(.i64, 0)),
2216 try o.builder.debugConstant(try o.builder.intConst(.i64, ty.vectorLen(zcu))),
2215 try o.builder.metadataConstant(try o.builder.intConst(.i64, 0)),
2216 try o.builder.metadataConstant(try o.builder.intConst(.i64, ty.vectorLen(zcu))),
22172217 ),
22182218 }),
22192219 );
......@@ -2288,7 +2288,7 @@ pub const Object = struct {
22882288 .none, // Underlying type
22892289 ty.abiSize(zcu) * 8,
22902290 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2291 try o.builder.debugTuple(&.{
2291 try o.builder.metadataTuple(&.{
22922292 debug_data_type,
22932293 debug_some_type,
22942294 }),
......@@ -2367,7 +2367,7 @@ pub const Object = struct {
23672367 .none, // Underlying type
23682368 ty.abiSize(zcu) * 8,
23692369 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2370 try o.builder.debugTuple(&fields),
2370 try o.builder.metadataTuple(&fields),
23712371 );
23722372
23732373 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_error_union_type);
......@@ -2447,7 +2447,7 @@ pub const Object = struct {
24472447 .none, // Underlying type
24482448 ty.abiSize(zcu) * 8,
24492449 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2450 try o.builder.debugTuple(fields.items),
2450 try o.builder.metadataTuple(fields.items),
24512451 );
24522452
24532453 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);
......@@ -2520,7 +2520,7 @@ pub const Object = struct {
25202520 .none, // Underlying type
25212521 ty.abiSize(zcu) * 8,
25222522 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2523 try o.builder.debugTuple(fields.items),
2523 try o.builder.metadataTuple(fields.items),
25242524 );
25252525
25262526 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);
......@@ -2561,7 +2561,7 @@ pub const Object = struct {
25612561 .none, // Underlying type
25622562 ty.abiSize(zcu) * 8,
25632563 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2564 try o.builder.debugTuple(
2564 try o.builder.metadataTuple(
25652565 &.{try o.lowerDebugType(Type.fromInterned(union_type.enum_tag_ty))},
25662566 ),
25672567 );
......@@ -2623,7 +2623,7 @@ pub const Object = struct {
26232623 .none, // Underlying type
26242624 ty.abiSize(zcu) * 8,
26252625 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2626 try o.builder.debugTuple(fields.items),
2626 try o.builder.metadataTuple(fields.items),
26272627 );
26282628
26292629 o.builder.debugForwardReferenceSetType(debug_union_fwd_ref, debug_union_type);
......@@ -2682,7 +2682,7 @@ pub const Object = struct {
26822682 .none, // Underlying type
26832683 ty.abiSize(zcu) * 8,
26842684 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2685 try o.builder.debugTuple(&full_fields),
2685 try o.builder.metadataTuple(&full_fields),
26862686 );
26872687
26882688 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_tagged_union_type);
......@@ -2735,7 +2735,7 @@ pub const Object = struct {
27352735 }
27362736
27372737 const debug_function_type = try o.builder.debugSubroutineType(
2738 try o.builder.debugTuple(debug_param_types.items),
2738 try o.builder.metadataTuple(debug_param_types.items),
27392739 );
27402740
27412741 try o.debug_type_map.put(gpa, ty, debug_function_type);
......@@ -4571,7 +4571,7 @@ pub const Object = struct {
45714571 const bad_value_block = try wip.block(1, "BadValue");
45724572 const tag_int_value = wip.arg(0);
45734573 var wip_switch =
4574 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len));
4574 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len), .none);
45754575 defer wip_switch.finish(&wip);
45764576
45774577 for (0..enum_type.names.len) |field_index| {
......@@ -4618,7 +4618,7 @@ pub const NavGen = struct {
46184618 }
46194619
46204620 fn todo(ng: *NavGen, comptime format: []const u8, args: anytype) Error {
4621 @setCold(true);
4621 @branchHint(.cold);
46224622 assert(ng.err_msg == null);
46234623 const o = ng.object;
46244624 const gpa = o.gpa;
......@@ -4784,7 +4784,7 @@ pub const FuncGen = struct {
47844784 }
47854785
47864786 fn todo(self: *FuncGen, comptime format: []const u8, args: anytype) Error {
4787 @setCold(true);
4787 @branchHint(.cold);
47884788 return self.ng.todo(format, args);
47894789 }
47904790
......@@ -4958,8 +4958,10 @@ pub const FuncGen = struct {
49584958 .ret_addr => try self.airRetAddr(inst),
49594959 .frame_addr => try self.airFrameAddress(inst),
49604960 .cond_br => try self.airCondBr(inst),
4961 .@"try" => try self.airTry(body[i..]),
4962 .try_ptr => try self.airTryPtr(inst),
4961 .@"try" => try self.airTry(body[i..], false),
4962 .try_cold => try self.airTry(body[i..], true),
4963 .try_ptr => try self.airTryPtr(inst, false),
4964 .try_ptr_cold => try self.airTryPtr(inst, true),
49634965 .intcast => try self.airIntCast(inst),
49644966 .trunc => try self.airTrunc(inst),
49654967 .fptrunc => try self.airFptrunc(inst),
......@@ -5506,6 +5508,7 @@ pub const FuncGen = struct {
55065508 const panic_nav = ip.getNav(panic_func.owner_nav);
55075509 const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?;
55085510 const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav);
5511 _ = try fg.wip.callIntrinsicAssumeCold();
55095512 _ = try fg.wip.call(
55105513 .normal,
55115514 toLlvmCallConv(fn_info.cc, target),
......@@ -5794,7 +5797,7 @@ pub const FuncGen = struct {
57945797 const mixed_block = try self.wip.block(1, "Mixed");
57955798 const both_pl_block = try self.wip.block(1, "BothNonNull");
57965799 const end_block = try self.wip.block(3, "End");
5797 var wip_switch = try self.wip.@"switch"(lhs_rhs_ored, mixed_block, 2);
5800 var wip_switch = try self.wip.@"switch"(lhs_rhs_ored, mixed_block, 2, .none);
57985801 defer wip_switch.finish(&self.wip);
57995802 try wip_switch.addCase(
58005803 try o.builder.intConst(llvm_i2, 0b00),
......@@ -5948,21 +5951,62 @@ pub const FuncGen = struct {
59485951 const then_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.then_body_len]);
59495952 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]);
59505953
5954 const Hint = enum {
5955 none,
5956 unpredictable,
5957 then_likely,
5958 else_likely,
5959 then_cold,
5960 else_cold,
5961 };
5962 const hint: Hint = switch (extra.data.branch_hints.true) {
5963 .none => switch (extra.data.branch_hints.false) {
5964 .none => .none,
5965 .likely => .else_likely,
5966 .unlikely => .then_likely,
5967 .cold => .else_cold,
5968 .unpredictable => .unpredictable,
5969 },
5970 .likely => switch (extra.data.branch_hints.false) {
5971 .none => .then_likely,
5972 .likely => .unpredictable,
5973 .unlikely => .then_likely,
5974 .cold => .else_cold,
5975 .unpredictable => .unpredictable,
5976 },
5977 .unlikely => switch (extra.data.branch_hints.false) {
5978 .none => .else_likely,
5979 .likely => .else_likely,
5980 .unlikely => .unpredictable,
5981 .cold => .else_cold,
5982 .unpredictable => .unpredictable,
5983 },
5984 .cold => .then_cold,
5985 .unpredictable => .unpredictable,
5986 };
5987
59515988 const then_block = try self.wip.block(1, "Then");
59525989 const else_block = try self.wip.block(1, "Else");
5953 _ = try self.wip.brCond(cond, then_block, else_block);
5990 _ = try self.wip.brCond(cond, then_block, else_block, switch (hint) {
5991 .none, .then_cold, .else_cold => .none,
5992 .unpredictable => .unpredictable,
5993 .then_likely => .then_likely,
5994 .else_likely => .else_likely,
5995 });
59545996
59555997 self.wip.cursor = .{ .block = then_block };
5998 if (hint == .then_cold) _ = try self.wip.callIntrinsicAssumeCold();
59565999 try self.genBodyDebugScope(null, then_body);
59576000
59586001 self.wip.cursor = .{ .block = else_block };
6002 if (hint == .else_cold) _ = try self.wip.callIntrinsicAssumeCold();
59596003 try self.genBodyDebugScope(null, else_body);
59606004
59616005 // No need to reset the insert cursor since this instruction is noreturn.
59626006 return .none;
59636007 }
59646008
5965 fn airTry(self: *FuncGen, body_tail: []const Air.Inst.Index) !Builder.Value {
6009 fn airTry(self: *FuncGen, body_tail: []const Air.Inst.Index, err_cold: bool) !Builder.Value {
59666010 const o = self.ng.object;
59676011 const pt = o.pt;
59686012 const zcu = pt.zcu;
......@@ -5975,10 +6019,10 @@ pub const FuncGen = struct {
59756019 const payload_ty = self.typeOfIndex(inst);
59766020 const can_elide_load = if (isByRef(payload_ty, zcu)) self.canElideLoad(body_tail) else false;
59776021 const is_unused = self.liveness.isUnused(inst);
5978 return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, is_unused);
6022 return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, is_unused, err_cold);
59796023 }
59806024
5981 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6025 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index, err_cold: bool) !Builder.Value {
59826026 const o = self.ng.object;
59836027 const zcu = o.pt.zcu;
59846028 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
......@@ -5987,7 +6031,7 @@ pub const FuncGen = struct {
59876031 const body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
59886032 const err_union_ty = self.typeOf(extra.data.ptr).childType(zcu);
59896033 const is_unused = self.liveness.isUnused(inst);
5990 return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, is_unused);
6034 return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, is_unused, err_cold);
59916035 }
59926036
59936037 fn lowerTry(
......@@ -5998,6 +6042,7 @@ pub const FuncGen = struct {
59986042 operand_is_ptr: bool,
59996043 can_elide_load: bool,
60006044 is_unused: bool,
6045 err_cold: bool,
60016046 ) !Builder.Value {
60026047 const o = fg.ng.object;
60036048 const pt = o.pt;
......@@ -6036,9 +6081,10 @@ pub const FuncGen = struct {
60366081
60376082 const return_block = try fg.wip.block(1, "TryRet");
60386083 const continue_block = try fg.wip.block(1, "TryCont");
6039 _ = try fg.wip.brCond(is_err, return_block, continue_block);
6084 _ = try fg.wip.brCond(is_err, return_block, continue_block, if (err_cold) .none else .else_likely);
60406085
60416086 fg.wip.cursor = .{ .block = return_block };
6087 if (err_cold) _ = try fg.wip.callIntrinsicAssumeCold();
60426088 try fg.genBodyDebugScope(null, body);
60436089
60446090 fg.wip.cursor = .{ .block = continue_block };
......@@ -6065,9 +6111,11 @@ pub const FuncGen = struct {
60656111
60666112 fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
60676113 const o = self.ng.object;
6068 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6069 const cond = try self.resolveInst(pl_op.operand);
6070 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
6114
6115 const switch_br = self.air.unwrapSwitch(inst);
6116
6117 const cond = try self.resolveInst(switch_br.operand);
6118
60716119 const else_block = try self.wip.block(1, "Default");
60726120 const llvm_usize = try o.lowerType(Type.usize);
60736121 const cond_int = if (cond.typeOfWip(&self.wip).isPointer(&o.builder))
......@@ -6075,34 +6123,70 @@ pub const FuncGen = struct {
60756123 else
60766124 cond;
60776125
6078 var extra_index: usize = switch_br.end;
6079 var case_i: u32 = 0;
6080 var llvm_cases_len: u32 = 0;
6081 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
6082 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6083 const items: []const Air.Inst.Ref =
6084 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6085 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
6086 extra_index = case.end + case.data.items_len + case_body.len;
6126 const llvm_cases_len = llvm_cases_len: {
6127 var len: u32 = 0;
6128 var it = switch_br.iterateCases();
6129 while (it.next()) |case| len += @intCast(case.items.len);
6130 break :llvm_cases_len len;
6131 };
6132
6133 const weights: Builder.Function.Instruction.BrCond.Weights = weights: {
6134 // First pass. If any weights are `.unpredictable`, unpredictable.
6135 // If all are `.none` or `.cold`, none.
6136 var any_likely = false;
6137 for (0..switch_br.cases_len) |case_idx| {
6138 switch (switch_br.getHint(@intCast(case_idx))) {
6139 .none, .cold => {},
6140 .likely, .unlikely => any_likely = true,
6141 .unpredictable => break :weights .unpredictable,
6142 }
6143 }
6144 switch (switch_br.getElseHint()) {
6145 .none, .cold => {},
6146 .likely, .unlikely => any_likely = true,
6147 .unpredictable => break :weights .unpredictable,
6148 }
6149 if (!any_likely) break :weights .none;
60876150
6088 llvm_cases_len += @intCast(items.len);
6089 }
6151 var weights = try self.gpa.alloc(Builder.Metadata, llvm_cases_len + 1);
6152 defer self.gpa.free(weights);
60906153
6091 var wip_switch = try self.wip.@"switch"(cond_int, else_block, llvm_cases_len);
6092 defer wip_switch.finish(&self.wip);
6154 const else_weight: u32 = switch (switch_br.getElseHint()) {
6155 .unpredictable => unreachable,
6156 .none, .cold => 1000,
6157 .likely => 2000,
6158 .unlikely => 1,
6159 };
6160 weights[0] = try o.builder.metadataConstant(try o.builder.intConst(.i32, else_weight));
6161
6162 var weight_idx: usize = 1;
6163 var it = switch_br.iterateCases();
6164 while (it.next()) |case| {
6165 const weight_val: u32 = switch (switch_br.getHint(case.idx)) {
6166 .unpredictable => unreachable,
6167 .none, .cold => 1000,
6168 .likely => 2000,
6169 .unlikely => 1,
6170 };
6171 const weight_meta = try o.builder.metadataConstant(try o.builder.intConst(.i32, weight_val));
6172 @memset(weights[weight_idx..][0..case.items.len], weight_meta);
6173 weight_idx += case.items.len;
6174 }
6175
6176 assert(weight_idx == weights.len);
60936177
6094 extra_index = switch_br.end;
6095 case_i = 0;
6096 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
6097 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6098 const items: []const Air.Inst.Ref =
6099 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6100 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
6101 extra_index = case.end + case.data.items_len + case_body.len;
6178 const branch_weights_str = try o.builder.metadataString("branch_weights");
6179 const tuple = try o.builder.strTuple(branch_weights_str, weights);
6180 break :weights @enumFromInt(@intFromEnum(tuple));
6181 };
61026182
6103 const case_block = try self.wip.block(@intCast(items.len), "Case");
6183 var wip_switch = try self.wip.@"switch"(cond_int, else_block, llvm_cases_len, weights);
6184 defer wip_switch.finish(&self.wip);
61046185
6105 for (items) |item| {
6186 var it = switch_br.iterateCases();
6187 while (it.next()) |case| {
6188 const case_block = try self.wip.block(@intCast(case.items.len), "Case");
6189 for (case.items) |item| {
61066190 const llvm_item = (try self.resolveInst(item)).toConst().?;
61076191 const llvm_int_item = if (llvm_item.typeOf(&o.builder).isPointer(&o.builder))
61086192 try o.builder.castConst(.ptrtoint, llvm_item, llvm_usize)
......@@ -6110,13 +6194,14 @@ pub const FuncGen = struct {
61106194 llvm_item;
61116195 try wip_switch.addCase(llvm_int_item, case_block, &self.wip);
61126196 }
6113
61146197 self.wip.cursor = .{ .block = case_block };
6115 try self.genBodyDebugScope(null, case_body);
6198 if (switch_br.getHint(case.idx) == .cold) _ = try self.wip.callIntrinsicAssumeCold();
6199 try self.genBodyDebugScope(null, case.body);
61166200 }
61176201
6202 const else_body = it.elseBody();
61186203 self.wip.cursor = .{ .block = else_block };
6119 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
6204 if (switch_br.getElseHint() == .cold) _ = try self.wip.callIntrinsicAssumeCold();
61206205 if (else_body.len != 0) {
61216206 try self.genBodyDebugScope(null, else_body);
61226207 } else {
......@@ -7748,7 +7833,7 @@ pub const FuncGen = struct {
77487833
77497834 const fail_block = try fg.wip.block(1, "OverflowFail");
77507835 const ok_block = try fg.wip.block(1, "OverflowOk");
7751 _ = try fg.wip.brCond(overflow_bit, fail_block, ok_block);
7836 _ = try fg.wip.brCond(overflow_bit, fail_block, ok_block, .none);
77527837
77537838 fg.wip.cursor = .{ .block = fail_block };
77547839 try fg.buildSimplePanic(.integer_overflow);
......@@ -9389,7 +9474,7 @@ pub const FuncGen = struct {
93899474 self.wip.cursor = .{ .block = loop_block };
93909475 const it_ptr = try self.wip.phi(.ptr, "");
93919476 const end = try self.wip.icmp(.ne, it_ptr.toValue(), end_ptr, "");
9392 _ = try self.wip.brCond(end, body_block, end_block);
9477 _ = try self.wip.brCond(end, body_block, end_block, .none);
93939478
93949479 self.wip.cursor = .{ .block = body_block };
93959480 const elem_abi_align = elem_ty.abiAlignment(zcu);
......@@ -9427,7 +9512,7 @@ pub const FuncGen = struct {
94279512 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);
94289513 const memset_block = try self.wip.block(1, "MemsetTrapSkip");
94299514 const end_block = try self.wip.block(2, "MemsetTrapEnd");
9430 _ = try self.wip.brCond(cond, memset_block, end_block);
9515 _ = try self.wip.brCond(cond, memset_block, end_block, .none);
94319516 self.wip.cursor = .{ .block = memset_block };
94329517 _ = try self.wip.callMemSet(dest_ptr, dest_ptr_align, fill_byte, len, access_kind);
94339518 _ = try self.wip.br(end_block);
......@@ -9462,7 +9547,7 @@ pub const FuncGen = struct {
94629547 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);
94639548 const memcpy_block = try self.wip.block(1, "MemcpyTrapSkip");
94649549 const end_block = try self.wip.block(2, "MemcpyTrapEnd");
9465 _ = try self.wip.brCond(cond, memcpy_block, end_block);
9550 _ = try self.wip.brCond(cond, memcpy_block, end_block, .none);
94669551 self.wip.cursor = .{ .block = memcpy_block };
94679552 _ = try self.wip.callMemCpy(
94689553 dest_ptr,
......@@ -9632,7 +9717,7 @@ pub const FuncGen = struct {
96329717 const valid_block = try self.wip.block(@intCast(names.len), "Valid");
96339718 const invalid_block = try self.wip.block(1, "Invalid");
96349719 const end_block = try self.wip.block(2, "End");
9635 var wip_switch = try self.wip.@"switch"(operand, invalid_block, @intCast(names.len));
9720 var wip_switch = try self.wip.@"switch"(operand, invalid_block, @intCast(names.len), .none);
96369721 defer wip_switch.finish(&self.wip);
96379722
96389723 for (0..names.len) |name_index| {
......@@ -9708,7 +9793,7 @@ pub const FuncGen = struct {
97089793 const named_block = try wip.block(@intCast(enum_type.names.len), "Named");
97099794 const unnamed_block = try wip.block(1, "Unnamed");
97109795 const tag_int_value = wip.arg(0);
9711 var wip_switch = try wip.@"switch"(tag_int_value, unnamed_block, @intCast(enum_type.names.len));
9796 var wip_switch = try wip.@"switch"(tag_int_value, unnamed_block, @intCast(enum_type.names.len), .none);
97129797 defer wip_switch.finish(&wip);
97139798
97149799 for (0..enum_type.names.len) |field_index| {
......@@ -9858,7 +9943,7 @@ pub const FuncGen = struct {
98589943 const cond = try self.wip.icmp(.ult, i, llvm_vector_len, "");
98599944 const loop_then = try self.wip.block(1, "ReduceLoopThen");
98609945
9861 _ = try self.wip.brCond(cond, loop_then, loop_exit);
9946 _ = try self.wip.brCond(cond, loop_then, loop_exit, .none);
98629947
98639948 {
98649949 self.wip.cursor = .{ .block = loop_then };
src/codegen/llvm/Builder.zig+316-101
......@@ -4817,12 +4817,22 @@ pub const Function = struct {
48174817 cond: Value,
48184818 then: Block.Index,
48194819 @"else": Block.Index,
4820 weights: Weights,
4821 pub const Weights = enum(u32) {
4822 // We can do this as metadata indices 0 and 1 are reserved.
4823 none = 0,
4824 unpredictable = 1,
4825 /// These values should be converted to `Metadata` to be used
4826 /// in a `prof` annotation providing branch weights.
4827 _,
4828 };
48204829 };
48214830
48224831 pub const Switch = struct {
48234832 val: Value,
48244833 default: Block.Index,
48254834 cases_len: u32,
4835 weights: BrCond.Weights,
48264836 //case_vals: [cases_len]Constant,
48274837 //case_blocks: [cases_len]Block.Index,
48284838 };
......@@ -4969,7 +4979,8 @@ pub const Function = struct {
49694979 };
49704980 pub const Info = packed struct(u32) {
49714981 call_conv: CallConv,
4972 _: u22 = undefined,
4982 has_op_bundle_cold: bool,
4983 _: u21 = undefined,
49734984 };
49744985 };
49754986
......@@ -5036,6 +5047,7 @@ pub const Function = struct {
50365047 FunctionAttributes,
50375048 Type,
50385049 Value,
5050 Instruction.BrCond.Weights,
50395051 => @enumFromInt(value),
50405052 MemoryAccessInfo,
50415053 Instruction.Alloca.Info,
......@@ -5201,6 +5213,7 @@ pub const WipFunction = struct {
52015213 cond: Value,
52025214 then: Block.Index,
52035215 @"else": Block.Index,
5216 weights: enum { none, unpredictable, then_likely, else_likely },
52045217 ) Allocator.Error!Instruction.Index {
52055218 assert(cond.typeOfWip(self) == .i1);
52065219 try self.ensureUnusedExtraCapacity(1, Instruction.BrCond, 0);
......@@ -5210,6 +5223,22 @@ pub const WipFunction = struct {
52105223 .cond = cond,
52115224 .then = then,
52125225 .@"else" = @"else",
5226 .weights = switch (weights) {
5227 .none => .none,
5228 .unpredictable => .unpredictable,
5229 .then_likely, .else_likely => w: {
5230 const branch_weights_str = try self.builder.metadataString("branch_weights");
5231 const unlikely_const = try self.builder.metadataConstant(try self.builder.intConst(.i32, 1));
5232 const likely_const = try self.builder.metadataConstant(try self.builder.intConst(.i32, 2000));
5233 const weight_vals: [2]Metadata = switch (weights) {
5234 .none, .unpredictable => unreachable,
5235 .then_likely => .{ likely_const, unlikely_const },
5236 .else_likely => .{ unlikely_const, likely_const },
5237 };
5238 const tuple = try self.builder.strTuple(branch_weights_str, &weight_vals);
5239 break :w @enumFromInt(@intFromEnum(tuple));
5240 },
5241 },
52135242 }),
52145243 });
52155244 then.ptr(self).branches += 1;
......@@ -5248,6 +5277,7 @@ pub const WipFunction = struct {
52485277 val: Value,
52495278 default: Block.Index,
52505279 cases_len: u32,
5280 weights: Instruction.BrCond.Weights,
52515281 ) Allocator.Error!WipSwitch {
52525282 try self.ensureUnusedExtraCapacity(1, Instruction.Switch, cases_len * 2);
52535283 const instruction = try self.addInst(null, .{
......@@ -5256,6 +5286,7 @@ pub const WipFunction = struct {
52565286 .val = val,
52575287 .default = default,
52585288 .cases_len = cases_len,
5289 .weights = weights,
52595290 }),
52605291 });
52615292 _ = self.extra.addManyAsSliceAssumeCapacity(cases_len * 2);
......@@ -5895,6 +5926,20 @@ pub const WipFunction = struct {
58955926 callee: Value,
58965927 args: []const Value,
58975928 name: []const u8,
5929 ) Allocator.Error!Value {
5930 return self.callInner(kind, call_conv, function_attributes, ty, callee, args, name, false);
5931 }
5932
5933 fn callInner(
5934 self: *WipFunction,
5935 kind: Instruction.Call.Kind,
5936 call_conv: CallConv,
5937 function_attributes: FunctionAttributes,
5938 ty: Type,
5939 callee: Value,
5940 args: []const Value,
5941 name: []const u8,
5942 has_op_bundle_cold: bool,
58985943 ) Allocator.Error!Value {
58995944 const ret_ty = ty.functionReturn(self.builder);
59005945 assert(ty.isFunction(self.builder));
......@@ -5918,7 +5963,10 @@ pub const WipFunction = struct {
59185963 .tail_fast => .@"tail call fast",
59195964 },
59205965 .data = self.addExtraAssumeCapacity(Instruction.Call{
5921 .info = .{ .call_conv = call_conv },
5966 .info = .{
5967 .call_conv = call_conv,
5968 .has_op_bundle_cold = has_op_bundle_cold,
5969 },
59225970 .attributes = function_attributes,
59235971 .ty = ty,
59245972 .callee = callee,
......@@ -5964,6 +6012,20 @@ pub const WipFunction = struct {
59646012 );
59656013 }
59666014
6015 pub fn callIntrinsicAssumeCold(self: *WipFunction) Allocator.Error!Value {
6016 const intrinsic = try self.builder.getIntrinsic(.assume, &.{});
6017 return self.callInner(
6018 .normal,
6019 CallConv.default,
6020 .none,
6021 intrinsic.typeOf(self.builder),
6022 intrinsic.toValue(self.builder),
6023 &.{try self.builder.intValue(.i1, 1)},
6024 "",
6025 true,
6026 );
6027 }
6028
59676029 pub fn callMemCpy(
59686030 self: *WipFunction,
59696031 dst: Value,
......@@ -6040,7 +6102,7 @@ pub const WipFunction = struct {
60406102
60416103 break :blk metadata;
60426104 },
6043 .constant => |constant| try self.builder.debugConstant(constant),
6105 .constant => |constant| try self.builder.metadataConstant(constant),
60446106 .metadata => |metadata| metadata,
60456107 };
60466108 }
......@@ -6099,6 +6161,7 @@ pub const WipFunction = struct {
60996161 FunctionAttributes,
61006162 Type,
61016163 Value,
6164 Instruction.BrCond.Weights,
61026165 => @intFromEnum(value),
61036166 MemoryAccessInfo,
61046167 Instruction.Alloca.Info,
......@@ -6380,6 +6443,7 @@ pub const WipFunction = struct {
63806443 .cond = instructions.map(extra.cond),
63816444 .then = extra.then,
63826445 .@"else" = extra.@"else",
6446 .weights = extra.weights,
63836447 });
63846448 },
63856449 .call,
......@@ -6522,6 +6586,7 @@ pub const WipFunction = struct {
65226586 .val = instructions.map(extra.data.val),
65236587 .default = extra.data.default,
65246588 .cases_len = extra.data.cases_len,
6589 .weights = extra.data.weights,
65256590 });
65266591 wip_extra.appendSlice(case_vals);
65276592 wip_extra.appendSlice(case_blocks);
......@@ -6744,6 +6809,7 @@ pub const WipFunction = struct {
67446809 FunctionAttributes,
67456810 Type,
67466811 Value,
6812 Instruction.BrCond.Weights,
67476813 => @intFromEnum(value),
67486814 MemoryAccessInfo,
67496815 Instruction.Alloca.Info,
......@@ -6792,6 +6858,7 @@ pub const WipFunction = struct {
67926858 FunctionAttributes,
67936859 Type,
67946860 Value,
6861 Instruction.BrCond.Weights,
67956862 => @enumFromInt(value),
67966863 MemoryAccessInfo,
67976864 Instruction.Alloca.Info,
......@@ -7697,6 +7764,7 @@ pub const MetadataString = enum(u32) {
76977764
76987765pub const Metadata = enum(u32) {
76997766 none = 0,
7767 empty_tuple = 1,
77007768 _,
77017769
77027770 const first_forward_reference = 1 << 29;
......@@ -7734,6 +7802,7 @@ pub const Metadata = enum(u32) {
77347802 enumerator_signed_negative,
77357803 subrange,
77367804 tuple,
7805 str_tuple,
77377806 module_flag,
77387807 expression,
77397808 local_var,
......@@ -7779,6 +7848,7 @@ pub const Metadata = enum(u32) {
77797848 .enumerator_signed_negative,
77807849 .subrange,
77817850 .tuple,
7851 .str_tuple,
77827852 .module_flag,
77837853 .local_var,
77847854 .parameter,
......@@ -8043,6 +8113,13 @@ pub const Metadata = enum(u32) {
80438113 // elements: [elements_len]Metadata
80448114 };
80458115
8116 pub const StrTuple = struct {
8117 str: MetadataString,
8118 elements_len: u32,
8119
8120 // elements: [elements_len]Metadata
8121 };
8122
80468123 pub const ModuleFlag = struct {
80478124 behavior: Metadata,
80488125 name: MetadataString,
......@@ -8355,7 +8432,7 @@ pub const Metadata = enum(u32) {
83558432};
83568433
83578434pub fn init(options: Options) Allocator.Error!Builder {
8358 var self = Builder{
8435 var self: Builder = .{
83598436 .gpa = options.allocator,
83608437 .strip = options.strip,
83618438
......@@ -8454,7 +8531,9 @@ pub fn init(options: Options) Allocator.Error!Builder {
84548531 assert(try self.intConst(.i32, 0) == .@"0");
84558532 assert(try self.intConst(.i32, 1) == .@"1");
84568533 assert(try self.noneConst(.token) == .none);
8457 if (!self.strip) assert(try self.debugNone() == .none);
8534
8535 assert(try self.metadataNone() == .none);
8536 assert(try self.metadataTuple(&.{}) == .empty_tuple);
84588537
84598538 try self.metadata_string_indices.append(self.gpa, 0);
84608539 assert(try self.metadataString("") == .none);
......@@ -9683,6 +9762,13 @@ pub fn printUnbuffered(
96839762 extra.then.toInst(&function).fmt(function_index, self),
96849763 extra.@"else".toInst(&function).fmt(function_index, self),
96859764 });
9765 switch (extra.weights) {
9766 .none => {},
9767 .unpredictable => try writer.writeAll(", !unpredictable !{}"),
9768 _ => try writer.print("{}", .{
9769 try metadata_formatter.fmt(", !prof ", @as(Metadata, @enumFromInt(@intFromEnum(extra.weights)))),
9770 }),
9771 }
96869772 },
96879773 .call,
96889774 .@"call fast",
......@@ -9727,6 +9813,9 @@ pub fn printUnbuffered(
97279813 });
97289814 }
97299815 try writer.writeByte(')');
9816 if (extra.data.info.has_op_bundle_cold) {
9817 try writer.writeAll(" [ \"cold\"() ]");
9818 }
97309819 const call_function_attributes = extra.data.attributes.func(self);
97319820 if (call_function_attributes != .none) try writer.print(" #{d}", .{
97329821 (try attribute_groups.getOrPutValue(
......@@ -9937,6 +10026,13 @@ pub fn printUnbuffered(
993710026 },
993810027 );
993910028 try writer.writeAll(" ]");
10029 switch (extra.data.weights) {
10030 .none => {},
10031 .unpredictable => try writer.writeAll(", !unpredictable !{}"),
10032 _ => try writer.print("{}", .{
10033 try metadata_formatter.fmt(", !prof ", @as(Metadata, @enumFromInt(@intFromEnum(extra.data.weights)))),
10034 }),
10035 }
994010036 },
994110037 .va_arg => |tag| {
994210038 const extra = function.extraData(Function.Instruction.VaArg, instruction.data);
......@@ -10285,6 +10381,17 @@ pub fn printUnbuffered(
1028510381 });
1028610382 try writer.writeAll("}\n");
1028710383 },
10384 .str_tuple => {
10385 var extra = self.metadataExtraDataTrail(Metadata.StrTuple, metadata_item.data);
10386 const elements = extra.trail.next(extra.data.elements_len, Metadata, self);
10387 try writer.print("!{{{[str]%}", .{
10388 .str = try metadata_formatter.fmt("", extra.data.str),
10389 });
10390 for (elements) |element| try writer.print("{[element]%}", .{
10391 .element = try metadata_formatter.fmt("", element),
10392 });
10393 try writer.writeAll("}\n");
10394 },
1028810395 .module_flag => {
1028910396 const extra = self.metadataExtraData(Metadata.ModuleFlag, metadata_item.data);
1029010397 try writer.print("!{{{[behavior]%}{[name]%}{[constant]%}}}\n", .{
......@@ -11797,9 +11904,9 @@ pub fn debugNamed(self: *Builder, name: MetadataString, operands: []const Metada
1179711904 self.debugNamedAssumeCapacity(name, operands);
1179811905}
1179911906
11800fn debugNone(self: *Builder) Allocator.Error!Metadata {
11907fn metadataNone(self: *Builder) Allocator.Error!Metadata {
1180111908 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);
11802 return self.debugNoneAssumeCapacity();
11909 return self.metadataNoneAssumeCapacity();
1180311910}
1180411911
1180511912pub fn debugFile(
......@@ -12088,12 +12195,21 @@ pub fn debugExpression(
1208812195 return self.debugExpressionAssumeCapacity(elements);
1208912196}
1209012197
12091pub fn debugTuple(
12198pub fn metadataTuple(
1209212199 self: *Builder,
1209312200 elements: []const Metadata,
1209412201) Allocator.Error!Metadata {
1209512202 try self.ensureUnusedMetadataCapacity(1, Metadata.Tuple, elements.len);
12096 return self.debugTupleAssumeCapacity(elements);
12203 return self.metadataTupleAssumeCapacity(elements);
12204}
12205
12206pub fn strTuple(
12207 self: *Builder,
12208 str: MetadataString,
12209 elements: []const Metadata,
12210) Allocator.Error!Metadata {
12211 try self.ensureUnusedMetadataCapacity(1, Metadata.StrTuple, elements.len);
12212 return self.strTupleAssumeCapacity(str, elements);
1209712213}
1209812214
1209912215pub fn debugModuleFlag(
......@@ -12164,9 +12280,9 @@ pub fn debugGlobalVarExpression(
1216412280 return self.debugGlobalVarExpressionAssumeCapacity(variable, expression);
1216512281}
1216612282
12167pub fn debugConstant(self: *Builder, value: Constant) Allocator.Error!Metadata {
12283pub fn metadataConstant(self: *Builder, value: Constant) Allocator.Error!Metadata {
1216812284 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);
12169 return self.debugConstantAssumeCapacity(value);
12285 return self.metadataConstantAssumeCapacity(value);
1217012286}
1217112287
1217212288pub fn debugForwardReferenceSetType(self: *Builder, fwd_ref: Metadata, ty: Metadata) void {
......@@ -12261,8 +12377,7 @@ fn debugNamedAssumeCapacity(self: *Builder, name: MetadataString, operands: []co
1226112377 };
1226212378}
1226312379
12264pub fn debugNoneAssumeCapacity(self: *Builder) Metadata {
12265 assert(!self.strip);
12380pub fn metadataNoneAssumeCapacity(self: *Builder) Metadata {
1226612381 return self.metadataSimpleAssumeCapacity(.none, .{});
1226712382}
1226812383
......@@ -12738,11 +12853,10 @@ fn debugExpressionAssumeCapacity(
1273812853 return @enumFromInt(gop.index);
1273912854}
1274012855
12741fn debugTupleAssumeCapacity(
12856fn metadataTupleAssumeCapacity(
1274212857 self: *Builder,
1274312858 elements: []const Metadata,
1274412859) Metadata {
12745 assert(!self.strip);
1274612860 const Key = struct {
1274712861 elements: []const Metadata,
1274812862 };
......@@ -12785,6 +12899,55 @@ fn debugTupleAssumeCapacity(
1278512899 return @enumFromInt(gop.index);
1278612900}
1278712901
12902fn strTupleAssumeCapacity(
12903 self: *Builder,
12904 str: MetadataString,
12905 elements: []const Metadata,
12906) Metadata {
12907 const Key = struct {
12908 str: MetadataString,
12909 elements: []const Metadata,
12910 };
12911 const Adapter = struct {
12912 builder: *const Builder,
12913 pub fn hash(_: @This(), key: Key) u32 {
12914 var hasher = comptime std.hash.Wyhash.init(std.hash.uint32(@intFromEnum(Metadata.Tag.tuple)));
12915 hasher.update(std.mem.sliceAsBytes(key.elements));
12916 return @truncate(hasher.final());
12917 }
12918
12919 pub fn eql(ctx: @This(), lhs_key: Key, _: void, rhs_index: usize) bool {
12920 if (.str_tuple != ctx.builder.metadata_items.items(.tag)[rhs_index]) return false;
12921 const rhs_data = ctx.builder.metadata_items.items(.data)[rhs_index];
12922 var rhs_extra = ctx.builder.metadataExtraDataTrail(Metadata.StrTuple, rhs_data);
12923 return rhs_extra.data.str == lhs_key.str and std.mem.eql(
12924 Metadata,
12925 lhs_key.elements,
12926 rhs_extra.trail.next(rhs_extra.data.elements_len, Metadata, ctx.builder),
12927 );
12928 }
12929 };
12930
12931 const gop = self.metadata_map.getOrPutAssumeCapacityAdapted(
12932 Key{ .str = str, .elements = elements },
12933 Adapter{ .builder = self },
12934 );
12935
12936 if (!gop.found_existing) {
12937 gop.key_ptr.* = {};
12938 gop.value_ptr.* = {};
12939 self.metadata_items.appendAssumeCapacity(.{
12940 .tag = .str_tuple,
12941 .data = self.addMetadataExtraAssumeCapacity(Metadata.StrTuple{
12942 .str = str,
12943 .elements_len = @intCast(elements.len),
12944 }),
12945 });
12946 self.metadata_extra.appendSliceAssumeCapacity(@ptrCast(elements));
12947 }
12948 return @enumFromInt(gop.index);
12949}
12950
1278812951fn debugModuleFlagAssumeCapacity(
1278912952 self: *Builder,
1279012953 behavior: Metadata,
......@@ -12875,8 +13038,7 @@ fn debugGlobalVarExpressionAssumeCapacity(
1287513038 });
1287613039}
1287713040
12878fn debugConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata {
12879 assert(!self.strip);
13041fn metadataConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata {
1288013042 const Adapter = struct {
1288113043 builder: *const Builder,
1288213044 pub fn hash(_: @This(), key: Constant) u32 {
......@@ -13755,15 +13917,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1375513917 }
1375613918
1375713919 // METADATA_KIND_BLOCK
13758 if (!self.strip) {
13920 {
1375913921 const MetadataKindBlock = ir.MetadataKindBlock;
1376013922 var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
1376113923
13762 inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| {
13763 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
13764 .id = field.value,
13765 .name = field.name,
13766 });
13924 inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| {
13925 // don't include `dbg` in stripped functions
13926 if (!(self.strip and std.mem.eql(u8, field.name, "dbg"))) {
13927 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
13928 .id = field.value,
13929 .name = field.name,
13930 });
13931 }
1376713932 }
1376813933
1376913934 try metadata_kind_block.end();
......@@ -13808,14 +13973,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1380813973 const metadata_adapter = MetadataAdapter.init(self, constant_adapter);
1380913974
1381013975 // METADATA_BLOCK
13811 if (!self.strip) {
13976 {
1381213977 const MetadataBlock = ir.MetadataBlock;
1381313978 var metadata_block = try module_block.enterSubBlock(MetadataBlock, true);
1381413979
1381513980 const MetadataBlockWriter = @TypeOf(metadata_block);
1381613981
1381713982 // Emit all MetadataStrings
13818 {
13983 if (self.metadata_string_map.count() > 1) {
1381913984 const strings_offset, const strings_size = blk: {
1382013985 var strings_offset: u32 = 0;
1382113986 var strings_size: u32 = 0;
......@@ -14046,7 +14211,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1404614211 else
1404714212 -%val << 1 | 1);
1404814213 }
14049 try metadata_block.writeUnabbrev(MetadataBlock.Enumerator.id, record.items);
14214 try metadata_block.writeUnabbrev(@intFromEnum(MetadataBlock.Enumerator.id), record.items);
1405014215 continue;
1405114216 };
1405214217 try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{
......@@ -14085,6 +14250,22 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1408514250 .elements = elements,
1408614251 }, metadata_adapter);
1408714252 },
14253 .str_tuple => {
14254 var extra = self.metadataExtraDataTrail(Metadata.StrTuple, data);
14255
14256 const elements = extra.trail.next(extra.data.elements_len, Metadata, self);
14257
14258 const all_elems = try self.gpa.alloc(Metadata, elements.len + 1);
14259 defer self.gpa.free(all_elems);
14260 all_elems[0] = @enumFromInt(metadata_adapter.getMetadataStringIndex(extra.data.str));
14261 for (elements, all_elems[1..]) |elem, *out_elem| {
14262 out_elem.* = @enumFromInt(metadata_adapter.getMetadataIndex(elem));
14263 }
14264
14265 try metadata_block.writeAbbrev(MetadataBlock.Node{
14266 .elements = all_elems,
14267 });
14268 },
1408814269 .module_flag => {
1408914270 const extra = self.metadataExtraData(Metadata.ModuleFlag, data);
1409014271 try metadata_block.writeAbbrev(MetadataBlock.Node{
......@@ -14177,7 +14358,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1417714358
1417814359 try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{
1417914360 .value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())),
14180 .kind = ir.MetadataKind.dbg,
14361 .kind = .dbg,
1418114362 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1),
1418214363 });
1418314364 }
......@@ -14186,6 +14367,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1418614367 try metadata_block.end();
1418714368 }
1418814369
14370 // OPERAND_BUNDLE_TAGS_BLOCK
14371 {
14372 const OperandBundleTags = ir.OperandBundleTags;
14373 var operand_bundle_tags_block = try module_block.enterSubBlock(OperandBundleTags, true);
14374
14375 try operand_bundle_tags_block.writeAbbrev(OperandBundleTags.OperandBundleTag{
14376 .tag = "cold",
14377 });
14378
14379 try operand_bundle_tags_block.end();
14380 }
14381
1418914382 // Block info
1419014383 {
1419114384 const BlockInfo = ir.BlockInfo;
......@@ -14220,20 +14413,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1422014413 constant_adapter: ConstantAdapter,
1422114414 metadata_adapter: MetadataAdapter,
1422214415 func: *const Function,
14223 instruction_index: u32 = 0,
14224
14225 pub fn init(
14226 const_adapter: ConstantAdapter,
14227 meta_adapter: MetadataAdapter,
14228 func: *const Function,
14229 ) @This() {
14230 return .{
14231 .constant_adapter = const_adapter,
14232 .metadata_adapter = meta_adapter,
14233 .func = func,
14234 .instruction_index = 0,
14235 };
14236 }
14416 instruction_index: Function.Instruction.Index,
1423714417
1423814418 pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) {
1423914419 _ = field_name;
......@@ -14254,7 +14434,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1425414434 .instruction => |instruction| instruction.valueIndex(adapter.func) + adapter.firstInstr(),
1425514435 .constant => |constant| adapter.constant_adapter.getConstantIndex(constant),
1425614436 .metadata => |metadata| {
14257 assert(!adapter.func.strip);
1425814437 const real_metadata = metadata.unwrap(adapter.metadata_adapter.builder);
1425914438 if (@intFromEnum(real_metadata) < Metadata.first_local_metadata)
1426014439 return adapter.metadata_adapter.getMetadataIndex(real_metadata) - 1;
......@@ -14282,19 +14461,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1428214461 }
1428314462
1428414463 pub fn offset(adapter: @This()) u32 {
14285 return @as(
14286 Function.Instruction.Index,
14287 @enumFromInt(adapter.instruction_index),
14288 ).valueIndex(adapter.func) + adapter.firstInstr();
14464 return adapter.instruction_index.valueIndex(adapter.func) + adapter.firstInstr();
1428914465 }
1429014466
1429114467 fn firstInstr(adapter: @This()) u32 {
1429214468 return adapter.constant_adapter.numConstants();
1429314469 }
14294
14295 pub fn next(adapter: *@This()) void {
14296 adapter.instruction_index += 1;
14297 }
1429814470 };
1429914471
1430014472 for (self.functions.items, 0..) |func, func_index| {
......@@ -14307,7 +14479,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1430714479
1430814480 try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len });
1430914481
14310 var adapter = FunctionAdapter.init(constant_adapter, metadata_adapter, &func);
14482 var adapter: FunctionAdapter = .{
14483 .constant_adapter = constant_adapter,
14484 .metadata_adapter = metadata_adapter,
14485 .func = &func,
14486 .instruction_index = @enumFromInt(0),
14487 };
1431114488
1431214489 // Emit function level metadata block
1431314490 if (!func.strip and func.debug_values.len > 0) {
......@@ -14330,21 +14507,27 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1433014507 var has_location = false;
1433114508
1433214509 var block_incoming_len: u32 = undefined;
14333 for (0..func.instructions.len) |instr_index| {
14334 const tag = tags[instr_index];
14335
14510 for (tags, datas, 0..) |tag, data, instr_index| {
14511 adapter.instruction_index = @enumFromInt(instr_index);
1433614512 record.clearRetainingCapacity();
1433714513
1433814514 switch (tag) {
14339 .block => block_incoming_len = datas[instr_index],
14340 .arg => {},
14515 .arg => continue,
14516 .block => {
14517 block_incoming_len = data;
14518 continue;
14519 },
1434114520 .@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}),
1434214521 .call,
1434314522 .@"musttail call",
1434414523 .@"notail call",
1434514524 .@"tail call",
1434614525 => |kind| {
14347 var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);
14526 var extra = func.extraDataTrail(Function.Instruction.Call, data);
14527
14528 if (extra.data.info.has_op_bundle_cold) {
14529 try function_block.writeAbbrev(FunctionBlock.ColdOperandBundle{});
14530 }
1434814531
1434914532 const call_conv = extra.data.info.call_conv;
1435014533 const args = extra.trail.next(extra.data.args_len, Value, &func);
......@@ -14367,7 +14550,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1436714550 .@"notail call fast",
1436814551 .@"tail call fast",
1436914552 => |kind| {
14370 var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);
14553 var extra = func.extraDataTrail(Function.Instruction.Call, data);
14554
14555 if (extra.data.info.has_op_bundle_cold) {
14556 try function_block.writeAbbrev(FunctionBlock.ColdOperandBundle{});
14557 }
1437114558
1437214559 const call_conv = extra.data.info.call_conv;
1437314560 const args = extra.trail.next(extra.data.args_len, Value, &func);
......@@ -14405,7 +14592,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1440514592 .srem,
1440614593 .ashr,
1440714594 => |kind| {
14408 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14595 const extra = func.extraData(Function.Instruction.Binary, data);
1440914596 try function_block.writeAbbrev(FunctionBlock.Binary{
1441014597 .opcode = kind.toBinaryOpcode(),
1441114598 .lhs = adapter.getOffsetValueIndex(extra.lhs),
......@@ -14417,7 +14604,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1441714604 .@"lshr exact",
1441814605 .@"ashr exact",
1441914606 => |kind| {
14420 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14607 const extra = func.extraData(Function.Instruction.Binary, data);
1442114608 try function_block.writeAbbrev(FunctionBlock.BinaryExact{
1442214609 .opcode = kind.toBinaryOpcode(),
1442314610 .lhs = adapter.getOffsetValueIndex(extra.lhs),
......@@ -14437,7 +14624,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1443714624 .@"shl nuw",
1443814625 .@"shl nuw nsw",
1443914626 => |kind| {
14440 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14627 const extra = func.extraData(Function.Instruction.Binary, data);
1444114628 try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{
1444214629 .opcode = kind.toBinaryOpcode(),
1444314630 .lhs = adapter.getOffsetValueIndex(extra.lhs),
......@@ -14468,7 +14655,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1446814655 .@"frem fast",
1446914656 .@"fsub fast",
1447014657 => |kind| {
14471 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14658 const extra = func.extraData(Function.Instruction.Binary, data);
1447214659 try function_block.writeAbbrev(FunctionBlock.BinaryFast{
1447314660 .opcode = kind.toBinaryOpcode(),
1447414661 .lhs = adapter.getOffsetValueIndex(extra.lhs),
......@@ -14479,7 +14666,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1447914666 .alloca,
1448014667 .@"alloca inalloca",
1448114668 => |kind| {
14482 const extra = func.extraData(Function.Instruction.Alloca, datas[instr_index]);
14669 const extra = func.extraData(Function.Instruction.Alloca, data);
1448314670 const alignment = extra.info.alignment.toLlvm();
1448414671 try function_block.writeAbbrev(FunctionBlock.Alloca{
1448514672 .inst_type = extra.type,
......@@ -14508,7 +14695,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1450814695 .sext,
1450914696 .zext,
1451014697 => |kind| {
14511 const extra = func.extraData(Function.Instruction.Cast, datas[instr_index]);
14698 const extra = func.extraData(Function.Instruction.Cast, data);
1451214699 try function_block.writeAbbrev(FunctionBlock.Cast{
1451314700 .val = adapter.getOffsetValueIndex(extra.val),
1451414701 .type_index = extra.type,
......@@ -14542,7 +14729,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1454214729 .@"icmp ule",
1454314730 .@"icmp ult",
1454414731 => |kind| {
14545 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14732 const extra = func.extraData(Function.Instruction.Binary, data);
1454614733 try function_block.writeAbbrev(FunctionBlock.Cmp{
1454714734 .lhs = adapter.getOffsetValueIndex(extra.lhs),
1454814735 .rhs = adapter.getOffsetValueIndex(extra.rhs),
......@@ -14566,7 +14753,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1456614753 .@"fcmp fast une",
1456714754 .@"fcmp fast uno",
1456814755 => |kind| {
14569 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
14756 const extra = func.extraData(Function.Instruction.Binary, data);
1457014757 try function_block.writeAbbrev(FunctionBlock.CmpFast{
1457114758 .lhs = adapter.getOffsetValueIndex(extra.lhs),
1457214759 .rhs = adapter.getOffsetValueIndex(extra.rhs),
......@@ -14575,14 +14762,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1457514762 });
1457614763 },
1457714764 .fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{
14578 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
14765 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
1457914766 }),
1458014767 .@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{
14581 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
14768 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
1458214769 .fast_math = FastMath.fast,
1458314770 }),
1458414771 .extractvalue => {
14585 var extra = func.extraDataTrail(Function.Instruction.ExtractValue, datas[instr_index]);
14772 var extra = func.extraDataTrail(Function.Instruction.ExtractValue, data);
1458614773 const indices = extra.trail.next(extra.data.indices_len, u32, &func);
1458714774 try function_block.writeAbbrev(FunctionBlock.ExtractValue{
1458814775 .val = adapter.getOffsetValueIndex(extra.data.val),
......@@ -14590,7 +14777,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1459014777 });
1459114778 },
1459214779 .insertvalue => {
14593 var extra = func.extraDataTrail(Function.Instruction.InsertValue, datas[instr_index]);
14780 var extra = func.extraDataTrail(Function.Instruction.InsertValue, data);
1459414781 const indices = extra.trail.next(extra.data.indices_len, u32, &func);
1459514782 try function_block.writeAbbrev(FunctionBlock.InsertValue{
1459614783 .val = adapter.getOffsetValueIndex(extra.data.val),
......@@ -14599,14 +14786,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1459914786 });
1460014787 },
1460114788 .extractelement => {
14602 const extra = func.extraData(Function.Instruction.ExtractElement, datas[instr_index]);
14789 const extra = func.extraData(Function.Instruction.ExtractElement, data);
1460314790 try function_block.writeAbbrev(FunctionBlock.ExtractElement{
1460414791 .val = adapter.getOffsetValueIndex(extra.val),
1460514792 .index = adapter.getOffsetValueIndex(extra.index),
1460614793 });
1460714794 },
1460814795 .insertelement => {
14609 const extra = func.extraData(Function.Instruction.InsertElement, datas[instr_index]);
14796 const extra = func.extraData(Function.Instruction.InsertElement, data);
1461014797 try function_block.writeAbbrev(FunctionBlock.InsertElement{
1461114798 .val = adapter.getOffsetValueIndex(extra.val),
1461214799 .elem = adapter.getOffsetValueIndex(extra.elem),
......@@ -14614,7 +14801,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1461414801 });
1461514802 },
1461614803 .select => {
14617 const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);
14804 const extra = func.extraData(Function.Instruction.Select, data);
1461814805 try function_block.writeAbbrev(FunctionBlock.Select{
1461914806 .lhs = adapter.getOffsetValueIndex(extra.lhs),
1462014807 .rhs = adapter.getOffsetValueIndex(extra.rhs),
......@@ -14622,7 +14809,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1462214809 });
1462314810 },
1462414811 .@"select fast" => {
14625 const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);
14812 const extra = func.extraData(Function.Instruction.Select, data);
1462614813 try function_block.writeAbbrev(FunctionBlock.SelectFast{
1462714814 .lhs = adapter.getOffsetValueIndex(extra.lhs),
1462814815 .rhs = adapter.getOffsetValueIndex(extra.rhs),
......@@ -14631,7 +14818,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1463114818 });
1463214819 },
1463314820 .shufflevector => {
14634 const extra = func.extraData(Function.Instruction.ShuffleVector, datas[instr_index]);
14821 const extra = func.extraData(Function.Instruction.ShuffleVector, data);
1463514822 try function_block.writeAbbrev(FunctionBlock.ShuffleVector{
1463614823 .lhs = adapter.getOffsetValueIndex(extra.lhs),
1463714824 .rhs = adapter.getOffsetValueIndex(extra.rhs),
......@@ -14641,7 +14828,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1464114828 .getelementptr,
1464214829 .@"getelementptr inbounds",
1464314830 => |kind| {
14644 var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, datas[instr_index]);
14831 var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, data);
1464514832 const indices = extra.trail.next(extra.data.indices_len, Value, &func);
1464614833 try function_block.writeAbbrevAdapted(
1464714834 FunctionBlock.GetElementPtr{
......@@ -14654,7 +14841,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1465414841 );
1465514842 },
1465614843 .load => {
14657 const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);
14844 const extra = func.extraData(Function.Instruction.Load, data);
1465814845 try function_block.writeAbbrev(FunctionBlock.Load{
1465914846 .ptr = adapter.getOffsetValueIndex(extra.ptr),
1466014847 .ty = extra.type,
......@@ -14663,7 +14850,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1466314850 });
1466414851 },
1466514852 .@"load atomic" => {
14666 const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);
14853 const extra = func.extraData(Function.Instruction.Load, data);
1466714854 try function_block.writeAbbrev(FunctionBlock.LoadAtomic{
1466814855 .ptr = adapter.getOffsetValueIndex(extra.ptr),
1466914856 .ty = extra.type,
......@@ -14674,7 +14861,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1467414861 });
1467514862 },
1467614863 .store => {
14677 const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);
14864 const extra = func.extraData(Function.Instruction.Store, data);
1467814865 try function_block.writeAbbrev(FunctionBlock.Store{
1467914866 .ptr = adapter.getOffsetValueIndex(extra.ptr),
1468014867 .val = adapter.getOffsetValueIndex(extra.val),
......@@ -14683,7 +14870,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1468314870 });
1468414871 },
1468514872 .@"store atomic" => {
14686 const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);
14873 const extra = func.extraData(Function.Instruction.Store, data);
1468714874 try function_block.writeAbbrev(FunctionBlock.StoreAtomic{
1468814875 .ptr = adapter.getOffsetValueIndex(extra.ptr),
1468914876 .val = adapter.getOffsetValueIndex(extra.val),
......@@ -14695,11 +14882,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1469514882 },
1469614883 .br => {
1469714884 try function_block.writeAbbrev(FunctionBlock.BrUnconditional{
14698 .block = datas[instr_index],
14885 .block = data,
1469914886 });
1470014887 },
1470114888 .br_cond => {
14702 const extra = func.extraData(Function.Instruction.BrCond, datas[instr_index]);
14889 const extra = func.extraData(Function.Instruction.BrCond, data);
1470314890 try function_block.writeAbbrev(FunctionBlock.BrConditional{
1470414891 .then_block = @intFromEnum(extra.then),
1470514892 .else_block = @intFromEnum(extra.@"else"),
......@@ -14707,7 +14894,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1470714894 });
1470814895 },
1470914896 .@"switch" => {
14710 var extra = func.extraDataTrail(Function.Instruction.Switch, datas[instr_index]);
14897 var extra = func.extraDataTrail(Function.Instruction.Switch, data);
1471114898
1471214899 try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2);
1471314900
......@@ -14730,7 +14917,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1473014917 try function_block.writeUnabbrev(12, record.items);
1473114918 },
1473214919 .va_arg => {
14733 const extra = func.extraData(Function.Instruction.VaArg, datas[instr_index]);
14920 const extra = func.extraData(Function.Instruction.VaArg, data);
1473414921 try function_block.writeAbbrev(FunctionBlock.VaArg{
1473514922 .list_type = extra.list.typeOf(@enumFromInt(func_index), self),
1473614923 .list = adapter.getOffsetValueIndex(extra.list),
......@@ -14740,7 +14927,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1474014927 .phi,
1474114928 .@"phi fast",
1474214929 => |kind| {
14743 var extra = func.extraDataTrail(Function.Instruction.Phi, datas[instr_index]);
14930 var extra = func.extraDataTrail(Function.Instruction.Phi, data);
1474414931 const vals = extra.trail.next(block_incoming_len, Value, &func);
1474514932 const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func);
1474614933
......@@ -14764,11 +14951,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1476414951 try function_block.writeUnabbrev(16, record.items);
1476514952 },
1476614953 .ret => try function_block.writeAbbrev(FunctionBlock.Ret{
14767 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
14954 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
1476814955 }),
1476914956 .@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}),
1477014957 .atomicrmw => {
14771 const extra = func.extraData(Function.Instruction.AtomicRmw, datas[instr_index]);
14958 const extra = func.extraData(Function.Instruction.AtomicRmw, data);
1477214959 try function_block.writeAbbrev(FunctionBlock.AtomicRmw{
1477314960 .ptr = adapter.getOffsetValueIndex(extra.ptr),
1477414961 .val = adapter.getOffsetValueIndex(extra.val),
......@@ -14782,7 +14969,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1478214969 .cmpxchg,
1478314970 .@"cmpxchg weak",
1478414971 => |kind| {
14785 const extra = func.extraData(Function.Instruction.CmpXchg, datas[instr_index]);
14972 const extra = func.extraData(Function.Instruction.CmpXchg, data);
1478614973
1478714974 try function_block.writeAbbrev(FunctionBlock.CmpXchg{
1478814975 .ptr = adapter.getOffsetValueIndex(extra.ptr),
......@@ -14797,7 +14984,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1479714984 });
1479814985 },
1479914986 .fence => {
14800 const info: MemoryAccessInfo = @bitCast(datas[instr_index]);
14987 const info: MemoryAccessInfo = @bitCast(data);
1480114988 try function_block.writeAbbrev(FunctionBlock.Fence{
1480214989 .ordering = info.success_ordering,
1480314990 .sync_scope = info.sync_scope,
......@@ -14806,7 +14993,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1480614993 }
1480714994
1480814995 if (!func.strip) {
14809 if (func.debug_locations.get(@enumFromInt(instr_index))) |debug_location| {
14996 if (func.debug_locations.get(adapter.instruction_index)) |debug_location| {
1481014997 switch (debug_location) {
1481114998 .no_location => has_location = false,
1481214999 .location => |location| {
......@@ -14823,8 +15010,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1482315010 try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{});
1482415011 }
1482515012 }
14826
14827 adapter.next();
1482815013 }
1482915014
1483015015 // VALUE_SYMTAB
......@@ -14850,18 +15035,48 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1485015035 }
1485115036
1485215037 // METADATA_ATTACHMENT_BLOCK
14853 if (!func.strip) blk: {
14854 const dbg = func.global.ptrConst(self).dbg;
14855
14856 if (dbg == .none) break :blk;
14857
15038 {
1485815039 const MetadataAttachmentBlock = ir.MetadataAttachmentBlock;
1485915040 var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false);
1486015041
14861 try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{
14862 .kind = ir.MetadataKind.dbg,
14863 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),
14864 });
15042 dbg: {
15043 if (func.strip) break :dbg;
15044 const dbg = func.global.ptrConst(self).dbg;
15045 if (dbg == .none) break :dbg;
15046 try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentGlobalSingle{
15047 .kind = .dbg,
15048 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),
15049 });
15050 }
15051
15052 var instr_index: u32 = 0;
15053 for (func.instructions.items(.tag), func.instructions.items(.data)) |instr_tag, data| switch (instr_tag) {
15054 .arg, .block => {}, // not an actual instruction
15055 else => {
15056 instr_index += 1;
15057 },
15058 .br_cond, .@"switch" => {
15059 const weights = switch (instr_tag) {
15060 .br_cond => func.extraData(Function.Instruction.BrCond, data).weights,
15061 .@"switch" => func.extraData(Function.Instruction.Switch, data).weights,
15062 else => unreachable,
15063 };
15064 switch (weights) {
15065 .none => {},
15066 .unpredictable => try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{
15067 .inst = instr_index,
15068 .kind = .unpredictable,
15069 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(.empty_tuple) - 1),
15070 }),
15071 _ => try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{
15072 .inst = instr_index,
15073 .kind = .prof,
15074 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(@enumFromInt(@intFromEnum(weights))) - 1),
15075 }),
15076 }
15077 instr_index += 1;
15078 },
15079 };
1486515080
1486615081 try metadata_attach_block.end();
1486715082 }
src/codegen/llvm/ir.zig+198-29
......@@ -20,8 +20,142 @@ const ColumnAbbrev = AbbrevOp{ .vbr = 8 };
2020
2121const BlockAbbrev = AbbrevOp{ .vbr = 6 };
2222
23pub const MetadataKind = enum(u1) {
23/// Unused tags are commented out so that they are omitted in the generated
24/// bitcode, which scans over this enum using reflection.
25pub const FixedMetadataKind = enum(u8) {
2426 dbg = 0,
27 //tbaa = 1,
28 prof = 2,
29 //fpmath = 3,
30 //range = 4,
31 //@"tbaa.struct" = 5,
32 //@"invariant.load" = 6,
33 //@"alias.scope" = 7,
34 //@"noalias" = 8,
35 //nontemporal = 9,
36 //@"llvm.mem.parallel_loop_access" = 10,
37 //nonnull = 11,
38 //dereferenceable = 12,
39 //dereferenceable_or_null = 13,
40 //@"make.implicit" = 14,
41 unpredictable = 15,
42 //@"invariant.group" = 16,
43 //@"align" = 17,
44 //@"llvm.loop" = 18,
45 //type = 19,
46 //section_prefix = 20,
47 //absolute_symbol = 21,
48 //associated = 22,
49 //callees = 23,
50 //irr_loop = 24,
51 //@"llvm.access.group" = 25,
52 //callback = 26,
53 //@"llvm.preserve.access.index" = 27,
54 //vcall_visibility = 28,
55 //noundef = 29,
56 //annotation = 30,
57 //nosanitize = 31,
58 //func_sanitize = 32,
59 //exclude = 33,
60 //memprof = 34,
61 //callsite = 35,
62 //kcfi_type = 36,
63 //pcsections = 37,
64 //DIAssignID = 38,
65 //@"coro.outside.frame" = 39,
66};
67
68pub const MetadataCode = enum(u8) {
69 /// MDSTRING: [values]
70 STRING_OLD = 1,
71 /// VALUE: [type num, value num]
72 VALUE = 2,
73 /// NODE: [n x md num]
74 NODE = 3,
75 /// STRING: [values]
76 NAME = 4,
77 /// DISTINCT_NODE: [n x md num]
78 DISTINCT_NODE = 5,
79 /// [n x [id, name]]
80 KIND = 6,
81 /// [distinct, line, col, scope, inlined-at?]
82 LOCATION = 7,
83 /// OLD_NODE: [n x (type num, value num)]
84 OLD_NODE = 8,
85 /// OLD_FN_NODE: [n x (type num, value num)]
86 OLD_FN_NODE = 9,
87 /// NAMED_NODE: [n x mdnodes]
88 NAMED_NODE = 10,
89 /// [m x [value, [n x [id, mdnode]]]
90 ATTACHMENT = 11,
91 /// [distinct, tag, vers, header, n x md num]
92 GENERIC_DEBUG = 12,
93 /// [distinct, count, lo]
94 SUBRANGE = 13,
95 /// [isUnsigned|distinct, value, name]
96 ENUMERATOR = 14,
97 /// [distinct, tag, name, size, align, enc]
98 BASIC_TYPE = 15,
99 /// [distinct, filename, directory, checksumkind, checksum]
100 FILE = 16,
101 /// [distinct, ...]
102 DERIVED_TYPE = 17,
103 /// [distinct, ...]
104 COMPOSITE_TYPE = 18,
105 /// [distinct, flags, types, cc]
106 SUBROUTINE_TYPE = 19,
107 /// [distinct, ...]
108 COMPILE_UNIT = 20,
109 /// [distinct, ...]
110 SUBPROGRAM = 21,
111 /// [distinct, scope, file, line, column]
112 LEXICAL_BLOCK = 22,
113 ///[distinct, scope, file, discriminator]
114 LEXICAL_BLOCK_FILE = 23,
115 /// [distinct, scope, file, name, line, exportSymbols]
116 NAMESPACE = 24,
117 /// [distinct, scope, name, type, ...]
118 TEMPLATE_TYPE = 25,
119 /// [distinct, scope, name, type, value, ...]
120 TEMPLATE_VALUE = 26,
121 /// [distinct, ...]
122 GLOBAL_VAR = 27,
123 /// [distinct, ...]
124 LOCAL_VAR = 28,
125 /// [distinct, n x element]
126 EXPRESSION = 29,
127 /// [distinct, name, file, line, ...]
128 OBJC_PROPERTY = 30,
129 /// [distinct, tag, scope, entity, line, name]
130 IMPORTED_ENTITY = 31,
131 /// [distinct, scope, name, ...]
132 MODULE = 32,
133 /// [distinct, macinfo, line, name, value]
134 MACRO = 33,
135 /// [distinct, macinfo, line, file, ...]
136 MACRO_FILE = 34,
137 /// [count, offset] blob([lengths][chars])
138 STRINGS = 35,
139 /// [valueid, n x [id, mdnode]]
140 GLOBAL_DECL_ATTACHMENT = 36,
141 /// [distinct, var, expr]
142 GLOBAL_VAR_EXPR = 37,
143 /// [offset]
144 INDEX_OFFSET = 38,
145 /// [bitpos]
146 INDEX = 39,
147 /// [distinct, scope, name, file, line]
148 LABEL = 40,
149 /// [distinct, name, size, align,...]
150 STRING_TYPE = 41,
151 /// [distinct, scope, name, variable,...]
152 COMMON_BLOCK = 44,
153 /// [distinct, count, lo, up, stride]
154 GENERIC_SUBRANGE = 45,
155 /// [n x [type num, value num]]
156 ARG_LIST = 46,
157 /// [distinct, ...]
158 ASSIGN_ID = 47,
25159};
26160
27161pub const Identification = struct {
......@@ -622,16 +756,29 @@ pub const MetadataAttachmentBlock = struct {
622756 pub const id = 16;
623757
624758 pub const abbrevs = [_]type{
625 AttachmentSingle,
759 AttachmentGlobalSingle,
760 AttachmentInstructionSingle,
626761 };
627762
628 pub const AttachmentSingle = struct {
763 pub const AttachmentGlobalSingle = struct {
629764 pub const ops = [_]AbbrevOp{
630 .{ .literal = 11 },
765 .{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
631766 .{ .fixed = 1 },
632767 MetadataAbbrev,
633768 };
634 kind: MetadataKind,
769 kind: FixedMetadataKind,
770 metadata: Builder.Metadata,
771 };
772
773 pub const AttachmentInstructionSingle = struct {
774 pub const ops = [_]AbbrevOp{
775 .{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
776 ValueAbbrev,
777 .{ .fixed = 5 },
778 MetadataAbbrev,
779 };
780 inst: u32,
781 kind: FixedMetadataKind,
635782 metadata: Builder.Metadata,
636783 };
637784};
......@@ -666,7 +813,7 @@ pub const MetadataBlock = struct {
666813
667814 pub const Strings = struct {
668815 pub const ops = [_]AbbrevOp{
669 .{ .literal = 35 },
816 .{ .literal = @intFromEnum(MetadataCode.STRINGS) },
670817 .{ .vbr = 6 },
671818 .{ .vbr = 6 },
672819 .blob,
......@@ -678,7 +825,7 @@ pub const MetadataBlock = struct {
678825
679826 pub const File = struct {
680827 pub const ops = [_]AbbrevOp{
681 .{ .literal = 16 },
828 .{ .literal = @intFromEnum(MetadataCode.FILE) },
682829 .{ .literal = 0 }, // is distinct
683830 MetadataAbbrev, // filename
684831 MetadataAbbrev, // directory
......@@ -692,7 +839,7 @@ pub const MetadataBlock = struct {
692839
693840 pub const CompileUnit = struct {
694841 pub const ops = [_]AbbrevOp{
695 .{ .literal = 20 },
842 .{ .literal = @intFromEnum(MetadataCode.COMPILE_UNIT) },
696843 .{ .literal = 1 }, // is distinct
697844 .{ .literal = std.dwarf.LANG.C99 }, // source language
698845 MetadataAbbrev, // file
......@@ -726,7 +873,7 @@ pub const MetadataBlock = struct {
726873
727874 pub const Subprogram = struct {
728875 pub const ops = [_]AbbrevOp{
729 .{ .literal = 21 },
876 .{ .literal = @intFromEnum(MetadataCode.SUBPROGRAM) },
730877 .{ .literal = 0b111 }, // is distinct | has sp flags | has flags
731878 MetadataAbbrev, // scope
732879 MetadataAbbrev, // name
......@@ -763,7 +910,7 @@ pub const MetadataBlock = struct {
763910
764911 pub const LexicalBlock = struct {
765912 pub const ops = [_]AbbrevOp{
766 .{ .literal = 22 },
913 .{ .literal = @intFromEnum(MetadataCode.LEXICAL_BLOCK) },
767914 .{ .literal = 0 }, // is distinct
768915 MetadataAbbrev, // scope
769916 MetadataAbbrev, // file
......@@ -779,7 +926,7 @@ pub const MetadataBlock = struct {
779926
780927 pub const Location = struct {
781928 pub const ops = [_]AbbrevOp{
782 .{ .literal = 7 },
929 .{ .literal = @intFromEnum(MetadataCode.LOCATION) },
783930 .{ .literal = 0 }, // is distinct
784931 LineAbbrev, // line
785932 ColumnAbbrev, // column
......@@ -796,7 +943,7 @@ pub const MetadataBlock = struct {
796943
797944 pub const BasicType = struct {
798945 pub const ops = [_]AbbrevOp{
799 .{ .literal = 15 },
946 .{ .literal = @intFromEnum(MetadataCode.BASIC_TYPE) },
800947 .{ .literal = 0 }, // is distinct
801948 .{ .literal = std.dwarf.TAG.base_type }, // tag
802949 MetadataAbbrev, // name
......@@ -813,7 +960,7 @@ pub const MetadataBlock = struct {
813960
814961 pub const CompositeType = struct {
815962 pub const ops = [_]AbbrevOp{
816 .{ .literal = 18 },
963 .{ .literal = @intFromEnum(MetadataCode.COMPOSITE_TYPE) },
817964 .{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref
818965 .{ .fixed = 32 }, // tag
819966 MetadataAbbrev, // name
......@@ -852,7 +999,7 @@ pub const MetadataBlock = struct {
852999
8531000 pub const DerivedType = struct {
8541001 pub const ops = [_]AbbrevOp{
855 .{ .literal = 17 },
1002 .{ .literal = @intFromEnum(MetadataCode.DERIVED_TYPE) },
8561003 .{ .literal = 0 }, // is distinct
8571004 .{ .fixed = 32 }, // tag
8581005 MetadataAbbrev, // name
......@@ -880,7 +1027,7 @@ pub const MetadataBlock = struct {
8801027
8811028 pub const SubroutineType = struct {
8821029 pub const ops = [_]AbbrevOp{
883 .{ .literal = 19 },
1030 .{ .literal = @intFromEnum(MetadataCode.SUBROUTINE_TYPE) },
8841031 .{ .literal = 0 | 0x2 }, // is distinct | has no old type refs
8851032 .{ .literal = 0 }, // flags
8861033 MetadataAbbrev, // types
......@@ -891,7 +1038,7 @@ pub const MetadataBlock = struct {
8911038 };
8921039
8931040 pub const Enumerator = struct {
894 pub const id = 14;
1041 pub const id: MetadataCode = .ENUMERATOR;
8951042
8961043 pub const Flags = packed struct(u3) {
8971044 distinct: bool = false,
......@@ -900,7 +1047,7 @@ pub const MetadataBlock = struct {
9001047 };
9011048
9021049 pub const ops = [_]AbbrevOp{
903 .{ .literal = Enumerator.id },
1050 .{ .literal = @intFromEnum(Enumerator.id) },
9041051 .{ .fixed = @bitSizeOf(Flags) }, // flags
9051052 .{ .vbr = 6 }, // bit width
9061053 MetadataAbbrev, // name
......@@ -915,7 +1062,7 @@ pub const MetadataBlock = struct {
9151062
9161063 pub const Subrange = struct {
9171064 pub const ops = [_]AbbrevOp{
918 .{ .literal = 13 },
1065 .{ .literal = @intFromEnum(MetadataCode.SUBRANGE) },
9191066 .{ .literal = 0b10 }, // is distinct | version
9201067 MetadataAbbrev, // count
9211068 MetadataAbbrev, // lower bound
......@@ -929,7 +1076,7 @@ pub const MetadataBlock = struct {
9291076
9301077 pub const Expression = struct {
9311078 pub const ops = [_]AbbrevOp{
932 .{ .literal = 29 },
1079 .{ .literal = @intFromEnum(MetadataCode.EXPRESSION) },
9331080 .{ .literal = 0 | (3 << 1) }, // is distinct | version
9341081 MetadataArrayAbbrev, // elements
9351082 };
......@@ -939,7 +1086,7 @@ pub const MetadataBlock = struct {
9391086
9401087 pub const Node = struct {
9411088 pub const ops = [_]AbbrevOp{
942 .{ .literal = 3 },
1089 .{ .literal = @intFromEnum(MetadataCode.NODE) },
9431090 MetadataArrayAbbrev, // elements
9441091 };
9451092
......@@ -948,7 +1095,7 @@ pub const MetadataBlock = struct {
9481095
9491096 pub const LocalVar = struct {
9501097 pub const ops = [_]AbbrevOp{
951 .{ .literal = 28 },
1098 .{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
9521099 .{ .literal = 0b10 }, // is distinct | has alignment
9531100 MetadataAbbrev, // scope
9541101 MetadataAbbrev, // name
......@@ -970,7 +1117,7 @@ pub const MetadataBlock = struct {
9701117
9711118 pub const Parameter = struct {
9721119 pub const ops = [_]AbbrevOp{
973 .{ .literal = 28 },
1120 .{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
9741121 .{ .literal = 0b10 }, // is distinct | has alignment
9751122 MetadataAbbrev, // scope
9761123 MetadataAbbrev, // name
......@@ -993,7 +1140,7 @@ pub const MetadataBlock = struct {
9931140
9941141 pub const GlobalVar = struct {
9951142 pub const ops = [_]AbbrevOp{
996 .{ .literal = 27 },
1143 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR) },
9971144 .{ .literal = 0b101 }, // is distinct | version
9981145 MetadataAbbrev, // scope
9991146 MetadataAbbrev, // name
......@@ -1020,7 +1167,7 @@ pub const MetadataBlock = struct {
10201167
10211168 pub const GlobalVarExpression = struct {
10221169 pub const ops = [_]AbbrevOp{
1023 .{ .literal = 37 },
1170 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR_EXPR) },
10241171 .{ .literal = 0 }, // is distinct
10251172 MetadataAbbrev, // variable
10261173 MetadataAbbrev, // expression
......@@ -1032,7 +1179,7 @@ pub const MetadataBlock = struct {
10321179
10331180 pub const Constant = struct {
10341181 pub const ops = [_]AbbrevOp{
1035 .{ .literal = 2 },
1182 .{ .literal = @intFromEnum(MetadataCode.VALUE) },
10361183 MetadataAbbrev, // type
10371184 MetadataAbbrev, // value
10381185 };
......@@ -1043,7 +1190,7 @@ pub const MetadataBlock = struct {
10431190
10441191 pub const Name = struct {
10451192 pub const ops = [_]AbbrevOp{
1046 .{ .literal = 4 },
1193 .{ .literal = @intFromEnum(MetadataCode.NAME) },
10471194 .{ .array_fixed = 8 }, // name
10481195 };
10491196
......@@ -1052,7 +1199,7 @@ pub const MetadataBlock = struct {
10521199
10531200 pub const NamedNode = struct {
10541201 pub const ops = [_]AbbrevOp{
1055 .{ .literal = 10 },
1202 .{ .literal = @intFromEnum(MetadataCode.NAMED_NODE) },
10561203 MetadataArrayAbbrev, // elements
10571204 };
10581205
......@@ -1061,18 +1208,32 @@ pub const MetadataBlock = struct {
10611208
10621209 pub const GlobalDeclAttachment = struct {
10631210 pub const ops = [_]AbbrevOp{
1064 .{ .literal = 36 },
1211 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_DECL_ATTACHMENT) },
10651212 ValueAbbrev, // value id
10661213 .{ .fixed = 1 }, // kind
10671214 MetadataAbbrev, // elements
10681215 };
10691216
10701217 value: Builder.Constant,
1071 kind: MetadataKind,
1218 kind: FixedMetadataKind,
10721219 metadata: Builder.Metadata,
10731220 };
10741221};
10751222
1223pub const OperandBundleTags = struct {
1224 pub const id = 21;
1225
1226 pub const abbrevs = [_]type{OperandBundleTag};
1227
1228 pub const OperandBundleTag = struct {
1229 pub const ops = [_]AbbrevOp{
1230 .{ .literal = 1 },
1231 .array_char6,
1232 };
1233 tag: []const u8,
1234 };
1235};
1236
10761237pub const FunctionMetadataBlock = struct {
10771238 pub const id = 15;
10781239
......@@ -1132,6 +1293,7 @@ pub const FunctionBlock = struct {
11321293 Fence,
11331294 DebugLoc,
11341295 DebugLocAgain,
1296 ColdOperandBundle,
11351297 };
11361298
11371299 pub const DeclareBlocks = struct {
......@@ -1644,6 +1806,13 @@ pub const FunctionBlock = struct {
16441806 .{ .literal = 33 },
16451807 };
16461808 };
1809
1810 pub const ColdOperandBundle = struct {
1811 pub const ops = [_]AbbrevOp{
1812 .{ .literal = 55 },
1813 .{ .literal = 0 },
1814 };
1815 };
16471816};
16481817
16491818pub const FunctionValueSymbolTable = struct {
src/codegen/spirv.zig+18-32
......@@ -410,7 +410,7 @@ const NavGen = struct {
410410 }
411411
412412 pub fn fail(self: *NavGen, comptime format: []const u8, args: anytype) Error {
413 @setCold(true);
413 @branchHint(.cold);
414414 const zcu = self.pt.zcu;
415415 const src_loc = zcu.navSrcLoc(self.owner_nav);
416416 assert(self.error_msg == null);
......@@ -6173,11 +6173,10 @@ const NavGen = struct {
61736173 const pt = self.pt;
61746174 const zcu = pt.zcu;
61756175 const target = self.getTarget();
6176 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6177 const cond_ty = self.typeOf(pl_op.operand);
6178 const cond = try self.resolve(pl_op.operand);
6176 const switch_br = self.air.unwrapSwitch(inst);
6177 const cond_ty = self.typeOf(switch_br.operand);
6178 const cond = try self.resolve(switch_br.operand);
61796179 var cond_indirect = try self.convertToIndirect(cond_ty, cond);
6180 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
61816180
61826181 const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) {
61836182 .Bool, .ErrorSet => 1,
......@@ -6204,18 +6203,15 @@ const NavGen = struct {
62046203 else => return self.todo("implement switch for type {s}", .{@tagName(cond_ty.zigTypeTag(zcu))}),
62056204 };
62066205
6207 const num_cases = switch_br.data.cases_len;
6206 const num_cases = switch_br.cases_len;
62086207
62096208 // Compute the total number of arms that we need.
62106209 // Zig switches are grouped by condition, so we need to loop through all of them
62116210 const num_conditions = blk: {
6212 var extra_index: usize = switch_br.end;
62136211 var num_conditions: u32 = 0;
6214 for (0..num_cases) |_| {
6215 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6216 const case_body = self.air.extra[case.end + case.data.items_len ..][0..case.data.body_len];
6217 extra_index = case.end + case.data.items_len + case_body.len;
6218 num_conditions += case.data.items_len;
6212 var it = switch_br.iterateCases();
6213 while (it.next()) |case| {
6214 num_conditions += @intCast(case.items.len);
62196215 }
62206216 break :blk num_conditions;
62216217 };
......@@ -6244,17 +6240,12 @@ const NavGen = struct {
62446240
62456241 // Emit each of the cases
62466242 {
6247 var extra_index: usize = switch_br.end;
6248 for (0..num_cases) |case_i| {
6243 var it = switch_br.iterateCases();
6244 while (it.next()) |case| {
62496245 // SPIR-V needs a literal here, which' width depends on the case condition.
6250 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6251 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6252 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
6253 extra_index = case.end + case.data.items_len + case_body.len;
6254
6255 const label = case_labels.at(case_i);
6246 const label = case_labels.at(case.idx);
62566247
6257 for (items) |item| {
6248 for (case.items) |item| {
62586249 const value = (try self.air.value(item, pt)) orelse unreachable;
62596250 const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) {
62606251 .Bool, .Int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu),
......@@ -6285,20 +6276,15 @@ const NavGen = struct {
62856276 }
62866277
62876278 // Now, finally, we can start emitting each of the cases.
6288 var extra_index: usize = switch_br.end;
6289 for (0..num_cases) |case_i| {
6290 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6291 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6292 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
6293 extra_index = case.end + case.data.items_len + case_body.len;
6294
6295 const label = case_labels.at(case_i);
6279 var it = switch_br.iterateCases();
6280 while (it.next()) |case| {
6281 const label = case_labels.at(case.idx);
62966282
62976283 try self.beginSpvBlock(label);
62986284
62996285 switch (self.control_flow) {
63006286 .structured => {
6301 const next_block = try self.genStructuredBody(.selection, case_body);
6287 const next_block = try self.genStructuredBody(.selection, case.body);
63026288 incoming_structured_blocks.appendAssumeCapacity(.{
63036289 .src_label = self.current_block_label,
63046290 .next_block = next_block,
......@@ -6306,12 +6292,12 @@ const NavGen = struct {
63066292 try self.func.body.emitBranch(self.spv.gpa, merge_label.?);
63076293 },
63086294 .unstructured => {
6309 try self.genBody(case_body);
6295 try self.genBody(case.body);
63106296 },
63116297 }
63126298 }
63136299
6314 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
6300 const else_body = it.elseBody();
63156301 try self.beginSpvBlock(default);
63166302 if (else_body.len != 0) {
63176303 switch (self.control_flow) {
src/crash_report.zig+1-1
......@@ -153,8 +153,8 @@ fn writeFilePath(file: *Zcu.File, writer: anytype) !void {
153153}
154154
155155pub fn compilerPanic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, maybe_ret_addr: ?usize) noreturn {
156 @branchHint(.cold);
156157 PanicSwitch.preDispatch();
157 @setCold(true);
158158 const ret_addr = maybe_ret_addr orelse @returnAddress();
159159 const stack_ctx: StackContext = .{ .current = .{ .ret_addr = ret_addr } };
160160 PanicSwitch.dispatch(error_return_trace, stack_ctx, msg);
src/print_air.zig+25-21
......@@ -297,8 +297,8 @@ const Writer = struct {
297297 .union_init => try w.writeUnionInit(s, inst),
298298 .br => try w.writeBr(s, inst),
299299 .cond_br => try w.writeCondBr(s, inst),
300 .@"try" => try w.writeTry(s, inst),
301 .try_ptr => try w.writeTryPtr(s, inst),
300 .@"try", .try_cold => try w.writeTry(s, inst),
301 .try_ptr, .try_ptr_cold => try w.writeTryPtr(s, inst),
302302 .switch_br => try w.writeSwitchBr(s, inst),
303303 .cmpxchg_weak, .cmpxchg_strong => try w.writeCmpxchg(s, inst),
304304 .fence => try w.writeFence(s, inst),
......@@ -825,41 +825,40 @@ const Writer = struct {
825825 }
826826
827827 fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
828 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
829 const switch_br = w.air.extraData(Air.SwitchBr, pl_op.payload);
828 const switch_br = w.air.unwrapSwitch(inst);
829
830830 const liveness = if (w.liveness) |liveness|
831 liveness.getSwitchBr(w.gpa, inst, switch_br.data.cases_len + 1) catch
831 liveness.getSwitchBr(w.gpa, inst, switch_br.cases_len + 1) catch
832832 @panic("out of memory")
833833 else blk: {
834 const slice = w.gpa.alloc([]const Air.Inst.Index, switch_br.data.cases_len + 1) catch
834 const slice = w.gpa.alloc([]const Air.Inst.Index, switch_br.cases_len + 1) catch
835835 @panic("out of memory");
836836 @memset(slice, &.{});
837837 break :blk Liveness.SwitchBrTable{ .deaths = slice };
838838 };
839839 defer w.gpa.free(liveness.deaths);
840 var extra_index: usize = switch_br.end;
841 var case_i: u32 = 0;
842840
843 try w.writeOperand(s, inst, 0, pl_op.operand);
841 try w.writeOperand(s, inst, 0, switch_br.operand);
844842 if (w.skip_body) return s.writeAll(", ...");
845843 const old_indent = w.indent;
846844 w.indent += 2;
847845
848 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
849 const case = w.air.extraData(Air.SwitchBr.Case, extra_index);
850 const items = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra[case.end..][0..case.data.items_len]));
851 const case_body: []const Air.Inst.Index = @ptrCast(w.air.extra[case.end + items.len ..][0..case.data.body_len]);
852 extra_index = case.end + case.data.items_len + case_body.len;
853
846 var it = switch_br.iterateCases();
847 while (it.next()) |case| {
854848 try s.writeAll(", [");
855 for (items, 0..) |item, item_i| {
849 for (case.items, 0..) |item, item_i| {
856850 if (item_i != 0) try s.writeAll(", ");
857851 try w.writeInstRef(s, item, false);
858852 }
859 try s.writeAll("] => {\n");
853 try s.writeAll("] ");
854 const hint = switch_br.getHint(case.idx);
855 if (hint != .none) {
856 try s.print(".{s} ", .{@tagName(hint)});
857 }
858 try s.writeAll("=> {\n");
860859 w.indent += 2;
861860
862 const deaths = liveness.deaths[case_i];
861 const deaths = liveness.deaths[case.idx];
863862 if (deaths.len != 0) {
864863 try s.writeByteNTimes(' ', w.indent);
865864 for (deaths, 0..) |operand, i| {
......@@ -869,15 +868,20 @@ const Writer = struct {
869868 try s.writeAll("\n");
870869 }
871870
872 try w.writeBody(s, case_body);
871 try w.writeBody(s, case.body);
873872 w.indent -= 2;
874873 try s.writeByteNTimes(' ', w.indent);
875874 try s.writeAll("}");
876875 }
877876
878 const else_body: []const Air.Inst.Index = @ptrCast(w.air.extra[extra_index..][0..switch_br.data.else_body_len]);
877 const else_body = it.elseBody();
879878 if (else_body.len != 0) {
880 try s.writeAll(", else => {\n");
879 try s.writeAll(", else ");
880 const hint = switch_br.getElseHint();
881 if (hint != .none) {
882 try s.print(".{s} ", .{@tagName(hint)});
883 }
884 try s.writeAll("=> {\n");
881885 w.indent += 2;
882886
883887 const deaths = liveness.deaths[liveness.deaths.len - 1];
src/print_zir.zig+2-15
......@@ -429,7 +429,6 @@ const Writer = struct {
429429 .elem_val_imm => try self.writeElemValImm(stream, inst),
430430
431431 .@"export" => try self.writePlNodeExport(stream, inst),
432 .export_value => try self.writePlNodeExportValue(stream, inst),
433432
434433 .call => try self.writeCall(stream, inst, .direct),
435434 .field_call => try self.writeCall(stream, inst, .field),
......@@ -565,7 +564,6 @@ const Writer = struct {
565564 .fence,
566565 .set_float_mode,
567566 .set_align_stack,
568 .set_cold,
569567 .wasm_memory_size,
570568 .int_from_error,
571569 .error_from_int,
......@@ -574,6 +572,7 @@ const Writer = struct {
574572 .work_item_id,
575573 .work_group_size,
576574 .work_group_id,
575 .branch_hint,
577576 => {
578577 const inst_data = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;
579578 try self.writeInstRef(stream, inst_data.operand);
......@@ -1007,20 +1006,8 @@ const Writer = struct {
10071006 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
10081007 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10091008 const extra = self.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;
1010 const decl_name = self.code.nullTerminatedString(extra.decl_name);
10111009
1012 try self.writeInstRef(stream, extra.namespace);
1013 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});
1014 try self.writeInstRef(stream, extra.options);
1015 try stream.writeAll(") ");
1016 try self.writeSrcNode(stream, inst_data.src_node);
1017 }
1018
1019 fn writePlNodeExportValue(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
1020 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1021 const extra = self.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;
1022
1023 try self.writeInstRef(stream, extra.operand);
1010 try self.writeInstRef(stream, extra.exported);
10241011 try stream.writeAll(", ");
10251012 try self.writeInstRef(stream, extra.options);
10261013 try stream.writeAll(") ");
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/behavior.zig+1
......@@ -12,6 +12,7 @@ test {
1212 _ = @import("behavior/bitcast.zig");
1313 _ = @import("behavior/bitreverse.zig");
1414 _ = @import("behavior/bool.zig");
15 _ = @import("behavior/builtin_functions_returning_void_or_noreturn.zig");
1516 _ = @import("behavior/byteswap.zig");
1617 _ = @import("behavior/byval_arg_var.zig");
1718 _ = @import("behavior/call.zig");
test/behavior/basic.zig+83-6
......@@ -107,13 +107,90 @@ test "non const ptr to aliased type" {
107107 try expect(?*int == ?*i32);
108108}
109109
110test "cold function" {
111 thisIsAColdFn();
112 comptime thisIsAColdFn();
110test "function branch hints" {
111 const S = struct {
112 fn none() void {
113 @branchHint(.none);
114 }
115 fn likely() void {
116 @branchHint(.likely);
117 }
118 fn unlikely() void {
119 @branchHint(.unlikely);
120 }
121 fn cold() void {
122 @branchHint(.cold);
123 }
124 fn unpredictable() void {
125 @branchHint(.unpredictable);
126 }
127 };
128 S.none();
129 S.likely();
130 S.unlikely();
131 S.cold();
132 S.unpredictable();
133 comptime S.none();
134 comptime S.likely();
135 comptime S.unlikely();
136 comptime S.cold();
137 comptime S.unpredictable();
138}
139
140test "if branch hints" {
141 var t: bool = undefined;
142 t = true;
143 if (t) {
144 @branchHint(.likely);
145 } else {
146 @branchHint(.cold);
147 }
113148}
114149
115fn thisIsAColdFn() void {
116 @setCold(true);
150test "switch branch hints" {
151 var t: bool = undefined;
152 t = true;
153 switch (t) {
154 true => {
155 @branchHint(.likely);
156 },
157 false => {
158 @branchHint(.cold);
159 },
160 }
161}
162
163test "orelse branch hints" {
164 var x: ?u32 = undefined;
165 x = 123;
166 const val = x orelse val: {
167 @branchHint(.cold);
168 break :val 456;
169 };
170 try expect(val == 123);
171}
172
173test "catch branch hints" {
174 var x: error{Bad}!u32 = undefined;
175 x = 123;
176 const val = x catch val: {
177 @branchHint(.cold);
178 break :val 456;
179 };
180 try expect(val == 123);
181}
182
183test "and/or branch hints" {
184 var t: bool = undefined;
185 t = true;
186 try expect(t or b: {
187 @branchHint(.unlikely);
188 break :b false;
189 });
190 try expect(t and b: {
191 @branchHint(.likely);
192 break :b true;
193 });
117194}
118195
119196test "unicode escape in character literal" {
......@@ -734,7 +811,7 @@ test "extern variable with non-pointer opaque type" {
734811 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
735812 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
736813
737 @export(var_to_export, .{ .name = "opaque_extern_var" });
814 @export(&var_to_export, .{ .name = "opaque_extern_var" });
738815 try expect(@as(*align(1) u32, @ptrCast(&opaque_extern_var)).* == 42);
739816}
740817extern var opaque_extern_var: opaque {};
test/behavior/builtin_functions_returning_void_or_noreturn.zig+1-2
......@@ -15,14 +15,13 @@ test {
1515 var val: u8 = undefined;
1616 try testing.expectEqual({}, @atomicStore(u8, &val, 0, .unordered));
1717 try testing.expectEqual(void, @TypeOf(@breakpoint()));
18 try testing.expectEqual({}, @export(x, .{ .name = "x" }));
18 try testing.expectEqual({}, @export(&x, .{ .name = "x" }));
1919 try testing.expectEqual({}, @fence(.acquire));
2020 try testing.expectEqual({}, @memcpy(@as([*]u8, @ptrFromInt(1))[0..0], @as([*]u8, @ptrFromInt(1))[0..0]));
2121 try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined));
2222 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));
2323 try testing.expectEqual({}, @prefetch(&val, .{}));
2424 try testing.expectEqual({}, @setAlignStack(16));
25 try testing.expectEqual({}, @setCold(true));
2625 try testing.expectEqual({}, @setEvalBranchQuota(0));
2726 try testing.expectEqual({}, @setFloatMode(.optimized));
2827 try testing.expectEqual({}, @setRuntimeSafety(true));
test/behavior/export_builtin.zig+6-26
......@@ -2,7 +2,7 @@ const builtin = @import("builtin");
22const std = @import("std");
33const expect = std.testing.expect;
44
5test "exporting enum type and value" {
5test "exporting enum value" {
66 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
77 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
88
......@@ -10,7 +10,7 @@ test "exporting enum type and value" {
1010 const E = enum(c_int) { one, two };
1111 const e: E = .two;
1212 comptime {
13 @export(e, .{ .name = "e" });
13 @export(&e, .{ .name = "e" });
1414 }
1515 };
1616 try expect(S.e == .two);
......@@ -23,13 +23,13 @@ test "exporting with internal linkage" {
2323 const S = struct {
2424 fn foo() callconv(.C) void {}
2525 comptime {
26 @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
26 @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
2727 }
2828 };
2929 S.foo();
3030}
3131
32test "exporting using field access" {
32test "exporting using namespace access" {
3333 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
3434 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
3535
......@@ -38,7 +38,7 @@ test "exporting using field access" {
3838 const x: u32 = 5;
3939 };
4040 comptime {
41 @export(Inner.x, .{ .name = "foo", .linkage = .internal });
41 @export(&Inner.x, .{ .name = "foo", .linkage = .internal });
4242 }
4343 };
4444
......@@ -57,29 +57,9 @@ test "exporting comptime-known value" {
5757 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
5858
5959 const x: u32 = 10;
60 @export(x, .{ .name = "exporting_comptime_known_value_foo" });
60 @export(&x, .{ .name = "exporting_comptime_known_value_foo" });
6161 const S = struct {
6262 extern const exporting_comptime_known_value_foo: u32;
6363 };
6464 try expect(S.exporting_comptime_known_value_foo == 10);
6565}
66
67test "exporting comptime var" {
68 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
69 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
70 if (builtin.zig_backend == .stage2_x86_64 and
71 (builtin.target.ofmt != .elf and
72 builtin.target.ofmt != .macho and
73 builtin.target.ofmt != .coff)) return error.SkipZigTest;
74 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
75 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
76 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
77
78 comptime var x: u32 = 5;
79 @export(x, .{ .name = "exporting_comptime_var_foo" });
80 x = 7; // modifying this now shouldn't change anything
81 const S = struct {
82 extern const exporting_comptime_var_foo: u32;
83 };
84 try expect(S.exporting_comptime_var_foo == 5);
85}
test/behavior/export_c_keywords.zig+12-12
......@@ -24,21 +24,21 @@ export fn some_non_c_keyword_function() Id {
2424}
2525
2626comptime {
27 @export(int, .{ .name = "long" });
28 @export(int, .{ .name = "an_alias_of_int" });
27 @export(&int, .{ .name = "long" });
28 @export(&int, .{ .name = "an_alias_of_int" });
2929
30 @export(some_non_c_keyword_variable, .{ .name = "void" });
31 @export(some_non_c_keyword_variable, .{ .name = "an_alias_of_some_non_c_keyword_variable" });
30 @export(&some_non_c_keyword_variable, .{ .name = "void" });
31 @export(&some_non_c_keyword_variable, .{ .name = "an_alias_of_some_non_c_keyword_variable" });
3232
33 @export(@"if", .{ .name = "else" });
34 @export(@"if", .{ .name = "an_alias_of_if" });
33 @export(&@"if", .{ .name = "else" });
34 @export(&@"if", .{ .name = "an_alias_of_if" });
3535
36 @export(some_non_c_keyword_constant, .{ .name = "switch" });
37 @export(some_non_c_keyword_constant, .{ .name = "an_alias_of_some_non_c_keyword_constant" });
36 @export(&some_non_c_keyword_constant, .{ .name = "switch" });
37 @export(&some_non_c_keyword_constant, .{ .name = "an_alias_of_some_non_c_keyword_constant" });
3838
39 @export(float, .{ .name = "double" });
40 @export(float, .{ .name = "an_alias_of_float" });
39 @export(&float, .{ .name = "double" });
40 @export(&float, .{ .name = "an_alias_of_float" });
4141
42 @export(some_non_c_keyword_function, .{ .name = "break" });
43 @export(some_non_c_keyword_function, .{ .name = "an_alias_of_some_non_c_keyword_function" });
42 @export(&some_non_c_keyword_function, .{ .name = "break" });
43 @export(&some_non_c_keyword_function, .{ .name = "an_alias_of_some_non_c_keyword_function" });
4444}
test/behavior/generics.zig+1-1
......@@ -320,7 +320,7 @@ test "generic function instantiation non-duplicates" {
320320
321321 const S = struct {
322322 fn copy(comptime T: type, dest: []T, source: []const T) void {
323 @export(foo, .{ .name = "test_generic_instantiation_non_dupe" });
323 @export(&foo, .{ .name = "test_generic_instantiation_non_dupe" });
324324 for (source, 0..) |s, i| dest[i] = s;
325325 }
326326
test/cases/compile_errors/@export_with_undeclared_identifier.zig deleted-9
......@@ -1,9 +0,0 @@
1export fn a() void {
2 @export(bogus, .{ .name = "bogus_alias" });
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:13: error: use of undeclared identifier 'bogus'
test/cases/compile_errors/export_with_empty_name_string.zig+2-2
......@@ -1,10 +1,10 @@
11pub export fn entry() void {}
22comptime {
3 @export(entry, .{ .name = "" });
3 @export(&entry, .{ .name = "" });
44}
55
66// error
77// backend=llvm
88// target=native
99//
10// :3:24: error: exported symbol name cannot be empty
10// :3:25: error: exported symbol name cannot be empty
test/cases/compile_errors/exported_enum_without_explicit_integer_tag_type.zig+2-2
......@@ -1,10 +1,10 @@
11const E = enum { one, two };
22comptime {
3 @export(E, .{ .name = "E" });
3 @export(&E, .{ .name = "E" });
44}
55const e: E = .two;
66comptime {
7 @export(e, .{ .name = "e" });
7 @export(&e, .{ .name = "e" });
88}
99
1010// error
test/cases/compile_errors/exporting_primitive_values.zig deleted-29
......@@ -1,29 +0,0 @@
1pub export fn entry1() void {
2 @export(u100, .{ .name = "a" });
3}
4pub export fn entry3() void {
5 @export(undefined, .{ .name = "b" });
6}
7pub export fn entry4() void {
8 @export(null, .{ .name = "c" });
9}
10pub export fn entry5() void {
11 @export(false, .{ .name = "d" });
12}
13pub export fn entry6() void {
14 @export(u8, .{ .name = "e" });
15}
16pub export fn entry7() void {
17 @export(u65535, .{ .name = "f" });
18}
19
20// error
21// backend=llvm
22// target=native
23//
24// :2:13: error: unable to export primitive value
25// :5:13: error: unable to export primitive value
26// :8:13: error: unable to export primitive value
27// :11:13: error: unable to export primitive value
28// :14:13: error: unable to export primitive value
29// :17:13: error: unable to export primitive value
test/cases/compile_errors/function-only_builtins_outside_function.zig+2-2
......@@ -3,7 +3,7 @@ comptime {
33}
44
55comptime {
6 @setCold(true);
6 @branchHint(.cold);
77}
88
99comptime {
......@@ -55,7 +55,7 @@ comptime {
5555// target=native
5656//
5757// :2:5: error: '@setAlignStack' outside function scope
58// :6:5: error: '@setCold' outside function scope
58// :6:5: error: '@branchHint' outside function scope
5959// :10:5: error: '@src' outside function scope
6060// :14:5: error: '@returnAddress' outside function scope
6161// :18:5: error: '@frameAddress' outside function scope
test/cases/compile_errors/invalid_branch_hint.zig created+41
......@@ -0,0 +1,41 @@
1const globl = g: {
2 @branchHint(.none);
3 break :g {};
4};
5
6comptime {
7 @branchHint(.none);
8}
9
10test {
11 @branchHint(.none);
12}
13
14export fn foo() void {
15 {
16 @branchHint(.none);
17 }
18}
19
20export fn bar() void {
21 _ = (b: {
22 @branchHint(.none);
23 break :b true;
24 }) or true;
25}
26
27export fn qux() void {
28 (b: {
29 @branchHint(.none);
30 break :b @as(?void, {});
31 }) orelse unreachable;
32}
33
34// error
35//
36// :2:5: error: '@branchHint' outside function scope
37// :7:5: error: '@branchHint' outside function scope
38// :11:5: error: '@branchHint' must appear as the first statement in a function or conditional branch
39// :16:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
40// :22:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
41// :29:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
test/cases/compile_errors/missing_member_in_namespace_export.zig deleted-10
......@@ -1,10 +0,0 @@
1const S = struct {};
2comptime {
3 @export(S.foo, .{ .name = "foo" });
4}
5
6// error
7// target=native
8//
9// :3:14: error: struct 'tmp.S' has no member named 'foo'
10// :1:11: note: struct declared here
test/cases/compile_errors/wrong_types_given_to_export.zig+2-2
......@@ -1,11 +1,11 @@
11fn entry() callconv(.C) void {}
22comptime {
3 @export(entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
3 @export(&entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
44}
55
66// error
77// backend=stage2
88// target=native
99//
10// :3:41: error: expected type 'builtin.GlobalLinkage', found 'u32'
10// :3:42: error: expected type 'builtin.GlobalLinkage', found 'u32'
1111// :?:?: note: enum declared here
test/link/elf.zig+2-2
......@@ -937,8 +937,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {
937937 \\}
938938 \\export var strongBar: usize = 100;
939939 \\comptime {
940 \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .weak });
941 \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .strong });
940 \\ @export(&weakFoo, .{ .name = "weakFoo", .linkage = .weak });
941 \\ @export(&strongBar, .{ .name = "strongBarAlias", .linkage = .strong });
942942 \\}
943943 ,
944944 });
test/link/macho.zig+2-2
......@@ -196,7 +196,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
196196 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
197197 \\var x: usize = 1;
198198 \\export fn strong() void { x += 1; }
199 \\comptime { @export(weakImpl, .{ .name = "weak", .linkage = .weak }); }
199 \\comptime { @export(&weakImpl, .{ .name = "weak", .linkage = .weak }); }
200200 \\fn weakImpl() callconv(.C) void { x += 1; }
201201 \\extern fn weak() void;
202202 \\pub fn main() void {
......@@ -1676,7 +1676,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
16761676 \\ return x;
16771677 \\}
16781678 \\comptime {
1679 \\ @export(foo, .{ .name = "bar", .linkage = .strong });
1679 \\ @export(&foo, .{ .name = "bar", .linkage = .strong });
16801680 \\}
16811681 });
16821682
test/standalone/global_linkage/obj1.zig+2-2
......@@ -2,6 +2,6 @@ var internal_integer: usize = 1;
22var obj1_integer: usize = 421;
33
44comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });
5 @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(&obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });
77}
test/standalone/global_linkage/obj2.zig+2-2
......@@ -2,6 +2,6 @@ var internal_integer: usize = 2;
22var obj2_integer: usize = 422;
33
44comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });
5 @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(&obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });
77}
tools/gen_outline_atomics.zig+1-1
......@@ -48,7 +48,7 @@ pub fn main() !void {
4848 @tagName(op), n.toBytes(), @tagName(order),
4949 });
5050 try writeFunction(arena, w, name, op, n, order);
51 try footer.writer().print(" @export({s}, .{{ .name = \"{s}\", .linkage = linkage }});\n", .{
51 try footer.writer().print(" @export(&{s}, .{{ .name = \"{s}\", .linkage = linkage }});\n", .{
5252 name, name,
5353 });
5454 }