Skip to content

Commit 6ee5f03

Browse files
committed
[KeyInstr] Fix DILocation AtomGroup/Rank bitfield packing for MSVC (llvm#138292)
Follow up to llvm#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 2f40963 commit 6ee5f03

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
@@ -2090,7 +2090,7 @@ class DILocation : public MDNode {
20902090
friend class MDNode;
20912091
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
20922092
uint64_t AtomGroup : 61;
2093-
uint8_t AtomRank : 3;
2093+
uint64_t AtomRank : 3;
20942094
#endif
20952095

20962096
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
@@ -320,7 +320,7 @@ template <> struct MDNodeKeyImpl<DILocation> {
320320
Metadata *InlinedAt;
321321
bool ImplicitCode;
322322
uint64_t AtomGroup : 61;
323-
uint8_t AtomRank : 3;
323+
uint64_t AtomRank : 3;
324324

325325
MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
326326
Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup,
@@ -342,7 +342,7 @@ template <> struct MDNodeKeyImpl<DILocation> {
342342

343343
unsigned getHashValue() const {
344344
return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
345-
AtomRank);
345+
(uint8_t)AtomRank);
346346
}
347347
};
348348

0 commit comments

Comments
 (0)