[PATCH] D52340: Ensure that variant part discriminator is read by MetadataLoader

Tom Tromey via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 20 22:16:11 PDT 2018


tromey created this revision.
Herald added subscribers: llvm-commits, JDevlieghere, aprantl.
tromey added a reviewer: aprantl.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D52340

Files:
  lib/Bitcode/Reader/MetadataLoader.cpp
  test/Assembler/debug-variant-discriminator.ll


Index: test/Assembler/debug-variant-discriminator.ll
===================================================================
--- /dev/null
+++ 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)
Index: lib/Bitcode/Reader/MetadataLoader.cpp
===================================================================
--- lib/Bitcode/Reader/MetadataLoader.cpp
+++ lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1313,7 +1313,7 @@
                            (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<DICompositeType>(CT));
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52340.166403.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180921/cb56608f/attachment.bin>


More information about the llvm-commits mailing list