Skip to content

Commit

Permalink
LLVM: omit memset of 0xaa bytes in unsafe optimization modes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewrk committed May 31, 2022
1 parent c3ef4ac commit 83beed0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6944,6 +6944,23 @@ pub const FuncGen = struct {
// possibly do the safety 0xaa bytes for undefined.
const val_is_undef = if (self.air.value(bin_op.rhs)) |val| val.isUndefDeep() else false;
if (val_is_undef) {
{
// TODO let's handle this in AIR rather than by having each backend
// check the optimization mode of the compilation because the plan is
// to support setting the optimization mode at finer grained scopes
// which happens in Sema. Codegen should not be aware of this logic.
// I think this comment is basically the same as the other TODO comment just
// above but I'm leaving them both here to make it look super messy and
// thereby bait contributors (or let's be honest, probably myself) into
// fixing this instead of letting it rot.
const safety = switch (self.dg.module.comp.bin_file.options.optimize_mode) {
.ReleaseSmall, .ReleaseFast => false,
.Debug, .ReleaseSafe => true,
};
if (!safety) {
return null;
}
}
const target = self.dg.module.getTarget();
const operand_size = operand_ty.abiSize(target);
const u8_llvm_ty = self.context.intType(8);
Expand Down

0 comments on commit 83beed0

Please sign in to comment.