Blame SOURCES/0001-Ensure-that-variant-part-discriminator-is-read-by-Me.patch

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