-
Notifications
You must be signed in to change notification settings - Fork 13.5k
When emitting DW_AT_discr_value
, discriminants that don't fit in a 64-bit integer are truncated or cause LLVM assertions
#119655
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
Labels
Comments
@llvm/issue-subscribers-debuginfo Author: None (beetrees)
When compiling the following IR ([compiler explorer](https://godbolt.org/z/PxhfM1KP4); the IR is [compiled from this Rust code](https://godbolt.org/z/8doGjqq36)):
<details><summary>LLVM IR</summary>
; ModuleID = 'example.bbc0a90001a6c25f-cgu.0'
source_filename = "example.bbc0a90001a6c25f-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nonlazybind uwtable
define void @<!-- -->f(ptr align 16 %arg) unnamed_addr #<!-- -->0 !dbg !7 {
start:
%arg.dbg.spill = alloca [8 x i8], align 8
store ptr %arg, ptr %arg.dbg.spill, align 8
#dbg_declare(ptr %arg.dbg.spill, !29, !DIExpression(), !30)
ret void, !dbg !31
}
attributes #<!-- -->0 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!llvm.dbg.cu = !{!5}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 2, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{!"rustc version 1.85.0-nightly (33c245b9e 2024-12-10)"}
!5 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !6, producer: "clang LLVM (rustc version 1.85.0-nightly (33c245b9e 2024-12-10))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!6 = !DIFile(filename: "/app/example.rs/@/example.bbc0a90001a6c25f-cgu.0", directory: "/app")
!7 = distinct !DISubprogram(name: "f", scope: !9, file: !8, line: 10, type: !10, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !5, templateParams: !23, retainedNodes: !28)
!8 = !DIFile(filename: "example.rs", directory: "/app", checksumkind: CSK_MD5, checksum: "a5e69d61728bea50929f951cefeb214d")
!9 = !DINamespace(name: "example", scope: null)
!10 = !DISubroutineType(types: !11)
!11 = !{null, !12}
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&example::Enum", baseType: !13, size: 64, align: 64, dwarfAddressSpace: 0)
!13 = !DICompositeType(tag: DW_TAG_structure_type, name: "Enum", scope: !9, file: !14, size: 256, align: 128, flags: DIFlagPrivate, elements: !15, templateParams: !23, identifier: "469ee2dc29a0e6d2c8e5f6f5942b091")
!14 = !DIFile(filename: "<unknown>", directory: "")
!15 = !{!16}
!16 = !DICompositeType(tag: DW_TAG_variant_part, scope: !13, file: !14, size: 256, align: 128, elements: !17, templateParams: !23, identifier: "190ce2747378be38ac7362eb40a80906", discriminator: !26)
!17 = !{!18, !24}
!18 = !DIDerivedType(tag: DW_TAG_member, name: "VariantA", scope: !16, file: !14, baseType: !19, size: 256, align: 128, extraData: i128 0)
!19 = !DICompositeType(tag: DW_TAG_structure_type, name: "VariantA", scope: !13, file: !14, size: 256, align: 128, flags: DIFlagPrivate, elements: !20, templateParams: !23, identifier: "588fffa66c9ca296e16b6bf021973a50")
!20 = !{!21}
!21 = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: !19, file: !14, baseType: !22, size: 8, align: 8, offset: 128, flags: DIFlagPrivate)
!22 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
!23 = !{}
!24 = !DIDerivedType(tag: DW_TAG_member, name: "VariantB", scope: !16, file: !14, baseType: !25, size: 256, align: 128, extraData: i128 18446744073709551616)
!25 = !DICompositeType(tag: DW_TAG_structure_type, name: "VariantB", scope: !13, file: !14, size: 256, align: 128, flags: DIFlagPrivate, elements: !23, identifier: "ace4dd05425154b121f11815fa7d85bc")
!26 = !DIDerivedType(tag: DW_TAG_member, scope: !13, file: !14, baseType: !27, size: 128, align: 128, flags: DIFlagArtificial)
!27 = !DIBasicType(name: "u128", size: 128, encoding: DW_ATE_unsigned)
!28 = !{!29}
!29 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !8, line: 10, type: !12)
!30 = !DILocation(line: 10, column: 6, scope: !7)
!31 = !DILocation(line: 12, column: 2, scope: !32)
!32 = !DILexicalBlockFile(scope: !7, file: !8, discriminator: 0) </details> An LLVM assertion is triggered by the <details><summary>Assertion backtrace</summary>
</details> |
tromey
added a commit
to tromey/llvm-project
that referenced
this issue
Feb 3, 2025
If a variant part has a 128-bit discriminator, then DwarfUnit::constructTypeDIE will assert. This patch fixes the problem by allowing any size of integer to be used here. This is mostly implemented by copying DwarfUnit::addConstantValue. However, I did not reimplement that method in terms of the new addInt because that would introduce the need for unrelated test case changes. Fixes llvm#119655
tromey
added a commit
to tromey/llvm-project
that referenced
this issue
Feb 4, 2025
If a variant part has a 128-bit discriminator, then DwarfUnit::constructTypeDIE will assert. This patch fixes the problem by allowing any size of integer to be used here. This is largely accomplished by moving part of DwarfUnit::addConstantValue to a new method. Fixes llvm#119655
dwblaikie
pushed a commit
that referenced
this issue
Feb 4, 2025
If a variant part has a 128-bit discriminator, then DwarfUnit::constructTypeDIE will assert. This patch fixes the problem by allowing any size of integer to be used here. This is largely accomplished by moving part of DwarfUnit::addConstantValue to a new method. Fixes #119655
swift-ci
pushed a commit
to swiftlang/llvm-project
that referenced
this issue
Feb 8, 2025
If a variant part has a 128-bit discriminator, then DwarfUnit::constructTypeDIE will assert. This patch fixes the problem by allowing any size of integer to be used here. This is largely accomplished by moving part of DwarfUnit::addConstantValue to a new method. Fixes llvm#119655 (cherry picked from commit 3c28076)
Icohedron
pushed a commit
to Icohedron/llvm-project
that referenced
this issue
Feb 11, 2025
If a variant part has a 128-bit discriminator, then DwarfUnit::constructTypeDIE will assert. This patch fixes the problem by allowing any size of integer to be used here. This is largely accomplished by moving part of DwarfUnit::addConstantValue to a new method. Fixes llvm#119655
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When compiling the following IR (compiler explorer; the IR is compiled from this Rust code):
LLVM IR
An LLVM assertion is triggered by the
getZExtValue
/getSExtValue
call inDwarfUnit::constructTypeDIE
(if assertions are disabled, the discriminant value is instead truncated to a 64-bit integer), as the discriminant value ofVariantB
does not fit in a 64-bit integer.Assertion backtrace
The text was updated successfully, but these errors were encountered: