Skip to content

fix(llvm): Correctly cache pointers to intrinsic memory operations #5549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xdoardo
Copy link
Collaborator

@xdoardo xdoardo commented Apr 30, 2025

Fixes the high CPU usage when using LLVM for modules that use atomics.

We were saving pointers to VM functions that operate on memory (for example, memory_notify and memory_wait) in the same cache. This led, then, to IR being generated like this:

if_then:                                          ; preds = %aligned_access_continue_block7
  %call_memory_notify = call i32 %xyz(ptr %0, i32 0, i32 %2, i32 1)
  br label %if_end

if_end:                                           ; preds = %aligned_access_continue_block7, %if_then
  %call_memory_wait32 = call i32 %xyz(ptr %0, i32 0, i32 %1, i32 %atomic_load, i64 -1)

where %xyz is a local variable the holds the value of the same function pointer resolved from cache, depending which between memory_notify and memory_wait, in this case, is added to the cache first.

Copy link

promptless bot commented Apr 30, 2025

✅ No documentation updates required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants