diff --git a/src/codegen.cpp b/src/codegen.cpp index 568344fc099da613cdaccfe7334cbc2e2dc16439..7d21787809e217775771ee34502fc068d591119a 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -424,7 +424,7 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, ZigFn *fn_table_entry) { } static void maybe_export_dll(CodeGen *g, LLVMValueRef global_value, GlobalLinkageId linkage) { - if (linkage != GlobalLinkageIdInternal && g->zig_target->os == OsWindows) { + if (linkage != GlobalLinkageIdInternal && g->zig_target->os == OsWindows && g->is_dynamic) { LLVMSetDLLStorageClass(global_value, LLVMDLLExportStorageClass); } } diff --git a/std/special/compiler_rt.zig b/std/special/compiler_rt.zig index f15cf42be2b7a8818b0c4de250485723ab12bb63..6eb87cbd938674931dc2847fb8908f9feb85a7a4 100644 --- a/std/special/compiler_rt.zig +++ b/std/special/compiler_rt.zig @@ -160,6 +160,8 @@ comptime { @export("__chkstk", __chkstk, strong_linkage); @export("___chkstk_ms", ___chkstk_ms, linkage); } + // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI + // that LLVM expects compiler-rt to have. @export("__divti3", @import("compiler_rt/divti3.zig").__divti3_windows_x86_64, linkage); @export("__modti3", @import("compiler_rt/modti3.zig").__modti3_windows_x86_64, linkage); @export("__multi3", @import("compiler_rt/multi3.zig").__multi3_windows_x86_64, linkage); @@ -198,17 +200,6 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn } } -pub fn setXmm0(comptime T: type, value: T) void { - comptime assert(builtin.arch == builtin.Arch.x86_64); - const aligned_value: T align(16) = value; - asm volatile ( - \\movaps (%[ptr]), %%xmm0 - : - : [ptr] "r" (&aligned_value) - : "xmm0" - ); -} - extern fn __udivdi3(a: u64, b: u64) u64 { @setRuntimeSafety(is_test); return __udivmoddi4(a, b, null); diff --git a/std/special/compiler_rt/divti3.zig b/std/special/compiler_rt/divti3.zig index e89a1ada5c82e6b566ae5f67f078a06c0d27f77c..d5b2778a34c0e882a805dcb1b2153019cb2e91b9 100644 --- a/std/special/compiler_rt/divti3.zig +++ b/std/special/compiler_rt/divti3.zig @@ -16,9 +16,9 @@ pub extern fn __divti3(a: i128, b: i128) i128 { return (@bitCast(i128, r) ^ s) -% s; } -pub extern fn __divti3_windows_x86_64(a: *const i128, b: *const i128) void { - @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(i128, __divti3(a.*, b.*)); +const v128 = @Vector(2, u64); +pub extern fn __divti3_windows_x86_64(a: v128, b: v128) v128 { + return @bitCast(v128, @inlineCall(__divti3, @bitCast(i128, a), @bitCast(i128, b))); } test "import divti3" { diff --git a/std/special/compiler_rt/modti3.zig b/std/special/compiler_rt/modti3.zig index 03222cadf581f861df46950b98edd61fe8dd615e..16f2f38ba37075b7897a203f7eaaba78c8f8c85f 100644 --- a/std/special/compiler_rt/modti3.zig +++ b/std/special/compiler_rt/modti3.zig @@ -20,9 +20,9 @@ pub extern fn __modti3(a: i128, b: i128) i128 { return (@bitCast(i128, r) ^ s_a) -% s_a; // negate if s == -1 } -pub extern fn __modti3_windows_x86_64(a: *const i128, b: *const i128) void { - @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(i128, __modti3(a.*, b.*)); +const v128 = @Vector(2, u64); +pub extern fn __modti3_windows_x86_64(a: v128, b: v128) v128 { + return @bitCast(v128, @inlineCall(__modti3, @bitCast(i128, a), @bitCast(i128, b))); } test "import modti3" { diff --git a/std/special/compiler_rt/muloti4.zig b/std/special/compiler_rt/muloti4.zig index f5820fa37d6477ec62d1ab84462fcf63c2f9a6f3..65953f3e1d0edc1393758eb3f283f037f6b2a758 100644 --- a/std/special/compiler_rt/muloti4.zig +++ b/std/special/compiler_rt/muloti4.zig @@ -44,9 +44,9 @@ pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 { return r; } -pub extern fn __muloti4_windows_x86_64(a: *const i128, b: *const i128, overflow: *c_int) void { - @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(i128, __muloti4(a.*, b.*, overflow)); +const v128 = @Vector(2, u64); +pub extern fn __muloti4_windows_x86_64(a: v128, b: v128, overflow: *c_int) v128 { + return @bitCast(v128, @inlineCall(__muloti4, @bitCast(i128, a), @bitCast(i128, b), overflow)); } test "import muloti4" { diff --git a/std/special/compiler_rt/multi3.zig b/std/special/compiler_rt/multi3.zig index a0c84adaf4197ef88b7e56d674d020ea79c90085..799b1f575d7de2fe3bf9652da7009ad1b811bbe7 100644 --- a/std/special/compiler_rt/multi3.zig +++ b/std/special/compiler_rt/multi3.zig @@ -14,9 +14,9 @@ pub extern fn __multi3(a: i128, b: i128) i128 { return r.all; } -pub extern fn __multi3_windows_x86_64(a: *const i128, b: *const i128) void { - @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(i128, __multi3(a.*, b.*)); +const v128 = @Vector(2, u64); +pub extern fn __multi3_windows_x86_64(a: v128, b: v128) v128 { + return @bitCast(v128, @inlineCall(__multi3, @bitCast(i128, a), @bitCast(i128, b))); } fn __mulddi3(a: u64, b: u64) i128 { diff --git a/std/special/compiler_rt/udivmodti4.zig b/std/special/compiler_rt/udivmodti4.zig index 6a037d3bae7751f0ca173bafa3704f7a86d4f3fb..c74dff512da2b9f773bb8cf899d04869215ffe0a 100644 --- a/std/special/compiler_rt/udivmodti4.zig +++ b/std/special/compiler_rt/udivmodti4.zig @@ -7,9 +7,10 @@ pub extern fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) u128 { return udivmod(u128, a, b, maybe_rem); } -pub extern fn __udivmodti4_windows_x86_64(a: *const u128, b: *const u128, maybe_rem: ?*u128) void { +const v128 = @Vector(2, u64); +pub extern fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) v128 { @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(u128, udivmod(u128, a.*, b.*, maybe_rem)); + return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem)); } test "import udivmodti4" { diff --git a/std/special/compiler_rt/udivti3.zig b/std/special/compiler_rt/udivti3.zig index 510e21ac1dac28cde6cc25a890002760ddc2523c..ab451859bfc8008a8b0d52d060c3813d3f2c951e 100644 --- a/std/special/compiler_rt/udivti3.zig +++ b/std/special/compiler_rt/udivti3.zig @@ -6,7 +6,8 @@ pub extern fn __udivti3(a: u128, b: u128) u128 { return udivmodti4.__udivmodti4(a, b, null); } -pub extern fn __udivti3_windows_x86_64(a: *const u128, b: *const u128) void { +const v128 = @Vector(2, u64); +pub extern fn __udivti3_windows_x86_64(a: v128, b: v128) v128 { @setRuntimeSafety(builtin.is_test); - udivmodti4.__udivmodti4_windows_x86_64(a, b, null); + return udivmodti4.__udivmodti4_windows_x86_64(a, b, null); } diff --git a/std/special/compiler_rt/umodti3.zig b/std/special/compiler_rt/umodti3.zig index 12aca8b03623e5793ce6f736640dc9d49aa0a506..7add0b2ffef07103032709b566af674ce01cf355 100644 --- a/std/special/compiler_rt/umodti3.zig +++ b/std/special/compiler_rt/umodti3.zig @@ -9,7 +9,7 @@ pub extern fn __umodti3(a: u128, b: u128) u128 { return r; } -pub extern fn __umodti3_windows_x86_64(a: *const u128, b: *const u128) void { - @setRuntimeSafety(builtin.is_test); - compiler_rt.setXmm0(u128, __umodti3(a.*, b.*)); +const v128 = @Vector(2, u64); +pub extern fn __umodti3_windows_x86_64(a: v128, b: v128) v128 { + return @bitCast(v128, @inlineCall(__umodti3, @bitCast(u128, a), @bitCast(u128, b))); }