authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-13 23:48:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-13 23:48:26-07:00
log5da5ded74326fce0ca52c6cb00f22824f7beb7eb
tree383f64ceb3347ce78783bc79db93ee3e70637b2d
parent4f5e065d6ec10cb27589995bf5d6390647f783f2

stage2: detect unreferenced non-volatile asm and NOT


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

src-self-hosted/codegen.zig+5
...@@ -412,6 +412,9 @@ const Function = struct {...@@ -412,6 +412,9 @@ const Function = struct {
412 }412 }
413413
414 fn genNot(self: *Function, inst: *ir.Inst.Not, comptime arch: std.Target.Cpu.Arch) !MCValue {414 fn genNot(self: *Function, inst: *ir.Inst.Not, comptime arch: std.Target.Cpu.Arch) !MCValue {
415 // No side effects, so if it's unreferenced, do nothing.
416 if (inst.base.isUnused())
417 return MCValue.dead;
415 switch (arch) {418 switch (arch) {
416 else => return self.fail(inst.base.src, "TODO implement NOT for {}", .{self.target.cpu.arch}),419 else => return self.fail(inst.base.src, "TODO implement NOT for {}", .{self.target.cpu.arch}),
417 }420 }
...@@ -819,6 +822,8 @@ const Function = struct {...@@ -819,6 +822,8 @@ const Function = struct {
819 }822 }
820823
821 fn genAsm(self: *Function, inst: *ir.Inst.Assembly, comptime arch: Target.Cpu.Arch) !MCValue {824 fn genAsm(self: *Function, inst: *ir.Inst.Assembly, comptime arch: Target.Cpu.Arch) !MCValue {
825 if (!inst.args.is_volatile and inst.base.isUnused())
826 return MCValue.dead;
822 if (arch != .x86_64 and arch != .i386) {827 if (arch != .x86_64 and arch != .i386) {
823 return self.fail(inst.base.src, "TODO implement inline asm support for more architectures", .{});828 return self.fail(inst.base.src, "TODO implement inline asm support for more architectures", .{});
824 }829 }