aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-26 19:12:34 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-26 19:27:49 -0700
commit31a59c229cb39b9ffd1ee3397a1ce87c36b91477 (patch)
treef4074655750f90c6350a8f3070343da9a724ccfd /src/Module.zig
parentcdeea3b0943b070d49d8d8d0855f9a38843e3ecc (diff)
downloadzig-31a59c229cb39b9ffd1ee3397a1ce87c36b91477.tar.gz
zig-31a59c229cb39b9ffd1ee3397a1ce87c36b91477.zip
stage2: improvements towards `zig test`
* Add AIR instruction: struct_field_val - This is part of an effort to eliminate the AIR instruction `ref`. - It's implemented for C backend and LLVM backend so far. * Rename `resolvePossiblyUndefinedValue` to `resolveMaybeUndefVal` just to save some columns on long lines. * Sema: add `fieldVal` alongside `fieldPtr` (renamed from `namedFieldPtr`). This is part of an effort to eliminate the AIR instruction `ref`. The idea is to avoid unnecessary loads, stores, stack usage, and IR instructions, by paying a DRY cost. LLVM backend improvements: * internal linkage vs exported linkage is implemented, along with aliases. There is an issue with incremental updates due to missing LLVM API for deleting aliases; see the relevant comment in this commit. - `updateDeclExports` is hooked up to the LLVM backend now. * Fix usage of `Type.tag() == .noreturn` rather than calling `isNoReturn()`. * Properly mark global variables as mutable/constant. * Fix llvm type generation of function pointers * Fix codegen for calls of function pointers * Implement llvm type generation of error unions and error sets. * Implement AIR instructions: addwrap, subwrap, mul, mulwrap, div, bit_and, bool_and, bit_or, bool_or, xor, struct_field_ptr, struct_field_val, unwrap_errunion_err, add for floats, sub for floats. After this commit, `zig test` on a file with `test "example" {}` correctly generates and executes a test binary. However the `test_functions` slice is undefined and just happens to be going into the .bss section, causing the length to be 0. The next step towards `zig test` will be replacing the `test_functions` Decl Value with the set of test function pointers, before it is sent to linker/codegen.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 8ebb1c203c..99f314c5cb 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -3702,8 +3702,8 @@ pub fn analyzeExport(
else => return mod.fail(scope, src, "unable to export type '{}'", .{exported_decl.ty}),
}
- try mod.decl_exports.ensureCapacity(mod.gpa, mod.decl_exports.count() + 1);
- try mod.export_owners.ensureCapacity(mod.gpa, mod.export_owners.count() + 1);
+ try mod.decl_exports.ensureUnusedCapacity(mod.gpa, 1);
+ try mod.export_owners.ensureUnusedCapacity(mod.gpa, 1);
const new_export = try mod.gpa.create(Export);
errdefer mod.gpa.destroy(new_export);