-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Dwarf] Emit DW_AT_bit_size
for non-byte-sized types
#137118
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
Open
dtcxzyw
wants to merge
4
commits into
llvm:main
Choose a base branch
from
dtcxzyw:debuginfo-bitsize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+135
−0
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8d37b69
[InstCombine] Add pre-commit tests. NFC.
dtcxzyw 0eb30b7
[InstCombine] Update debug value uses in `freelyInvertAllUsersOf`
dtcxzyw 037aa20
[Dwarf] Emit `DW_AT_bit_size` for non-byte-sized types
dtcxzyw db3c8d6
[Dwarf] Remove local dir. NFC.
dtcxzyw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Dwarf] Emit
DW_AT_bit_size
for non-byte-sized types
- Loading branch information
commit 037aa2015dae1dc0f400b67effc98b060a6b25be
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s | llvm-dwarfdump - | FileCheck %s | ||
|
||
; CHECK: DW_TAG_base_type | ||
; CHECK-NEXT: DW_AT_name ("DW_ATE_unsigned_1") | ||
; CHECK-NEXT: DW_AT_encoding (DW_ATE_unsigned) | ||
; CHECK-NEXT: DW_AT_byte_size (0x01) | ||
; CHECK-NEXT: DW_AT_bit_size (0x01) | ||
|
||
define void @main() !dbg !18 { | ||
entry: | ||
#dbg_value(i1 false, !22, !DIExpression(DW_OP_not, DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), !23) | ||
ret void, !dbg !24 | ||
} | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!10, !11, !12, !13, !14, !15, !16} | ||
!llvm.ident = !{!17} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "test.c", directory: "/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build", checksumkind: CSK_MD5, checksum: "100bdbce655d729c24c7c0e8523a58ae") | ||
!2 = !{!3, !6, !8} | ||
!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression()) | ||
!4 = distinct !DIGlobalVariable(name: "a", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true) | ||
!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) | ||
!7 = distinct !DIGlobalVariable(name: "b", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true) | ||
!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression()) | ||
!9 = distinct !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true) | ||
!10 = !{i32 7, !"Dwarf Version", i32 5} | ||
!11 = !{i32 2, !"Debug Info Version", i32 3} | ||
!12 = !{i32 1, !"wchar_size", i32 4} | ||
!13 = !{i32 8, !"PIC Level", i32 2} | ||
!14 = !{i32 7, !"PIE Level", i32 2} | ||
!15 = !{i32 7, !"uwtable", i32 2} | ||
!16 = !{i32 7, !"debug-info-assignment-tracking", i1 true} | ||
!17 = !{!"clang version 21.0.0git"} | ||
!18 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !19, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !21) | ||
!19 = !DISubroutineType(types: !20) | ||
!20 = !{null} | ||
!21 = !{!22} | ||
!22 = !DILocalVariable(name: "l_4516", scope: !18, file: !1, line: 4, type: !5) | ||
!23 = !DILocation(line: 0, scope: !18) | ||
!24 = !DILocation(line: 9, column: 1, scope: !18) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DWARF seems to say that either the bit- or byte-size should be specified. So rather than emit both sizes, I think it's preferable to emit just the bit size if it is not a multiple of 8. See DWARF 5 section 5.1 "Base Type Entries":
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at this again and there's some later text about a scenario where
DW_AT_byte_size
is used for the object size, but then the actual data is described withDW_AT_bit_size
plusDW_AT_data_bit_offset
. So while it's not totally correct to say that the base type must have one or the other, it's still the case that this particular patch should probably do that. IMO.