aboutsummaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2023-07-11 00:30:01 -0700
committerShoaib Meenai <smeenai@fb.com>2023-07-11 09:39:25 -0700
commitcaf5b6a2121751ec6f0e9bf7c7984be229c685cc (patch)
treeab9addc8c4a6007b9c0e2b94b69da10014ff63fe /bolt
parent631576561ee2d3907f8038dac50e08b266311e12 (diff)
downloadllvm-caf5b6a2121751ec6f0e9bf7c7984be229c685cc.zip
llvm-caf5b6a2121751ec6f0e9bf7c7984be229c685cc.tar.gz
llvm-caf5b6a2121751ec6f0e9bf7c7984be229c685cc.tar.bz2
[bolt] Fix MSVC builds
We need to explicitly mark DWARFUnitInfo as non-copyable since MSVC's STL has a `noexcept(false)` move constructor for `unordered_map`; see the added comment for more details. An alternative might be using SmallVector instead of std::vector, since that never tries to copy elements [1]. That would result in a bunch of API changes though, so I figured a smaller targeted fix was better. [1] https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h Reviewed By: ayermolo, maksfb Differential Revision: https://reviews.llvm.org/D154924
Diffstat (limited to 'bolt')
-rw-r--r--bolt/include/bolt/Core/DIEBuilder.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/bolt/include/bolt/Core/DIEBuilder.h b/bolt/include/bolt/Core/DIEBuilder.h
index e2da876..2eac4ce 100644
--- a/bolt/include/bolt/Core/DIEBuilder.h
+++ b/bolt/include/bolt/Core/DIEBuilder.h
@@ -58,6 +58,20 @@ public:
// A map of DIE offsets in original DWARF section to DIE ID.
// Whih is used to access DieInfoVector.
std::unordered_map<uint64_t, uint32_t> DIEIDMap;
+
+ // Some STL implementations don't have a noexcept move constructor for
+ // unordered_map (e.g. https://github.com/microsoft/STL/issues/165 explains
+ // why the Microsoft STL doesn't). In that case, the default move
+ // constructor generated for DWARFUnitInfo isn't noexcept either, and thus
+ // resizing a vector of DWARFUnitInfo will copy elements instead of moving
+ // them (https://en.cppreference.com/w/cpp/utility/move_if_noexcept).
+ // DWARFUnitInfo isn't copyable though, since the DieInfoVector member is a
+ // vector of unique_ptrs and unique_ptr isn't copyable, so using a vector of
+ // DWARFUnitInfo causes build errors. Explicitly marking DWARFUnitInfo as
+ // non-copyable forces vector resizes to move instead and fixes the issue.
+ DWARFUnitInfo() = default;
+ DWARFUnitInfo(const DWARFUnitInfo &) = delete;
+ DWARFUnitInfo(DWARFUnitInfo &&) = default;
};
enum class ProcessingType { DWARF4TUs, DWARF5TUs, CUs };