authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-31 00:39:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-31 00:39:14-07:00
log83beed09e1ce5a15e2b9801a50cf601352d8383e
treeccb6c6633a76b8f06bcc4efe08e2f27019145a7e
parentc3ef4ac15f4aa0a4bbf546fb46745d445b97d717

LLVM: omit memset of 0xaa bytes in unsafe optimization modes

This is one out of three changes I intend to make to address #11498. However I will put these changes in separate branches and merge them separately so that we can have three independent points on the perf charts.

1 files changed, 17 insertions(+), 0 deletions(-)

src/codegen/llvm.zig+17
......@@ -6944,6 +6944,23 @@ pub const FuncGen = struct {
69446944 // possibly do the safety 0xaa bytes for undefined.
69456945 const val_is_undef = if (self.air.value(bin_op.rhs)) |val| val.isUndefDeep() else false;
69466946 if (val_is_undef) {
6947 {
6948 // TODO let's handle this in AIR rather than by having each backend
6949 // check the optimization mode of the compilation because the plan is
6950 // to support setting the optimization mode at finer grained scopes
6951 // which happens in Sema. Codegen should not be aware of this logic.
6952 // I think this comment is basically the same as the other TODO comment just
6953 // above but I'm leaving them both here to make it look super messy and
6954 // thereby bait contributors (or let's be honest, probably myself) into
6955 // fixing this instead of letting it rot.
6956 const safety = switch (self.dg.module.comp.bin_file.options.optimize_mode) {
6957 .ReleaseSmall, .ReleaseFast => false,
6958 .Debug, .ReleaseSafe => true,
6959 };
6960 if (!safety) {
6961 return null;
6962 }
6963 }
69476964 const target = self.dg.module.getTarget();
69486965 const operand_size = operand_ty.abiSize(target);
69496966 const u8_llvm_ty = self.context.intType(8);