Skip to content

Commit 83beed0

Browse files
committed
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 parent c3ef4ac commit 83beed0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/codegen/llvm.zig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)