Skip to content

AArch64: Fixes missing memory operand access value for SWP - #3111

Merged
Rot127 merged 2 commits into
capstone-engine:nextfrom
Abhinavmadake:swp-mem-access
Oct 9, 2026
Merged

Rot127 merged 2 commits into
capstone-engine:nextfrom
Abhinavmadake:swp-mem-access

Conversation

@Abhinavmadake

Copy link
Copy Markdown
Contributor

checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description
SWP reads old value from memory and writes the new one, But BaseSWP in llvm-capstone is missing mayLoad/mayStore
While checking for atomic instructions from #2589 i found that SWP's memory access was missing entirely

Fixes the per-operand access seen in the output for all 16 SWP instructions in arch/AArch64/AArch64GenCSMappingInsnOp.inc and per-instruction access in arch/AArch64/AArch64GenCSMappingInsn.inc.

Added suite/auto-sync/inc_patches/AArch64/03_swp_mem_access.patch following the workflow for patch files

Test plan

Added 4 tests covering 4 of the 16 instructions, for all 4 sizes(b/h/w/x) and all 4 ordering (none/a/al/l)

swp     w0, w1, [x2]
swpalb  w3, w4, [x5]
swplh   w6, w7, [sp]
swpa    x8, x9, [x10]

These tests pass with my fix, while they fail without it

Closing issues
-none

changes CS_AC_INVALID to CS_AC_READ | CS_AC_WRITE for all 16 swp versions in arch/AArch64/AArch64GenCSMappingInsnOp.inc and CS_AC_INVALID to CS_AC_READ_WRITE in arch/AArch64/AArch64GenCSMappingInsn.inc, added new patch file and tests for the same
@Rot127

Rot127 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix!
Since you identified already the issue in LLVM, could you please also open a PR in our fork: https://github.com/capstone-engine/llvm-capstone

Then the patch file is no longer necessary and can be removed.

@Abhinavmadake

Copy link
Copy Markdown
Contributor Author

got it, made the changes and added a pr in capstone-engine/llvm-capstone#98

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (next@992e6d7). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3111   +/-   ##
=======================================
  Coverage        ?   61.14%           
=======================================
  Files           ?      243           
  Lines           ?    56765           
  Branches        ?    10066           
=======================================
  Hits            ?    34707           
  Misses          ?    16854           
  Partials        ?     5204           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rot127
Rot127 merged commit 8149777 into capstone-engine:next Oct 9, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants