Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[KeyInstr] Fix DILocation AtomGroup/Rank bitfield packing for MSVC #138292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented May 2, 2025

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).

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).
@llvmbot
Copy link
Member

llvmbot commented May 2, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-ir

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

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).


Full diff: https://github.com/llvm/llvm-project/pull/138292.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+1-1)
  • (modified) llvm/lib/IR/LLVMContextImpl.h (+2-2)
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);
   }
 };
 

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OCHyams OCHyams merged commit fe1d115 into llvm:main May 6, 2025
14 checks passed
OCHyams added a commit to OCHyams/llvm-project that referenced this pull request May 6, 2025
…lvm#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).
OCHyams added a commit to OCHyams/llvm-project that referenced this pull request May 6, 2025
…lvm#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).
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
…lvm#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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants