Skip to content

[NFC][DebugInfo] Make MDNodeKeyImpl<DILocation>::Column 16 bits #143399

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 2 commits into from
Jun 10, 2025

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Jun 9, 2025

Column is limited to 16 bits in several places in the compiler:

SubclassData16 = Column;

ColumnField() : MDUnsignedField(0, UINT16_MAX) {}

Slight compile time improvement due to reducing hash_combine workload in MDNodeKeyImpl<DILocation>::getHashValue().

https://llvm-compile-time-tracker.com/compare.php?from=2b7b0e178259a910355631d7d648c89052000872&to=89490929c34f45842df1588cf78d836f51c2c222&stat=instructions%3Au

(positively affects compile time regardless of whether Key Instructions is enabled)

@OCHyams OCHyams requested review from nikic, jmorse and SLTozer June 9, 2025 15:33
@llvmbot llvmbot added the llvm:ir label Jun 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 9, 2025

@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-debuginfo

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

Column is limited to 16 bits in several places in the compiler:

SubclassData16 = Column;

ColumnField() : MDUnsignedField(0, UINT16_MAX) {}

Slight compile time improvement due to reducing hash_combine workload in MDNodeKeyImpl&lt;DILocation&gt;::getHashValue().

https://llvm-compile-time-tracker.com/compare.php?from=2b7b0e178259a910355631d7d648c89052000872&amp;to=89490929c34f45842df1588cf78d836f51c2c222&amp;stat=instructions%3Au

(positively affects compile time regardless of whether Key Instructions is enabled)


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

1 Files Affected:

  • (modified) llvm/lib/IR/LLVMContextImpl.h (+1-1)
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 7b6083a7a3496..946dc3188aeb1 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -311,7 +311,7 @@ template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
 /// DenseMapInfo for DILocation.
 template <> struct MDNodeKeyImpl<DILocation> {
   unsigned Line;
-  unsigned Column;
+  uint16_t Column;
   Metadata *Scope;
   Metadata *InlinedAt;
   bool ImplicitCode;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM, though I wonder whether we should also change the ctor to accept uint16_t?

@OCHyams OCHyams merged commit f0d05b9 into llvm:main Jun 10, 2025
7 checks passed
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…#143399)

Column is limited to 16 bits in several places in the compiler:
DebugInfoMetadata.cpp#L87, LLParser.cpp#L4706, and more

Slight compile time improvement due to reducing `hash_combine` workload
in `MDNodeKeyImpl<DILocation>::getHashValue()`.

Positively affects compile time regardless of whether Key Instructions
is enabled. See PR for numbers.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…#143399)

Column is limited to 16 bits in several places in the compiler:
DebugInfoMetadata.cpp#L87, LLParser.cpp#L4706, and more

Slight compile time improvement due to reducing `hash_combine` workload
in `MDNodeKeyImpl<DILocation>::getHashValue()`.

Positively affects compile time regardless of whether Key Instructions
is enabled. See PR for numbers.
OCHyams added a commit to OCHyams/llvm-project that referenced this pull request Jun 16, 2025
Set LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS=ON by default. This enables support for
Key Instructions in LLVM by default, it does not enable the feature by default.

This does have an affect on compile time, which looks to have mostly been
"paid for" (if that argument stands) by my PR llvm#143399.

From compile-time-tracker:

1. this patch
2. PR llvm#143399
3. base
```
    Commit  stage1-O3  stage1-ReleaseThinLTO  stage1-ReleaseLTO-g  stage1-O0-g  stage1-aarch64-O3  stage1-aarch64-O0-g  stage2-O3      stage2-O0-g      stage2-clang
        1.  61213M (+0.02%)  77397M (+0.01%)  89413M (+0.08%)  18865M (+0.13%)  68670M (+0.01%)  23100M (+0.12%)  53409M (+0.00%)  16550M (+0.20%)  34060797M (+0.02%)
	2.  61201M (-0.01%)  77389M (+0.00%)  89343M (-0.06%)  18841M (-0.16%)  68666M (+0.00%)  23073M (-0.16%)  53408M (-0.01%)  16518M (+0.01%)  34054978M (+0.00%)
	3.  61207M (+0.00%)  77386M (-0.01%)  89396M (-0.02%)  18871M (-0.02%)  68665M (+0.01%)  23109M (+0.02%)  53415M (-0.02%)  16516M (-0.00%)  34054300M (-0.00%)
```

Compare 2-1: https://llvm-compile-time-tracker.com/compare.php?from=89490929c34f45842df1588cf78d836f51c2c222&to=7d00712c28bbcc8a8e00d672f2f7c109fb5823c9&stat=instructions%3Au
Compare 3-2: https://llvm-compile-time-tracker.com/compare.php?from=2b7b0e178259a910355631d7d648c89052000872&to=89490929c34f45842df1588cf78d836f51c2c222&stat=instructions%3Au
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.

3 participants