Skip to content

Commit fe1d115

Browse files
authored
[KeyInstr] Fix DILocation AtomGroup/Rank bitfield packing for MSVC (#138292)
Follow up to #133477. As nikic pointed out: We need to use uint64_t for both fields to get actual bit packing with msvc (https://c.godbolt.org/z/1f556c1zb). The cast to u8 in hash_combine prevents an increase in compile time (+0.16% for stage1-O0-g on compile-time-tracker).
1 parent 91ad90b commit fe1d115

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ class DILocation : public MDNode {
22372237
friend class MDNode;
22382238
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
22392239
uint64_t AtomGroup : 61;
2240-
uint8_t AtomRank : 3;
2240+
uint64_t AtomRank : 3;
22412241
#endif
22422242

22432243
DILocation(LLVMContext &C, StorageType Storage, unsigned Line,

llvm/lib/IR/LLVMContextImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ template <> struct MDNodeKeyImpl<DILocation> {
316316
Metadata *InlinedAt;
317317
bool ImplicitCode;
318318
uint64_t AtomGroup : 61;
319-
uint8_t AtomRank : 3;
319+
uint64_t AtomRank : 3;
320320

321321
MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
322322
Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup,
@@ -338,7 +338,7 @@ template <> struct MDNodeKeyImpl<DILocation> {
338338

339339
unsigned getHashValue() const {
340340
return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
341-
AtomRank);
341+
(uint8_t)AtomRank);
342342
}
343343
};
344344

0 commit comments

Comments
 (0)