diff options
| author | William Roe <git@wjlr.org.uk> | 2023-08-07 19:29:42 +0100 |
|---|---|---|
| committer | William Roe <git@wjlr.org.uk> | 2023-08-07 21:18:56 +0100 |
| commit | 5d8b78cb887f431991d2fa1276c4e033a6d42566 (patch) | |
| tree | 536e1bf3b6b1d6c4c3be46fafe20f36466268463 /src/llvm_backend_proc.cpp | |
| parent | 9736402dfdb097172c6d1f74cade5cd142057c79 (diff) | |
Fix read_cycle_counter intrinsic on arm64
Running this code with the hard-coded x9 register results in not
returning the cycle count, but some other value.
This code (using $0 as the register), works on arm64 Linux and Darwin.
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 66edda825..b8f6f0f30 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -2115,7 +2115,7 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu if (build_context.metrics.arch == TargetArch_arm64) { LLVMTypeRef func_type = LLVMFunctionType(LLVMInt64TypeInContext(p->module->ctx), nullptr, 0, false); bool has_side_effects = false; - LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("mrs x9, cntvct_el0"), str_lit("=r"), has_side_effects); + LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("mrs $0, cntvct_el0"), str_lit("=r"), has_side_effects); GB_ASSERT(the_asm != nullptr); res.value = LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, ""); } else { |