Following on from https://reviews.llvm.org/D96120, this allows scudo to be used as a memory allocator for Windows.
For example, adding:
-DLLVM_INTEGRATED_CRT_ALLOC="<folder>/llvm-project/stage1/lib/clang/13.0.0/lib/windows/clang_rt.scudo-x86_64.lib"
Note that -DLLVM_INTEGRATED_CRT_ALLOC only allows hooking in C library so this doesn't replace C++ new/delete etc.
check-all passes with scudo. Intermittently see failures in:
ExecutionEngine/MCJIT/test-global-init-nonzero-sm-pic.ll ExecutionEngine/MCJIT/test-ptr-reloc-sm-pic.ll ExecutionEngine/MCJIT/multi-module-sm-pic-a.ll ExecutionEngine/MCJIT/cross-module-sm-pic-a.ll
Which appear to be due to https://bugs.llvm.org/show_bug.cgi?id=24978 (see analysis here: https://reviews.llvm.org/D86694#2539630). This bug happens more frequently with Scudo due to the difference in allocated addresses.
Strangely we don't #include <rpnew.h>[1] anywhere when activating rpmalloc, and that still works (I don't see calls to Win32 Heap functions in the profile traces, only calls to rpmalloc functions). I think this is because the default behavior of the Windows CRT new/delete is to call malloc/free. So I'm not quite sure in which situation we need clang_rt.scudo_cxx / if it is needed here?
[1] https://github.com/mjansson/rpmalloc/blob/develop/rpmalloc/rpnew.h