diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-19 12:07:56 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-19 12:07:56 -0500 |
| commit | db74832e40f98960e5dc3e46c8196c59033ee0f9 (patch) | |
| tree | 95d7e039968d665d0e0001c45c9c9c1f3e2a622d /src/all_types.hpp | |
| parent | c9fb5240d6305bcef7db5e12b7676ba3d741c11e (diff) | |
| download | zig-db74832e40f98960e5dc3e46c8196c59033ee0f9.tar.gz zig-db74832e40f98960e5dc3e46c8196c59033ee0f9.zip | |
valgrind client requests for undefined values
with this change, when you assign undefined, zig emits a few
assembly instructions to tell valgrind that the memory is undefined
it's on by default for debug builds, and disabled otherwise. only
support for linux, darwin, solaris, mingw on x86_64 is currently
implemented.
--disable-valgrind turns it off even in debug mode.
--enable-valgrind turns it on even in release modes.
It's always disabled for compiler_rt.a and builtin.a.
Adds `@import("builtin").valgrind_support` which lets code know
at comptime whether valgrind client requests are enabled.
See #1989
Diffstat (limited to 'src/all_types.hpp')
| -rw-r--r-- | src/all_types.hpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp index 0c81f1f53c..5bac44f9da 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1345,15 +1345,11 @@ struct ZigFn { // in the case of async functions this is the implicit return type according to the // zig source code, not according to zig ir ZigType *src_implicit_return_type; - bool is_test; - FnInline fn_inline; - FnAnalState anal_state; IrExecutable ir_executable; IrExecutable analyzed_executable; size_t prealloc_bbc; AstNode **param_source_nodes; Buf **param_names; - uint32_t align_bytes; AstNode *fn_no_inline_set_node; AstNode *fn_static_eval_set_node; @@ -1363,13 +1359,22 @@ struct ZigFn { Buf *section_name; AstNode *set_alignstack_node; - uint32_t alignstack_value; AstNode *set_cold_node; - bool is_cold; ZigList<FnExport> export_list; + + LLVMValueRef valgrind_client_request_array; + + FnInline fn_inline; + FnAnalState anal_state; + + uint32_t align_bytes; + uint32_t alignstack_value; + bool calls_or_awaits_errorable_fn; + bool is_cold; + bool is_test; }; uint32_t fn_table_entry_hash(ZigFn*); @@ -1612,6 +1617,12 @@ struct LinkLib { bool provided_explicitly; }; +enum ValgrindSupport { + ValgrindSupportAuto, + ValgrindSupportDisabled, + ValgrindSupportEnabled, +}; + // When adding fields, check if they should be added to the hash computation in build_with_cache struct CodeGen { //////////////////////////// Runtime State @@ -1813,6 +1824,7 @@ struct CodeGen { OutType out_type; ZigTarget zig_target; TargetSubsystem subsystem; + ValgrindSupport valgrind_support; bool is_static; bool strip_debug_symbols; bool is_test_build; |
