authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-30 19:12:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-30 19:12:05-07:00
log20145016ac0d098e8e63d5107a05eca376d1e7bb
tree9fa59538541c7a92a5b593a248d00ec8be06f87d
parentea4ef832e364d48b4670c71d948782df12e5e4ca
parent56cfa8f22f69d813efedb1fa01fdcb7077ca0e5a

Merge remote-tracking branch 'origin/master' into llvm15


6 files changed, 113 insertions(+), 10 deletions(-)

ci/drone/linux_script_finalize+2-1
...@@ -19,7 +19,8 @@ pip3 install s3cmd...@@ -19,7 +19,8 @@ pip3 install s3cmd
19cd build19cd build
2020
21mv ../LICENSE "$INSTALL_PREFIX/"21mv ../LICENSE "$INSTALL_PREFIX/"
22mv ../zig-cache/langref.html "$INSTALL_PREFIX/"22# https://github.com/ziglang/zig/issues/12689
23# mv ../zig-cache/langref.html "$INSTALL_PREFIX/"
23mv "$INSTALL_PREFIX/bin/zig" "$INSTALL_PREFIX/"24mv "$INSTALL_PREFIX/bin/zig" "$INSTALL_PREFIX/"
24rmdir "$INSTALL_PREFIX/bin"25rmdir "$INSTALL_PREFIX/bin"
2526
ci/drone/test_linux_behavior+3-1
...@@ -7,8 +7,10 @@ INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"...@@ -7,8 +7,10 @@ INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
99
10# Tracking issue for the disabled tests:
10# https://github.com/ziglang/zig/issues/1268911# https://github.com/ziglang/zig/issues/12689
12
11# $ZIG build test-behavior -Dskip-non-native --zig-lib-dir lib13# $ZIG build test-behavior -Dskip-non-native --zig-lib-dir lib
12$ZIG build test-compiler-rt -Dskip-non-native --zig-lib-dir lib14$ZIG build test-compiler-rt -Dskip-non-native --zig-lib-dir lib
13$ZIG build test-fmt --zig-lib-dir lib15$ZIG build test-fmt --zig-lib-dir lib
14$ZIG build docs --zig-lib-dir lib16# $ZIG build docs --zig-lib-dir lib
ci/drone/test_linux_misc+4-2
...@@ -7,10 +7,12 @@ INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"...@@ -7,10 +7,12 @@ INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
99
10$ZIG build test-universal-libc -Dskip-non-native --zig-lib-dir lib10# Tracking issue for the disabled tests:
11# https://github.com/ziglang/zig/issues/1268911# https://github.com/ziglang/zig/issues/12689
12
13$ZIG build test-universal-libc -Dskip-non-native --zig-lib-dir lib
12# $ZIG build test-compare-output -Dskip-non-native --zig-lib-dir lib14# $ZIG build test-compare-output -Dskip-non-native --zig-lib-dir lib
13$ZIG build test-standalone -Dskip-non-native --zig-lib-dir lib -Dskip-release-safe15# $ZIG build test-standalone -Dskip-non-native --zig-lib-dir lib -Dskip-release-safe
14$ZIG build test-stack-traces -Dskip-non-native --zig-lib-dir lib16$ZIG build test-stack-traces -Dskip-non-native --zig-lib-dir lib
15$ZIG build test-cli -Dskip-non-native --zig-lib-dir lib17$ZIG build test-cli -Dskip-non-native --zig-lib-dir lib
16$ZIG build test-asm-link -Dskip-non-native --zig-lib-dir lib18$ZIG build test-asm-link -Dskip-non-native --zig-lib-dir lib
lib/std/coff.zig+78
...@@ -310,6 +310,84 @@ pub const ImageDataDirectory = extern struct {...@@ -310,6 +310,84 @@ pub const ImageDataDirectory = extern struct {
310 size: u32,310 size: u32,
311};311};
312312
313pub const BaseRelocationDirectoryEntry = extern struct {
314 /// The image base plus the page RVA is added to each offset to create the VA where the base relocation must be applied.
315 page_rva: u32,
316
317 /// The total number of bytes in the base relocation block, including the Page RVA and Block Size fields and the Type/Offset fields that follow.
318 block_size: u32,
319};
320
321pub const BaseRelocation = packed struct {
322 /// Stored in the remaining 12 bits of the WORD, an offset from the starting address that was specified in the Page RVA field for the block.
323 /// This offset specifies where the base relocation is to be applied.
324 offset: u12,
325
326 /// Stored in the high 4 bits of the WORD, a value that indicates the type of base relocation to be applied.
327 @"type": BaseRelocationType,
328};
329
330pub const BaseRelocationType = enum(u4) {
331 /// The base relocation is skipped. This type can be used to pad a block.
332 ABSOLUTE = 0,
333
334 /// The base relocation adds the high 16 bits of the difference to the 16-bit field at offset. The 16-bit field represents the high value of a 32-bit word.
335 HIGH = 1,
336
337 /// The base relocation adds the low 16 bits of the difference to the 16-bit field at offset. The 16-bit field represents the low half of a 32-bit word.
338 LOW = 2,
339
340 /// The base relocation applies all 32 bits of the difference to the 32-bit field at offset.
341 HIGHLOW = 3,
342
343 /// The base relocation adds the high 16 bits of the difference to the 16-bit field at offset.
344 /// The 16-bit field represents the high value of a 32-bit word.
345 /// The low 16 bits of the 32-bit value are stored in the 16-bit word that follows this base relocation.
346 /// This means that this base relocation occupies two slots.
347 HIGHADJ = 4,
348
349 /// When the machine type is MIPS, the base relocation applies to a MIPS jump instruction.
350 MIPS_JMPADDR = 5,
351
352 /// This relocation is meaningful only when the machine type is ARM or Thumb.
353 /// The base relocation applies the 32-bit address of a symbol across a consecutive MOVW/MOVT instruction pair.
354 // ARM_MOV32 = 5,
355
356 /// This relocation is only meaningful when the machine type is RISC-V.
357 /// The base relocation applies to the high 20 bits of a 32-bit absolute address.
358 // RISCV_HIGH20 = 5,
359
360 /// Reserved, must be zero.
361 RESERVED = 6,
362
363 /// This relocation is meaningful only when the machine type is Thumb.
364 /// The base relocation applies the 32-bit address of a symbol to a consecutive MOVW/MOVT instruction pair.
365 THUMB_MOV32 = 7,
366
367 /// This relocation is only meaningful when the machine type is RISC-V.
368 /// The base relocation applies to the low 12 bits of a 32-bit absolute address formed in RISC-V I-type instruction format.
369 // RISCV_LOW12I = 7,
370
371 /// This relocation is only meaningful when the machine type is RISC-V.
372 /// The base relocation applies to the low 12 bits of a 32-bit absolute address formed in RISC-V S-type instruction format.
373 RISCV_LOW12S = 8,
374
375 /// This relocation is only meaningful when the machine type is LoongArch 32-bit.
376 /// The base relocation applies to a 32-bit absolute address formed in two consecutive instructions.
377 // LOONGARCH32_MARK_LA = 8,
378
379 /// This relocation is only meaningful when the machine type is LoongArch 64-bit.
380 /// The base relocation applies to a 64-bit absolute address formed in four consecutive instructions.
381 // LOONGARCH64_MARK_LA = 8,
382
383 /// The relocation is only meaningful when the machine type is MIPS.
384 /// The base relocation applies to a MIPS16 jump instruction.
385 MIPS_JMPADDR16 = 9,
386
387 /// The base relocation applies the difference to the 64-bit field at offset.
388 DIR64 = 10,
389};
390
313pub const DebugDirectoryEntry = extern struct {391pub const DebugDirectoryEntry = extern struct {
314 characteristics: u32,392 characteristics: u32,
315 time_date_stamp: u32,393 time_date_stamp: u32,
src/Module.zig+16
...@@ -1496,6 +1496,22 @@ pub const Fn = struct {...@@ -1496,6 +1496,22 @@ pub const Fn = struct {
1496 /// active Sema context. Importantly, this value is also updated when an existing1496 /// active Sema context. Importantly, this value is also updated when an existing
1497 /// generic function instantiation is found and called.1497 /// generic function instantiation is found and called.
1498 branch_quota: u32,1498 branch_quota: u32,
1499
1500 /// If this is not none, this function is a generic function instantiation, and
1501 /// this is the generic function decl from which the instance was derived.
1502 /// This information is redundant with a combination of checking if comptime_args is
1503 /// not null and looking at the first decl dependency of owner_decl. This redundant
1504 /// information is useful for three reasons:
1505 /// 1. Improved perf of monomorphed_funcs when checking the eql() function because it
1506 /// can do two fewer pointer chases by grabbing the info from this field directly
1507 /// instead of accessing the decl and then the dependencies set.
1508 /// 2. While a generic function instantiation is being initialized, we need hash()
1509 /// and eql() to work before the initialization is complete. Completing the
1510 /// insertion into the decl dependency set has more fallible operations than simply
1511 /// setting this field.
1512 /// 3. I forgot what the third thing was while typing up the other two.
1513 generic_owner_decl: Decl.OptionalIndex,
1514
1499 state: Analysis,1515 state: Analysis,
1500 is_cold: bool = false,1516 is_cold: bool = false,
1501 is_noinline: bool,1517 is_noinline: bool,
src/Sema.zig+10-6
...@@ -5590,11 +5590,10 @@ const GenericCallAdapter = struct {...@@ -5590,11 +5590,10 @@ const GenericCallAdapter = struct {
55905590
5591 pub fn eql(ctx: @This(), adapted_key: void, other_key: *Module.Fn) bool {5591 pub fn eql(ctx: @This(), adapted_key: void, other_key: *Module.Fn) bool {
5592 _ = adapted_key;5592 _ = adapted_key;
5593 // The generic function Decl is guaranteed to be the first dependency5593 // Checking for equality may happen on an item that has been inserted
5594 // of each of its instantiations.5594 // into the map but is not yet fully initialized. In such case, the
5595 const other_owner_decl = ctx.module.declPtr(other_key.owner_decl);5595 // two initialized fields are `hash` and `generic_owner_decl`.
5596 const generic_owner_decl = other_owner_decl.dependencies.keys()[0];5596 if (ctx.generic_fn.owner_decl != other_key.generic_owner_decl.unwrap().?) return false;
5597 if (ctx.generic_fn.owner_decl != generic_owner_decl) return false;
55985597
5599 const other_comptime_args = other_key.comptime_args.?;5598 const other_comptime_args = other_key.comptime_args.?;
5600 for (other_comptime_args[0..ctx.func_ty_info.param_types.len]) |other_arg, i| {5599 for (other_comptime_args[0..ctx.func_ty_info.param_types.len]) |other_arg, i| {
...@@ -6447,11 +6446,14 @@ fn instantiateGenericCall(...@@ -6447,11 +6446,14 @@ fn instantiateGenericCall(
6447 const gop = try mod.monomorphed_funcs.getOrPutAdapted(gpa, {}, adapter);6446 const gop = try mod.monomorphed_funcs.getOrPutAdapted(gpa, {}, adapter);
6448 const callee = if (!gop.found_existing) callee: {6447 const callee = if (!gop.found_existing) callee: {
6449 const new_module_func = try gpa.create(Module.Fn);6448 const new_module_func = try gpa.create(Module.Fn);
6449 errdefer gpa.destroy(new_module_func);
6450
6450 // This ensures that we can operate on the hash map before the Module.Fn6451 // This ensures that we can operate on the hash map before the Module.Fn
6451 // struct is fully initialized.6452 // struct is fully initialized.
6452 new_module_func.hash = precomputed_hash;6453 new_module_func.hash = precomputed_hash;
6454 new_module_func.generic_owner_decl = module_fn.owner_decl.toOptional();
6455 new_module_func.comptime_args = null;
6453 gop.key_ptr.* = new_module_func;6456 gop.key_ptr.* = new_module_func;
6454 errdefer gpa.destroy(new_module_func);
6455 errdefer assert(mod.monomorphed_funcs.remove(new_module_func));6457 errdefer assert(mod.monomorphed_funcs.remove(new_module_func));
64566458
6457 try namespace.anon_decls.ensureUnusedCapacity(gpa, 1);6459 try namespace.anon_decls.ensureUnusedCapacity(gpa, 1);
...@@ -8032,11 +8034,13 @@ fn funcCommon(...@@ -8032,11 +8034,13 @@ fn funcCommon(
8032 } else null;8034 } else null;
80338035
8034 const hash = new_func.hash;8036 const hash = new_func.hash;
8037 const generic_owner_decl = if (comptime_args == null) .none else new_func.generic_owner_decl;
8035 const fn_payload = try sema.arena.create(Value.Payload.Function);8038 const fn_payload = try sema.arena.create(Value.Payload.Function);
8036 new_func.* = .{8039 new_func.* = .{
8037 .state = anal_state,8040 .state = anal_state,
8038 .zir_body_inst = func_inst,8041 .zir_body_inst = func_inst,
8039 .owner_decl = sema.owner_decl_index,8042 .owner_decl = sema.owner_decl_index,
8043 .generic_owner_decl = generic_owner_decl,
8040 .comptime_args = comptime_args,8044 .comptime_args = comptime_args,
8041 .hash = hash,8045 .hash = hash,
8042 .lbrace_line = src_locs.lbrace_line,8046 .lbrace_line = src_locs.lbrace_line,