Page MenuHomePhabricator

[MCA] Fix MSVC 19.16 build with libc++
ClosedPublic

Authored by orivej on Aug 6 2019, 9:17 PM.

Details

Summary

MSVC (19.16) wants to see the definition of Instruction in std::pair<unsigned, const Instruction &> SourceRef to decide if it is assignable:

libcxx/include/type_traits:2209: error C2139: 'llvm::mca::Instruction': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_assignable'
llvm/include/llvm/mca/sourcemgr.h:31: note: see declaration of 'llvm::mca::Instruction'
libcxx/include/type_traits:2226: note: see reference to class template instantiation 'std::is_assignable<const llvm::mca::Instruction &,const llvm::mca::Instruction &>' being compiled
libcxx/include/utility:524: note: see reference to class template instantiation 'std::is_copy_assignable<const llvm::mca::Instruction &>' being compiled
llvm/include/llvm/mca/sourcemgr.h:51: note: see reference to class template instantiation 'std::pair<unsigned int,const llvm::mca::Instruction &>' being compiled

Diff Detail

Repository
rL LLVM

Event Timeline

orivej created this revision.Aug 6 2019, 9:17 PM
andreadb accepted this revision.Aug 7 2019, 4:13 AM
andreadb added a subscriber: gbedwell.

A colleague ( @gbedwell ) pointed out that this is likely to be the same MSVC bug originally reported here:
https://developercommunity.visualstudio.com/content/problem/343550/webkit-an-undefined-class-is-not-allowed-as-an-arg.html.

That issue has been fixed by a more recent version of MSVC (presumably 19.20)
https://godbolt.org/resetlayout/vka9Vf

If that's the case, then your change is a good workaround. Maybe add a comment to the new include mentioning the problematic MSVC version, so that we can re-evaluate it in future.

Thanks!
-Andrea

This revision is now accepted and ready to land.Aug 7 2019, 4:13 AM
orivej updated this revision to Diff 214282.Aug 8 2019, 7:18 PM
orivej retitled this revision from [MCA] Fix MSVC build with libc++ to [MCA] Fix MSVC 19.16 build with libc++.

Add a comment that this affects only MSVC >= 19.15, < 19.20.

orivej added a comment.Aug 8 2019, 7:19 PM

Could you commit this on my behalf? Please edit the comment if you wish.

Could you commit this on my behalf? Please edit the comment if you wish.

Sure. I'll commit it on your behalf.
That code comment is perfect. Thanks!

Closed by commit rL368436: [MCA] Fix MSVC 19.16 build with libc++ (authored by adibiagio, committed by ). · Explain WhyAug 9 2019, 5:40 AM
This revision was automatically updated to reflect the committed changes.