Backport r315279 to fix an issue with rust

This commit is contained in:
Tom Stellard 2018-01-24 02:34:13 +00:00
parent eaeb4a01bc
commit 7a0f3d9fb9
3 changed files with 153 additions and 1 deletions

View File

@ -0,0 +1,105 @@
From 9848d812bc6a5ecbac4b64b28d580f5f5ce16c4f Mon Sep 17 00:00:00 2001
From: Bjorn Steinbrink <bsteinbr@gmail.com>
Date: Tue, 10 Oct 2017 07:46:17 +0000
Subject: [PATCH 1/2] Ignore all duplicate frame index expression
Some passes might duplicate calls to llvm.dbg.declare creating
duplicate frame index expression which currently trigger an assertion
which is meant to catch erroneous, overlapping fragment declarations.
But identical frame index expressions are just redundant and don't
actually conflict with each other, so we can be more lenient and just
ignore the duplicates.
Reviewers: aprantl, rnk
Subscribers: llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D38540
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315279 91177308-0d34-0410-b5e6-96231b3b80d8
Conflicts:
lib/CodeGen/AsmPrinter/DwarfDebug.h
---
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 25 +++++++++++++++++++++++++
lib/CodeGen/AsmPrinter/DwarfDebug.h | 25 +------------------------
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f1b4d9f..90f6f2f 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -206,9 +206,34 @@ ArrayRef<DbgVariable::FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
return A.Expr->getFragmentInfo()->OffsetInBits <
B.Expr->getFragmentInfo()->OffsetInBits;
});
+
return FrameIndexExprs;
}
+void DbgVariable::addMMIEntry(const DbgVariable &V) {
+ assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
+ assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
+ assert(V.Var == Var && "conflicting variable");
+ assert(V.IA == IA && "conflicting inlined-at location");
+
+ assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
+ assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
+
+ for (const auto &FIE : V.FrameIndexExprs)
+ // Ignore duplicate entries.
+ if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
+ return FIE.FI == Other.FI && FIE.Expr == Other.Expr;
+ }))
+ FrameIndexExprs.push_back(FIE);
+
+ assert((FrameIndexExprs.size() == 1 ||
+ llvm::all_of(FrameIndexExprs,
+ [](FrameIndexExpr &FIE) {
+ return FIE.Expr && FIE.Expr->isFragment();
+ })) &&
+ "conflicting locations for variable");
+}
+
static const DwarfAccelTable::Atom TypeAtoms[] = {
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4),
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 78ee9a1..44107aa 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -124,30 +124,7 @@ public:
/// Get the FI entries, sorted by fragment offset.
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
-
- void addMMIEntry(const DbgVariable &V) {
- assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
- assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
- assert(V.Var == Var && "conflicting variable");
- assert(V.IA == IA && "conflicting inlined-at location");
-
- assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
- assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
-
- if (FrameIndexExprs.size()) {
- auto *Expr = FrameIndexExprs.back().Expr;
- // Get rid of duplicate non-fragment entries. More than one non-fragment
- // dbg.declare makes no sense so ignore all but the first.
- if (!Expr || !Expr->isFragment())
- return;
- }
- FrameIndexExprs.append(V.FrameIndexExprs.begin(), V.FrameIndexExprs.end());
- assert(all_of(FrameIndexExprs,
- [](FrameIndexExpr &FIE) {
- return FIE.Expr && FIE.Expr->isFragment();
- }) &&
- "conflicting locations for variable");
- }
+ void addMMIEntry(const DbgVariable &V);
// Translate tag to proper Dwarf tag.
dwarf::Tag getTag() const {
--
1.8.3.1

View File

@ -0,0 +1,42 @@
From ca865fbaa493ff3250db39786c41658037e456ab Mon Sep 17 00:00:00 2001
From: Daniel Jasper <djasper@google.com>
Date: Thu, 12 Oct 2017 13:25:05 +0000
Subject: [PATCH 2/2] Reinstantiate old/bad deduplication logic that was
removed in r315279.
While this shouldn't be necessary anymore, we have cases where we run
into the assertion below, i.e. cases with two non-fragment entries for the
same variable at different frame indices.
This should be fixed, but for now, we should revert to a version that
does not trigger asserts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315576 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 90f6f2f..064450f 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -219,6 +219,16 @@ void DbgVariable::addMMIEntry(const DbgVariable &V) {
assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
+ // FIXME: This logic should not be necessary anymore, as we now have proper
+ // deduplication. However, without it, we currently run into the assertion
+ // below, which means that we are likely dealing with broken input, i.e. two
+ // non-fragment entries for the same variable at different frame indices.
+ if (FrameIndexExprs.size()) {
+ auto *Expr = FrameIndexExprs.back().Expr;
+ if (!Expr || !Expr->isFragment())
+ return;
+ }
+
for (const auto &FIE : V.FrameIndexExprs)
// Ignore duplicate entries.
if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
--
1.8.3.1

View File

@ -12,7 +12,7 @@
Name: llvm
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 1%{?dist}
Release: 2%{?dist}
Summary: The Low Level Virtual Machine
License: NCSA
@ -26,6 +26,8 @@ Patch3: 0001-CMake-Split-static-library-exports-into-their-own-ex.patch
# libstdc++, so we disable it for now.
Patch4: 0001-Revert-Add-a-linker-script-to-version-LLVM-symbols.patch
Patch5: 0001-PowerPC-Don-t-use-xscvdpspn-on-the-P7.patch
Patch6: 0001-Ignore-all-duplicate-frame-index-expression.patch
Patch7: 0002-Reinstantiate-old-bad-deduplication-logic-that-was-r.patch
BuildRequires: cmake
BuildRequires: zlib-devel
@ -216,6 +218,9 @@ fi
%{_libdir}/cmake/llvm/LLVMStaticExports.cmake
%changelog
* Thu Feb 01 2018 Tom Stellard <tstellar@redhat.com> - 5.0.1-2
- Backport r315279 to fix an issue with rust
* Tue Dec 19 2017 Tom Stellard <tstellar@redhat.com> - 5.0.1-1
- 5.0.1 Release