commit 5da5ded74326fce0ca52c6cb00f22824f7beb7eb (tree)
parent 4f5e065d6ec10cb27589995bf5d6390647f783f2
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 13 Jul 2020 23:48:26 -0700
stage2: detect unreferenced non-volatile asm and NOT
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/src-self-hosted/codegen.zig b/src-self-hosted/codegen.zig
@@ -412,6 +412,9 @@ const Function = struct {
}
fn genNot(self: *Function, inst: *ir.Inst.Not, comptime arch: std.Target.Cpu.Arch) !MCValue {
+ // No side effects, so if it's unreferenced, do nothing.
+ if (inst.base.isUnused())
+ return MCValue.dead;
switch (arch) {
else => return self.fail(inst.base.src, "TODO implement NOT for {}", .{self.target.cpu.arch}),
}
@@ -819,6 +822,8 @@ const Function = struct {
}
fn genAsm(self: *Function, inst: *ir.Inst.Assembly, comptime arch: Target.Cpu.Arch) !MCValue {
+ if (!inst.args.is_volatile and inst.base.isUnused())
+ return MCValue.dead;
if (arch != .x86_64 and arch != .i386) {
return self.fail(inst.base.src, "TODO implement inline asm support for more architectures", .{});
}