authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-11 18:41:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-12 18:38:11-07:00
log8324a93f2e382036b3a923f4ac869cf0d80438a2
tree12bcfd2221e2946997ed708b7e91260385e50eba
parent0d164f9a25f05a2917f4e1d4eb21c85b3279b47b

LLVM: always add some clobbers for some architectures

For some targets, Clang unconditionally adds some clobbers to all inline assembly. While this is probably not strictly necessary, if we don't follow Clang's lead here then we may risk tripping LLVM bugs since anything not used by Clang tends to be buggy and regress often.

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

src/codegen/llvm.zig+19
...@@ -5432,6 +5432,25 @@ pub const FuncGen = struct {...@@ -5432,6 +5432,25 @@ pub const FuncGen = struct {
5432 total_i += 1;5432 total_i += 1;
5433 }5433 }
5434 }5434 }
5435
5436 // For some targets, Clang unconditionally adds some clobbers to all inline assembly.
5437 // While this is probably not strictly necessary, if we don't follow Clang's lead
5438 // here then we may risk tripping LLVM bugs since anything not used by Clang tends
5439 // to be buggy and regress often.
5440 switch (target.cpu.arch) {
5441 .x86_64, .i386 => {
5442 if (total_i != 0) try llvm_constraints.append(self.gpa, ',');
5443 try llvm_constraints.appendSlice(self.gpa, "~{dirflag},~{fpsr},~{flags}");
5444 total_i += 3;
5445 },
5446 .mips, .mipsel, .mips64, .mips64el => {
5447 if (total_i != 0) try llvm_constraints.append(self.gpa, ',');
5448 try llvm_constraints.appendSlice(self.gpa, "~{$1}");
5449 total_i += 1;
5450 },
5451 else => {},
5452 }
5453
5435 const asm_source = std.mem.sliceAsBytes(self.air.extra[extra_i..])[0..extra.data.source_len];5454 const asm_source = std.mem.sliceAsBytes(self.air.extra[extra_i..])[0..extra.data.source_len];
54365455
5437 // hackety hacks until stage2 has proper inline asm in the frontend.5456 // hackety hacks until stage2 has proper inline asm in the frontend.