From be31da677cd8d5a3df9e86a9c3c1afcdc1acd746 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Fri, 2 May 2025 08:55:48 +0100 Subject: [PATCH] [KeyInstr] Fix DILocation AtomGroup/Rank bitfield packing for MSVC 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). --- llvm/include/llvm/IR/DebugInfoMetadata.h | 2 +- llvm/lib/IR/LLVMContextImpl.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 91cda271f498b..0f6a206cab75f 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2237,7 +2237,7 @@ class DILocation : public MDNode { friend class MDNode; #ifdef EXPERIMENTAL_KEY_INSTRUCTIONS uint64_t AtomGroup : 61; - uint8_t AtomRank : 3; + uint64_t AtomRank : 3; #endif DILocation(LLVMContext &C, StorageType Storage, unsigned Line, diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index ad5fb802029fe..7b2ff6cf80972 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -316,7 +316,7 @@ template <> struct MDNodeKeyImpl { Metadata *InlinedAt; bool ImplicitCode; uint64_t AtomGroup : 61; - uint8_t AtomRank : 3; + uint64_t AtomRank : 3; MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup, @@ -338,7 +338,7 @@ template <> struct MDNodeKeyImpl { unsigned getHashValue() const { return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup, - AtomRank); + (uint8_t)AtomRank); } };