aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-19 14:25:05 +0100
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-19 17:05:53 +0100
commit95b27b2a1e0e9fe0781ec76015b4016b9d04423d (patch)
tree396ef12de63f4403d3425e94bc54e582ef20c71c /llvm/lib/CodeGen/MachineInstr.cpp
parent12aef5df0c7ee742a6c93215a189b4641748c8e7 (diff)
downloadllvm-95b27b2a1e0e9fe0781ec76015b4016b9d04423d.zip
llvm-95b27b2a1e0e9fe0781ec76015b4016b9d04423d.tar.gz
llvm-95b27b2a1e0e9fe0781ec76015b4016b9d04423d.tar.bz2
[llvm][ADT] Fix Any with msvc and lto
llvm::Any had and has several bugs, so we eventually want to replace it with std::any. Unfortunately, we cannot do that right now because of bugs in the msvc standard library that are only fixed in VS 2022 17.4. When lto is enabled in msvc, constant symbols end up at the same address, breaking the TypeId implementation of llvm::Any. Make the TypeId<T>::Id non-const to fix this. I was able to find an easy reproducer (tried in godbolt with x64 msvc v19.32 and `/GL` as compiler flags to enable lto): ```c++ template <typename T> struct TypeId { // Remove the const here and below to make it work. static const char Id; }; template <typename T> const char TypeId<T>::Id = 0; template <typename A, typename B> bool isSame() { return &TypeId<A>::Id == &TypeId<B>::Id; } class A {}; class B {}; int main() { // This should output "is same 0" because the addresses of A's and B's // TypeId::Id should be different. printf("is same %d\n", isSame<A, B>()); return 0; } ``` Differential Revision: https://reviews.llvm.org/D139974
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
0 files changed, 0 insertions, 0 deletions