[llvm] [IR] Composable and Extensible Memory Cache Control Hints (PR #181612)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 02:53:31 PDT 2026


================
@@ -7769,6 +7769,73 @@ The ``!captures`` attribute makes no statement about other uses of ``%x``, or
 uses of the stored-to memory location after it has been overwritten with a
 different value.
 
+'``mem.cache_hint``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``!mem.cache_hint`` metadata may be attached to any instruction that reads
+or writes memory. It provides target-specific cache control hints for the
+memory operation. This metadata is a performance hint: dropping or ignoring it
+must not change the observable behavior of the program.
+
+The value of ``!mem.cache_hint`` is a single metadata node containing a flat
+list of ``(operand_no, hint_node)`` pairs. Each ``operand_no`` is an ``i32``
+constant that is the raw IR operand index (for regular instructions) or the
+argument index (for intrinsic calls) of a pointer-typed operand. Each
----------------
antoniofrighetto wrote:

Was not immediately clear to me, how about the following? (Also shouldn't it be quite implicit the operand index is an unsigned?)
```suggestion
list of ``(operand_no, hint_node)`` pairs. For non-call instructions, ``operand_no`` is the IR operand index. For intrinsic calls, ``operand_no`` is the call argument index. Each
```

https://github.com/llvm/llvm-project/pull/181612


More information about the llvm-commits mailing list