[llvm] fe1d115 - [KeyInstr] Fix DILocation AtomGroup/Rank bitfield packing for MSVC (#138292)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 00:52:08 PDT 2025


Author: Orlando Cazalet-Hyams
Date: 2025-05-06T08:52:05+01:00
New Revision: fe1d1159be269309b5cbb9889c7ebe99cebfd940

URL: https://github.com/llvm/llvm-project/commit/fe1d1159be269309b5cbb9889c7ebe99cebfd940
DIFF: https://github.com/llvm/llvm-project/commit/fe1d1159be269309b5cbb9889c7ebe99cebfd940.diff

LOG: [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).

Added: 
    

Modified: 
    llvm/include/llvm/IR/DebugInfoMetadata.h
    llvm/lib/IR/LLVMContextImpl.h

Removed: 
    


################################################################################
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<DILocation> {
   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<DILocation> {
 
   unsigned getHashValue() const {
     return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
-                        AtomRank);
+                        (uint8_t)AtomRank);
   }
 };
 


        


More information about the llvm-commits mailing list