[compiler-rt] Changes to support running tests for Windows arm64 asan (PR #66973)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 20:03:42 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
<details>
<summary>Changes</summary>
1. Differentiate SANITIZER_WINDOWS64 for x64 and arm64
2. fix A Warning where asserts needs messages
3. turn of interception tests that expect x86 assembly
4. After this change I can now build compiler-rt\lib\asan\tests\AARCH64WindowsConfig\Asan-aarch64-inline-Noinst-Test.exe
---
Full diff: https://github.com/llvm/llvm-project/pull/66973.diff
4 Files Affected:
- (modified) compiler-rt/lib/interception/interception_win.cpp (+3-3)
- (modified) compiler-rt/lib/interception/tests/interception_win_test.cpp (+2)
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h (+1-1)
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform.h (+8)
``````````diff
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index b2ba40902347f46..1e178f516c49d8b 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -1,4 +1,4 @@
-//===-- interception_linux.cpp ----------------------------------*- C++ -*-===//
+//===-- interception_win.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -462,7 +462,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
return 4;
#endif
-#if SANITIZER_WINDOWS64
+#if SANITIZER_WINDOWSx64
if (memcmp((u8*)address, kPrologueWithShortJump1,
sizeof(kPrologueWithShortJump1)) == 0 ||
memcmp((u8*)address, kPrologueWithShortJump2,
@@ -544,7 +544,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
return 7;
}
-#if SANITIZER_WINDOWS64
+#if SANITIZER_WINDOWSx64
switch (*(u8*)address) {
case 0xA1: // A1 XX XX XX XX XX XX XX XX :
// movabs eax, dword ptr ds:[XXXXXXXX]
diff --git a/compiler-rt/lib/interception/tests/interception_win_test.cpp b/compiler-rt/lib/interception/tests/interception_win_test.cpp
index 9159ce405f2dc49..629cdf437f342ec 100644
--- a/compiler-rt/lib/interception/tests/interception_win_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_win_test.cpp
@@ -17,6 +17,7 @@
// Too slow for debug build
#if !SANITIZER_DEBUG
#if SANITIZER_WINDOWS
+#if !SANITIZER_WINDOWSARM64
#include <stdarg.h>
@@ -793,5 +794,6 @@ TEST(Interception, EmptyExportTable) {
} // namespace __interception
+#endif // !SANITIZER_WINDOWSARM64
#endif // SANITIZER_WINDOWS
#endif // #if !SANITIZER_DEBUG
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index fa43ac50c61e4f4..c1c7e4c4cda2c80 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -636,7 +636,7 @@ class SizeClassAllocator64 {
}
uptr SpaceEnd() const { return SpaceBeg() + kSpaceSize; }
// kRegionSize should be able to satisfy the largest size class.
- static_assert(kRegionSize >= SizeClassMap::kMaxSize);
+ static_assert(kRegionSize >= SizeClassMap::kMaxSize, "kRegionSize must satisfy largest class size");
// kRegionSize must be <= 2^36, see CompactPtrT.
COMPILER_CHECK((kRegionSize) <= (1ULL << (SANITIZER_WORDSIZE / 2 + 4)));
// Call mmap for user memory with at least this size.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index c1ca5c9ca44783b..55f3d0b846853e6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -260,6 +260,14 @@
# define SANITIZER_ARM64 0
#endif
+#if SANITIZER_WINDOWS64 && SANITIZER_ARM64
+# define SANITIZER_WINDOWSARM64 1
+# define SANITIZER_WINDOWSx64 0
+#else
+# define SANITIZER_WINDOWSARM64 0
+# define SANITIZER_WINDOWSx64 1
+#endif
+
#if SANITIZER_SOLARIS && SANITIZER_WORDSIZE == 32
# define SANITIZER_SOLARIS32 1
#else
``````````
</details>
https://github.com/llvm/llvm-project/pull/66973
More information about the llvm-commits
mailing list