================
@@ -4055,6 +4055,115 @@ template<typename T> constexpr T *addressof(T &value) {
}
```
+### `__addrspaceof`
+
+`__addrspaceof` returns a Clang address-space identifier for a type, object, or
+lvalue expression.
+
+This is useful for performance-sensitive code that needs a compile-time value
+to choose an address-space-specific operation, overload, or template
+specialization. For example, GPU code may select different loads for global,
+shared/local, or constant memory.
+
+**Syntax**:
+
+```c++
+int __addrspaceof(type-or-expression)
+```
+
+The parentheses are required. The operand is not evaluated. The result is an
----------------
AaronBallman wrote:
What happens if the operand is a VLA that would normally require evaluation?
e.g.,
```
int vla = 1;
int val = __addrspaceof(int[vla++]);
```
https://github.com/llvm/llvm-project/pull/210242
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits