Skip to content

Commit ed10309

Browse files
emilybaoTylerMSFT
andauthored
Add Arm64 forceInterlockedFunctions option (#5822)
* Learn Editor: Update compiler-options-listed-by-category.md * Learn Editor: Update compiler-options-listed-alphabetically.md * Learn Editor: Update force-interlocked-functions.md * Learn Editor: Update force-interlocked-functions.md * update Metadata * Update force-interlocked-functions.md with github id author name * Reorder compiler options in toc.yml to be alphabetical * Learn Editor: Update compiler-options-listed-alphabetically.md * Learn Editor: Update compiler-options-listed-by-category.md * Learn Editor: Update force-interlocked-functions.md * change article metadata * Learn Editor: Update force-interlocked-functions.md * Fix casing in toc.yml for forceInterlockedFunctions * Add 'items' section to toc.yml to revert previous change * Fix indentation in toc.yml file * Update metadata and improve documentation wording * Update metadata in force-interlocked-functions.md tidied up metdata * Fix typos and improve clarity in documentation * Update description for `/forceInterlockedFunctions` option * Clarify CPU capability/ runtime description in documentation * Update remark on Armv8.0 instructions * Remove unneeded template comments and update livelock remarks in documentation * Add "---" to metadata --------- Co-authored-by: Tyler Whitney <[email protected]>
1 parent 2e58356 commit ed10309

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

docs/build/reference/compiler-options-listed-alphabetically.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
6767
| [`/Fd`](fd-program-database-file-name.md) | Renames program database file. |
6868
| [`/Fe`](fe-name-exe-file.md) | Renames the executable file. |
6969
| [`/feature`](feature-arm64.md) | Enable architecture features.<sup>17.10</sup> |
70+
| [`/forceInterlockedFunctions`](force-interlocked-functions.md) | Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 LSE atomic instructions based on target CPU.<sup>17.14</sup> |
7071
| [`/FI<file>`](fi-name-forced-include-file.md) | Preprocesses the specified include file. |
7172
| [`/Fi`](fi-preprocess-output-file-name.md) | Specifies the preprocessed output file name. |
7273
| [`/Fm`](fm-name-mapfile.md) | Creates a mapfile. |
@@ -261,6 +262,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
261262
| [`/ZW`](zw-windows-runtime-compilation.md) | Produces an output file to run on the Windows Runtime. |
262263

263264
<sup>17.10</sup> This option is available starting in Visual Studio 2022 version 17.10.
265+
<sup>17.14</sup> This option is available starting in Visual Studio 2022 version 17.14.
264266

265267
## See also
266268

docs/build/reference/compiler-options-listed-by-category.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This article contains a categorical list of compiler options. For an alphabetica
4444
| [`/EHr`](eh-exception-handling-model.md) | Always generate `noexcept` runtime termination checks. |
4545
| [`/EHs`](eh-exception-handling-model.md) | Enable C++ exception handling (no SEH exceptions). |
4646
| [`/feature`](feature-arm64.md) | Enable architecture features.<sup>17.10</sup> |
47+
| [`/forceInterlockedFunctions`](force-interlocked-functions.md) | Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 LSE atomic instructions based on target CPU.<sup>17.14</sup> |
4748
| [`/fp:contract`](fp-specify-floating-point-behavior.md) | Consider floating-point contractions when generating code. |
4849
| [`/fp:except[-]`](fp-specify-floating-point-behavior.md) | Consider floating-point exceptions when generating code. |
4950
| [`/fp:fast`](fp-specify-floating-point-behavior.md) | "fast" floating-point model; results are less predictable. |
@@ -329,6 +330,7 @@ Experimental options may only be supported by certain versions of the compiler.
329330
| [`/Zg`](zg-generate-function-prototypes.md) | Removed in Visual Studio 2015. Generates function prototypes. |
330331

331332
<sup>17.10</sup> This option is available starting in Visual Studio 2022 version 17.10.
333+
<sup>17.14</sup> This option is available starting in Visual Studio 2022 version 17.14.
332334

333335
## See also
334336

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "/forceInterlockedFunctions"
3+
description: "Learn more about /forceInterlockedFunctions"
4+
ms.date: 03/07/2025
5+
---
6+
# `/forceInterlockedFunctions`
7+
8+
Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 Large System Extension (LSE) atomic instructions based on CPU capability at runtime.
9+
10+
## Syntax
11+
12+
> **`/forceInterlockedFunctions`**[**`-`**]
13+
14+
## Remarks
15+
When possible, this flag avoids using Armv8.0 load and store exclusive instructions, as these instructions can result in livelocks.
16+
This flag forces the following interlocked intrinsics to be generated as out-of-line functions:
17+
18+
|Operation|8|16|32|64|128|Pointer|
19+
|-|-------|--------|--------|--------|-------|-------|
20+
|Add|None|None|Full|Full|None|None|
21+
|And|Full|Full|Full|Full|None|None|
22+
|CompareExchange|Full|Full|Full|Full|Full|Full|
23+
|Decrement|None|Full|Full|Full|None|None|
24+
|Exchange|Full|Full|Full|Full|None|Full|
25+
|ExchangeAdd|Full|Full|Full|Full|None|None|
26+
|Increment|None|Full|Full|Full|None|None|
27+
|Or|Full|Full|Full|Full|None|None|
28+
|Xor|Full|Full|Full|Full|None|None|
29+
|bittestandreset|None|None|Full|Full|None|None|
30+
|bittestandset|None|None|Full|Full|None|None|
31+
32+
Key:
33+
34+
- **Full**: supports plain, `_acq`, `_rel`, and `_nf` forms.
35+
36+
- **None**: Not supported
37+
38+
For more information about interlocked intrinsics, see the "Interlocked intrinsics" section in [Arm64 Intrinsics](../../intrinsics/arm64-intrinsics.md).
39+
40+
### To set the `/forceInterlockedFunctions` compiler option in Visual Studio
41+
42+
1. Open the **Property Pages** dialog box for the project. For more information, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
43+
44+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
45+
46+
1. In the **Additional options** box, add *`/forceInterlockedFunctions`* to enable. Choose **OK** to save your changes.
47+
48+
### To set this compiler option programmatically
49+
50+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
51+
52+
## See also
53+
[Arm64 Intrinsics](../../intrinsics/arm64-intrinsics.md)\
54+
[MSVC compiler options](compiler-options.md)\
55+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/build/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ items:
562562
href: ../build/reference/fc-full-path-of-source-code-file-in-diagnostics.md
563563
- name: /feature (Enable architecture features)
564564
href: ../build/reference/feature-arm64.md
565+
- name: /forceInterlockedFunctions (Generate and link with out-of-line atomic
566+
functions)
567+
href: ./reference/force-interlocked-functions.md
565568
- name: /fp (Specify floating-point behavior)
566569
href: ../build/reference/fp-specify-floating-point-behavior.md
567570
- name: /fpcvt (Floating-point to unsigned integer conversion behavior)

0 commit comments

Comments
 (0)