This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [profile] fix profile generate for mingw x86_64
ClosedPublic

Authored by SquallATF on Jul 28 2020, 7:52 AM.

Details

Summary

mingw will use __sync_fetch_and_add for atomic, but on 64bit target the pointer will cast to long and the high 32 bits of the pointer will be lost. so mingw should use the same logic as msvc

Diff Detail

Event Timeline

SquallATF created this revision.Jul 28 2020, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2020, 7:52 AM
Herald added subscribers: Restricted Project, mstorsjo, jfb and 2 others. · View Herald Transcript
SquallATF requested review of this revision.Jul 28 2020, 7:52 AM
mstorsjo added inline comments.
compiler-rt/lib/profile/CMakeLists.txt
4

I think this one needs to be lowercased to work properly in mingw cross compile setups.

compiler-rt/lib/profile/InstrProfilingPort.h
58

Can this cause warnings if _MSC_VER isn't defined? Would it be safer to change it into #if defined(_MSC_VER) && _MSC_VER < 1900?

SquallATF edited the summary of this revision. (Show Details)Jul 28 2020, 6:35 PM
amccarth accepted this revision.Jul 29 2020, 8:50 AM

LGTM.

compiler-rt/lib/profile/InstrProfilingPort.h
58

Technically not necessary, since the preprocessor will replace any unrecognized macro name in a #if- or #elif-conditional with 0. But I believe this makes the intent clearer.

This revision is now accepted and ready to land.Jul 29 2020, 8:50 AM
This revision was landed with ongoing or failed builds.Jul 30 2020, 1:40 PM
This revision was automatically updated to reflect the committed changes.
mstorsjo added a subscriber: hans.Jul 30 2020, 1:42 PM

@hans - @SquallATF wants this one backported to the 11.x release branch, which I think is reasonable - but maybe after waiting for a day or two in case there's any surprise.

hans added a comment.Jul 31 2020, 8:38 AM

@hans - @SquallATF wants this one backported to the 11.x release branch, which I think is reasonable - but maybe after waiting for a day or two in case there's any surprise.

Thanks! I've put it on my list.

hans added a comment.Aug 5 2020, 10:53 AM

@hans - @SquallATF wants this one backported to the 11.x release branch, which I think is reasonable - but maybe after waiting for a day or two in case there's any surprise.

Thanks! I've put it on my list.

Pushed to 11.x as a862618aab2551540e175dff3a6a1d1d7c4b4a29