[libcxx-commits] [libcxx] [libc] Adjust inline assembly constraints for the AMDGPU target (PR #101747)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 2 13:23:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
Summary:
These assembly constraints are illegal / invalid on the AMDGPU target.
The `r` constraint is only valid on inputs and the `m` constraint isn't
accepted at all. The NVPTX target can handle them because it uses a more
permissive virtual machine (PTX is an IR). Simply add exceptions on the
target to make these work.
---
Full diff: https://github.com/llvm/llvm-project/pull/101747.diff
1 Files Affected:
- (modified) libcxx/test/support/test_macros.h (+13-5)
``````````diff
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 15fc5b69b5207..65037d03b9567 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -291,17 +291,25 @@ struct is_same<T, T> { enum {value = 1}; };
// when optimizations are enabled.
template <class Tp>
inline Tp const& DoNotOptimize(Tp const& value) {
- asm volatile("" : : "r,m"(value) : "memory");
- return value;
+ // The `m` constraint is invalid in the AMDGPU backend.
+# if defined(__AMDGPU__) || defined(__NVPTX__)
+ asm volatile("" : : "r"(value) : "memory");
+# else
+ asm volatile("" : : "r,m"(value) : "memory");
+# endif
+ return value;
}
template <class Tp>
inline Tp& DoNotOptimize(Tp& value) {
-#if defined(__clang__)
+ // The `m` and `r` output constraint is invalid in the AMDGPU backend.
+# if defined(__AMDGPU__)
+ asm volatile("" : "+v"(value) : : "memory");
+# elif defined(__clang__)
asm volatile("" : "+r,m"(value) : : "memory");
-#else
+# else
asm volatile("" : "+m,r"(value) : : "memory");
-#endif
+# endif
return value;
}
#else
``````````
</details>
https://github.com/llvm/llvm-project/pull/101747
More information about the libcxx-commits
mailing list