Repository navigation
Deduplicate assembly macros between CoreCLR and NativeAOT - #136638
Merged
Merged
Conversation
- Move the common Unix macros into runtime/<arch>/UnixAsmMacros.inc. - Move the common Windows macros into runtime/amd64/AsmMacros_Common.inc, runtime/arm64/AsmMacros_Common.h and runtime/i386/AsmMacros_Common.inc. - Use the shared argument register save/restore macros in NativeAOT GcProbe and UniversalTransition. - Delete the unused runtime/<arch>/StubDispatch files.
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
jkotas
reviewed
Oct 29, 2026
jkotas
reviewed
Oct 29, 2026
Move the general-purpose macros that only one runtime defined (prolog and epilog helpers, register save and restore helpers, entry/end/label macros, barriers, PREPARE_EXTERNAL_VAR variants, nop and return encodings) into the shared per-architecture macro files, including the identical MOVL64, PREPARE_EXTERNAL_VAR_INDIRECT(_W) and InterlockedOperationBarrier copies in CoreCLR's AsmMacros_Shared.h. The shared Windows arm64 INLINE_GET_TLS_VAR declares the TLS variable as EXTERN itself again, so its callers no longer need to.
jkotas
reviewed
Oct 29, 2026
Drop the unused NativeAOT-only '.global _Name' on amd64, and use .hidden for LEAF_ENTRY in both runtimes on arm64 and loongarch64 (matching ALTERNATE_ENTRY).
jkotas
reviewed
Oct 29, 2026
The DAC exports the LEAF_ENTRY stubs generated from libredefines.inc, so .hidden broke linking libmscordbi.so against libmscordaccore.so.
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
jkotas
reviewed
Oct 30, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The shared ARM64 macro changes NativeAOT’s breakpoint encoding, so its objects cannot be byte-identical to the previous ones as claimed.
1 open issue
What changed in this PR
This PR separates assembly-macro deduplication from #136626, moving common definitions into CoreCLR’s shared runtime directory so CoreCLR and NativeAOT use the same implementations.
Changes:
- Consolidates Unix and Windows assembly macros and updates their consumers.
- Reuses argument-register save/restore macros in NativeAOT helpers, with related unwind and label adjustments.
- Removes unused dispatch-stub files and their build entry.
| File | Description |
|---|---|
| src/coreclr/vm/i386/AsmMacros.inc | Uses shared Windows x86 macros. |
| src/coreclr/vm/arm64/asmmacros.h | Uses shared Windows ARM64 macros. |
| src/coreclr/vm/arm64/AsmMacros_Shared.h | Removes definitions moved into shared includes. |
| src/coreclr/vm/amd64/AsmMacros.inc | Uses shared Windows AMD64 macros. |
| src/coreclr/runtime/s390x/StubDispatch.S | Removes unused stub file. |
| src/coreclr/runtime/riscv64/StubDispatch.S | Removes unused dispatch implementation. |
| src/coreclr/runtime/riscv64/InlineTls.inc | Moves TLS macro into the shared architecture include. |
| src/coreclr/runtime/riscv64/AsmMacros_Unix.inc | Centralizes RISC-V Unix macros. |
| src/coreclr/runtime/ppc64le/StubDispatch.S | Removes unused stub file. |
| src/coreclr/runtime/loongarch64/StubDispatch.S | Removes unused dispatch implementation. |
| src/coreclr/runtime/loongarch64/InlineTls.inc | Moves TLS macro into the shared architecture include. |
| src/coreclr/runtime/loongarch64/AsmMacros_Unix.inc | Centralizes LoongArch64 Unix macros. |
| src/coreclr/runtime/i386/StubDispatch.S | Removes unused placeholder. |
| src/coreclr/runtime/i386/StubDispatch.asm | Removes unused Windows dispatch implementation. |
| src/coreclr/runtime/i386/AsmMacros_Windows.inc | Centralizes Windows x86 macros and constants. |
| src/coreclr/runtime/i386/AsmMacros_Unix.inc | Centralizes Unix x86 macros. |
| src/coreclr/runtime/AsmMacros_Unix.inc | Shares architecture-independent Unix definitions. |
| src/coreclr/runtime/arm64/AsmMacros_Windows.h | Centralizes Windows ARM64 macros. |
| src/coreclr/runtime/arm64/AsmMacros_Unix.inc | Centralizes Unix ARM64 macros. |
| src/coreclr/runtime/arm/StubDispatch.S | Removes unused dispatch implementation. |
| src/coreclr/runtime/arm/AsmMacros_Unix.inc | Centralizes Unix ARM macros. |
| src/coreclr/runtime/amd64/AsmMacros_Windows.inc | Centralizes Windows AMD64 macros. |
| src/coreclr/runtime/amd64/AsmMacros_Unix.inc | Centralizes Unix AMD64 macros. |
| src/coreclr/pal/src/arch/loongarch64/callsignalhandlerwrapper.S | Removes redundant unwind-offset adjustment. |
| src/coreclr/pal/inc/unixasmmacrosx86.inc | Imports shared x86 definitions. |
| src/coreclr/pal/inc/unixasmmacrosriscv64.inc | Imports shared RISC-V definitions. |
| src/coreclr/pal/inc/unixasmmacrosloongarch64.inc | Imports shared LoongArch64 definitions. |
| src/coreclr/pal/inc/unixasmmacrosarm64.inc | Imports shared ARM64 definitions. |
| src/coreclr/pal/inc/unixasmmacrosarm.inc | Imports shared ARM definitions. |
| src/coreclr/pal/inc/unixasmmacrosamd64.inc | Imports shared AMD64 definitions. |
| src/coreclr/pal/inc/unixasmmacros.inc | Imports common Unix definitions. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosx86.inc | Replaces duplicated macros with shared include. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosriscv64.inc | Imports shared macros and uses the fp alias. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc | Replaces duplicated macros with shared include. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosarm64.inc | Replaces duplicated macros with shared include. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosarm.inc | Replaces duplicated macros with shared include. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosamd64.inc | Replaces duplicated macros with shared include. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacros.inc | Imports common Unix definitions. |
| src/coreclr/nativeaot/Runtime/riscv64/UniversalTransition.S | Uses shared argument save/restore macros. |
| src/coreclr/nativeaot/Runtime/riscv64/ExceptionHandling.S | Adapts stack adjustments to shared unwind conventions. |
| src/coreclr/nativeaot/Runtime/loongarch64/UniversalTransition.S | Uses shared argument-save macros. |
| src/coreclr/nativeaot/Runtime/loongarch64/ExceptionHandling.S | Adapts stack adjustments to shared unwind conventions. |
| src/coreclr/nativeaot/Runtime/i386/AsmMacros.inc | Imports shared Windows x86 definitions. |
| src/coreclr/nativeaot/Runtime/CMakeLists.txt | Removes the dispatch-stub build entry. |
| src/coreclr/nativeaot/Runtime/arm64/UniversalTransition.S | Uses shared floating-point save/restore macros. |
| src/coreclr/nativeaot/Runtime/arm64/ThunkPoolThunks.S | Defines the thunk-pool label explicitly. |
| src/coreclr/nativeaot/Runtime/arm64/GcProbe.S | Reuses floating-point argument macros. |
| src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h | Imports shared Windows ARM64 definitions. |
| src/coreclr/nativeaot/Runtime/amd64/UniversalTransition.S | Defines floating-point save-area size locally. |
| src/coreclr/nativeaot/Runtime/amd64/ThunkPoolThunks.S | Defines the thunk-pool label explicitly. |
| src/coreclr/nativeaot/Runtime/amd64/GcProbe.S | Uses shared macros with register-ordered save slots. |
| src/coreclr/nativeaot/Runtime/amd64/AsmMacros.inc | Imports shared Windows AMD64 definitions. |
Review effort: Balanced
steveisok
added a commit
that referenced
this pull request
Nov 1, 2026
<!-- --> Add the shared `AsmMacros_Unix.inc` and its six architecture-specific files to the universal DBI source manifest using exact paths, without importing unrelated runtime implementation files. This fixes the missing assembly macro dependency closure behind the Unix universal DBI mirror build failures in [dotnet/diagnostics#6167](dotnet/diagnostics#6167) after [#136638](#136638). Existing include paths remain unchanged. Validation: manifest-produced `git archive` snapshots reproduced the missing include before the fix and passed all 18 PAL macro preprocessing checks afterward. Six Linux/macOS PAL assembly smoke checks passed. Full CoreCLR/diagnostics builds were not run; RISC-V assembly was blocked by installed Apple clang support, and LoongArch assembly was not run. Both passed preprocessing. > [!NOTE] > This PR was prepared by GitHub Copilot. Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Split out of #136626 per review feedback.
unixasmmacros*.incintoruntime/<arch>/UnixAsmMacros.inc(amd64, arm, arm64, loongarch64, riscv64).runtime/amd64/AsmMacros_Common.inc,runtime/arm64/AsmMacros_Common.h(SETALIAS,INLINE_GET_TLS_VAR) andruntime/i386/AsmMacros_Common.inc(ALTERNATE_ENTRY).runtime/<arch>/StubDispatch.*files.Validated by building linux-x64 CoreCLR + NativeAOT and running P/Invoke, stack probe/GC poll and EH tests. I also cross-assembled all Unix .S files for amd64/arm/arm64/loongarch64/riscv64 (+ Apple, release and emulated TLS variants) before and after, and the objects are byte-identical except NativeAOT amd64
GcProbe.S, where the xmm save slots are now in register order. The Windows MASM parts were checked with llvm-ml/preprocessor comparisons (real ml64/armasm64 are not available locally).