[Compiler-rt][PATCH] Fix MSVC compilation of lib/profile/InstrProfData.inc

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 19 11:00:02 PST 2015


On Sat, Dec 19, 2015 at 10:27 AM, Johan Engelen <jbc.engelen at gmail.com> wrote:
> Hi all,
>   Here is another patch to fix building compiler-rt/lib/profile with MSVC.
>
> MSVC does not do pointer math on void* (InstrProfilingPlatformOther.c lines
> 37 and 39), and so the types of NamePtr and CounterPtr should be mentioned
> explicitly.
> Is there a reason why "IntPtrT" was used instead of specifying the types as
> is done in this patch? The LLVM calls (getInt8PtrTy) also explicitly contain
> the type size.
>

This patch is not correct. The reason IntPtrT is used is because the
file is shared across profiler runtime and LLVM.  In LLVM side, we
support reading profile generated by 64bit target on 32bit host (and
vice versa), so IntPtr needs to be a template parameter.

I will fix this issue for MSVC.


> With this patch, trunk works with MSVC, with these two remaining issues:
> 1. GCDAProfiling.c does not compile, because it includes <sys/mman.h> and
> <sys/file.h> that are not available with MSVC.

This is legacy runtime producing GCC compatible format. Need to figure
out a way to make it build for MSVC though.

> 2. COMPILER_RT_HAS_ATOMICS should not be 1 for MSVC. Unfortunately, MSVC
> does not have a drop-in replacement for GCC's __sync_bool_compare_and_swap,
> and so a fix is non-trivial.

How about InterlockedCompareExchange?

David


>
> Thanks,
>   Johan
>


More information about the llvm-commits mailing list