From bb0b26aea362bf692f794d45ca032523e36d3042 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 20 Sep 2018 23:00:07 -0600 Subject: [PATCH] Ensure that variant part discriminator is read by MetadataLoader Summary: https://reviews.llvm.org/D42082 introduced variant parts to debug info in LLVM. Subsequent work on the Rust compiler has found a bug in that patch; namely, there is a path in MetadataLoader that fails to restore the discriminator. This patch fixes the bug. This was accepted by upstream LLVM here: https://reviews.llvm.org/D52340 --- lib/Bitcode/Reader/MetadataLoader.cpp | 2 +- test/Assembler/debug-variant-discriminator.ll | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/Assembler/debug-variant-discriminator.ll diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp index a48bbcc2f2db..c525c95faf05 100644 --- a/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1311,7 +1311,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( (Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, - Identifier)); + Identifier, Discriminator)); if (!IsNotUsedInTypeRef && Identifier) MetadataList.addTypeRef(*Identifier, *cast(CT)); diff --git a/test/Assembler/debug-variant-discriminator.ll b/test/Assembler/debug-variant-discriminator.ll new file mode 100644 index 000000000000..5be001cad6be --- /dev/null +++ b/test/Assembler/debug-variant-discriminator.ll @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s +; RUN: verify-uselistorder %s + +; CHECK: !named = !{!0, !1, !2} +!named = !{!0, !1, !2} + +; CHECK: !0 = !DICompositeType(tag: DW_TAG_structure_type, name: "Outer", size: 64, align: 64, identifier: "Outer") +; CHECK-NEXT: !1 = !DICompositeType(tag: DW_TAG_variant_part, scope: !0, size: 64, discriminator: !2) +; CHECK-NEXT: !2 = !DIDerivedType(tag: DW_TAG_member, scope: !1, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial) +; CHECK-NEXT: !3 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned) +!0 = !DICompositeType(tag: DW_TAG_structure_type, name: "Outer", size: 64, align: 64, identifier: "Outer") +!1 = !DICompositeType(tag: DW_TAG_variant_part, scope: !0, size: 64, discriminator: !2) +!2 = !DIDerivedType(tag: DW_TAG_member, scope: !1, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial) +!3 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)