From 15e2844b9028175c27c76dc31ad551fddccf5029 Mon Sep 17 00:00:00 2001 From: Hugel <2712504175@qq.com> Date: Wed, 22 Jul 2020 19:36:39 +0800 Subject: [PATCH] Ensure that variant part discriminator is read by MetadataLoader, and fix Assembler/debug-info.ll --- ...ant-part-discriminator-is-read-by-Me.patch | 60 +++++++++++++++++++ llvm.spec | 11 +++- test-Fix-Assembler-debug-info.ll.patch | 28 +++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 Ensure-that-variant-part-discriminator-is-read-by-Me.patch create mode 100644 test-Fix-Assembler-debug-info.ll.patch diff --git a/Ensure-that-variant-part-discriminator-is-read-by-Me.patch b/Ensure-that-variant-part-discriminator-is-read-by-Me.patch new file mode 100644 index 0000000..fde1c00 --- /dev/null +++ b/Ensure-that-variant-part-discriminator-is-read-by-Me.patch @@ -0,0 +1,60 @@ +From da1fb72bb305d6bc1f3899d541414146934bf80f Mon Sep 17 00:00:00 2001 +From: Jonas Devlieghere +Date: Fri, 21 Sep 2018 12:03:14 +0000 +Subject: [PATCH] Ensure that variant part discriminator is read by + MetadataLoader + +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. + +Patch by: Tom Tromey + +Differential revision: https://reviews.llvm.org/D52340 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342725 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + 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 3fe7d22..4781cfe 100644 +--- a/lib/Bitcode/Reader/MetadataLoader.cpp ++++ b/lib/Bitcode/Reader/MetadataLoader.cpp +@@ -1313,7 +1313,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 0000000..5be001c +--- /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) +-- +1.8.3.1 + diff --git a/llvm.spec b/llvm.spec index cd3a31a..b593bb2 100644 --- a/llvm.spec +++ b/llvm.spec @@ -1,6 +1,6 @@ Name: llvm Version: 7.0.0 -Release: 9 +Release: 10 Summary: The Low Level Virtual Machine License: NCSA URL: http://llvm.org @@ -10,6 +10,8 @@ Patch0: CMake-Split-static-library-exports-into-their-own-ex.patch Patch1: Filter-out-cxxflags-not-supported-by-clang.patch Patch2: CMake-Don-t-prefer-python2.7.patch Patch3: Don-t-set-rpath-when-installing.patch +Patch4: Ensure-that-variant-part-discriminator-is-read-by-Me.patch +Patch5: test-Fix-Assembler-debug-info.ll.patch BuildRequires: gcc gcc-c++ cmake ninja-build zlib-devel libffi-devel ncurses-devel libstdc++-static BuildRequires: python3-sphinx binutils-devel valgrind-devel libedit-devel python3-devel @@ -191,6 +193,13 @@ fi %{_mandir}/man1/* %changelog +* Wed Jul 22 2020 Hugel - 7.0.0-10 +- Type: enhancement +- ID: NA +- SUG: NA +- DESC: Ensure that variant part discriminator is read by MetadataLoader + Fix Assembler/debug-info.ll + * Wed Mar 18 2020 openEuler Buildteam - 7.0.0-9 - Type: enhancement - ID: NA diff --git a/test-Fix-Assembler-debug-info.ll.patch b/test-Fix-Assembler-debug-info.ll.patch new file mode 100644 index 0000000..47c77d4 --- /dev/null +++ b/test-Fix-Assembler-debug-info.ll.patch @@ -0,0 +1,28 @@ +From cc1f2a595ead516812a6c50398f0f3480ebe031f Mon Sep 17 00:00:00 2001 +From: Jonas Devlieghere +Date: Fri, 21 Sep 2018 12:28:44 +0000 +Subject: [PATCH] [test] Fix Assembler/debug-info.ll + +Update Assembler/debug-info.ll to contain discriminator. + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342727 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + test/Assembler/debug-info.ll | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/Assembler/debug-info.ll b/test/Assembler/debug-info.ll +index 4404b74..d54dba0 100644 +--- a/test/Assembler/debug-info.ll ++++ b/test/Assembler/debug-info.ll +@@ -83,7 +83,7 @@ + ; CHECK-NEXT: !32 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f") + !35 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f") + +-; CHECK-NEXT: !33 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64) ++; CHECK-NEXT: !33 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64, discriminator: !34) + ; CHECK-NEXT: !34 = !DIDerivedType(tag: DW_TAG_member, scope: !33, baseType: !35, size: 64, align: 64, flags: DIFlagArtificial) + ; CHECK-NEXT: !35 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned) + !36 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !16, size: 64, discriminator: !37) +-- +1.8.3.1 + -- Gitee