diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2021-11-13 18:54:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-13 18:54:12 +0000 |
| commit | bfa23f1352d0df719b84e467d9c7df29f98c7834 (patch) | |
| tree | 3be144030d41cfb87f339cec51368dd757ac5e85 /src/llvm_backend_proc.cpp | |
| parent | cc316a473e50f4b19255fa24d2fe616c685770bb (diff) | |
| parent | c430a827216b7c79e5df70ed20a1acd98abc92f2 (diff) | |
Merge pull request #1308 from Yawning/fix/amd64-syscalls
src: Fix the syscall intrinsic code generation for Linux and Windows
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 2b094cfae..8b8559cae 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -2002,7 +2002,22 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, constraints = gb_string_appendc(constraints, regs[i]); constraints = gb_string_appendc(constraints, "}"); } - + + // The SYSCALL instruction stores the address of the + // following instruction into RCX, and RFLAGS in R11. + // + // RSP is not saved, but at least on Linux it appears + // that the kernel system-call handler does the right + // thing. + // + // Some but not all system calls will additionally + // clobber memory. + // + // TODO: FreeBSD is different and will also clobber + // R8, R9, and R10. Additionally CF is used to + // indicate an error instead of -errno. + constraints = gb_string_appendc(constraints, ",~{rcx},~{r11},~{memory}"); + inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints)); } break; |