diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-11-16 17:46:39 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-11-16 17:46:39 -0700 |
| commit | 09588c795c08064971f61ee147d06972f0add94e (patch) | |
| tree | d7d2af6503aea7aa499c1a5eabf3c2f5a3591d3a /src/codegen/c.zig | |
| parent | 68fe391de02fd4c99f39bd6e0af643e1e327e52a (diff) | |
| download | zig-09588c795c08064971f61ee147d06972f0add94e.tar.gz zig-09588c795c08064971f61ee147d06972f0add94e.zip | |
stage2: LLVM backend: memset to 0xaa for undefined stores
Also support `one` and `int_big_positive` tags for const pointers.
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 908b85e701..3aef5a8f92 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -279,7 +279,7 @@ pub const DeclGen = struct { ty: Type, val: Value, ) error{ OutOfMemory, AnalysisFail }!void { - if (val.isUndef()) { + if (val.isUndefDeep()) { switch (ty.zigTypeTag()) { // Using '{}' for integer and floats seemed to error C compilers (both GCC and Clang) // with 'error: expected expression' (including when built with 'zig cc') @@ -1049,7 +1049,7 @@ pub fn genDecl(o: *Object) !void { } try fwd_decl_writer.writeAll(";\n"); - if (variable.init.isUndef()) { + if (variable.init.isUndefDeep()) { return; } @@ -1602,8 +1602,10 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { const src_val = try f.resolveInst(bin_op.rhs); const lhs_type = f.air.typeOf(bin_op.lhs); + // TODO Sema should emit a different instruction when the store should + // possibly do the safety 0xaa bytes for undefined. const src_val_is_undefined = - if (f.air.value(bin_op.rhs)) |v| v.isUndef() else false; + if (f.air.value(bin_op.rhs)) |v| v.isUndefDeep() else false; if (src_val_is_undefined) return try airStoreUndefined(f, dest_ptr, lhs_type); |
