[compiler-rt] 1822bc1 - Remove `__cdecl` from _ReturnAddress (#72919)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 10:11:13 PST 2023


Author: nicole mazzuca
Date: 2023-11-22T10:11:09-08:00
New Revision: 1822bc15cb378458e942e405ae7da32ee75b8c5b

URL: https://github.com/llvm/llvm-project/commit/1822bc15cb378458e942e405ae7da32ee75b8c5b
DIFF: https://github.com/llvm/llvm-project/commit/1822bc15cb378458e942e405ae7da32ee75b8c5b.diff

LOG: Remove `__cdecl` from _ReturnAddress (#72919)

As an intrinsic, `_ReturnAddress` does not need it; additionally,
if someone else declares `_ReturnAddress` without `__cdecl` (for
example, `<intrin.h>`)

Additionally, actually add a test for this change. I've tested it
locally with both LLVM and MSVC.

Added: 
    compiler-rt/test/asan/TestCases/Windows/msvc/gz.cpp

Modified: 
    compiler-rt/include/sanitizer/common_interface_defs.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/include/sanitizer/common_interface_defs.h b/compiler-rt/include/sanitizer/common_interface_defs.h
index 56d9e008fa06e96..f9fce595b37bb89 100644
--- a/compiler-rt/include/sanitizer/common_interface_defs.h
+++ b/compiler-rt/include/sanitizer/common_interface_defs.h
@@ -293,7 +293,7 @@ void SANITIZER_CDECL __sanitizer_symbolize_global(void *data_ptr,
 #define __sanitizer_return_address()                                           \
   __builtin_extract_return_addr(__builtin_return_address(0))
 #else
-void *SANITIZER_CDECL _ReturnAddress(void);
+void *_ReturnAddress(void);
 #pragma intrinsic(_ReturnAddress)
 #define __sanitizer_return_address() _ReturnAddress()
 #endif

diff  --git a/compiler-rt/test/asan/TestCases/Windows/msvc/gz.cpp b/compiler-rt/test/asan/TestCases/Windows/msvc/gz.cpp
new file mode 100644
index 000000000000000..52a59d2fe335e7a
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/msvc/gz.cpp
@@ -0,0 +1,15 @@
+// Make sure that ASan works with non-cdecl default calling conventions.
+// Many x86 projects pass `/Gz` to their compiles, so that __stdcall is the default,
+// but LLVM is built with __cdecl.
+//
+// RUN: %clang_cl_asan -Gz %Od %s %Fe%t
+
+// includes a declaration of `_ReturnAddress`
+#include <intrin.h>
+
+#include <sanitizer/asan_interface.h>
+
+int main() {
+  alignas(8) char buffer[8];
+  __asan_poison_memory_region(buffer, sizeof buffer);
+}


        


More information about the llvm-commits mailing list