From a244d9e3deb5e2043c9c1bcba62955dc75a1bd9d Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 4 May 2018 16:10:43 +0000 Subject: [PATCH] DwarfCompileUnit: Fix another assertion failure on malformed input that is not rejected by the Verifier. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thanks to Björn Pettersson for providing a reproducer! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331535 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 2 +- lib/CodeGen/AsmPrinter/DwarfExpression.h | 1 + test/DebugInfo/X86/global-expression.ll | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 4a5c7b324d6..32b6657c2fd 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -234,7 +234,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( // It would be better if this were unconditional, but malformed input that // mixes non-fragments and fragments for the same variable is too expensive // to detect in the verifier. - if (!DwarfExpr->isMemoryLocation()) + if (DwarfExpr->isUnknownLocation()) DwarfExpr->setMemoryLocationKind(); DwarfExpr->addExpression(Expr); } diff --git a/lib/CodeGen/AsmPrinter/DwarfExpression.h b/lib/CodeGen/AsmPrinter/DwarfExpression.h index 7d6d45e64d6..952b0d99a95 100644 --- a/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -212,6 +212,7 @@ public: void addUnsignedConstant(const APInt &Value); bool isMemoryLocation() const { return LocationKind == Memory; } + bool isUnknownLocation() const { return LocationKind == Unknown; } /// Lock this down to become a memory location description. void setMemoryLocationKind() { diff --git a/test/DebugInfo/X86/global-expression.ll b/test/DebugInfo/X86/global-expression.ll index fdae9bd5fa2..6bfb5478b5f 100644 --- a/test/DebugInfo/X86/global-expression.ll +++ b/test/DebugInfo/X86/global-expression.ll @@ -17,7 +17,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.13.0" @i = global i32 23, align 4 -@indirect = global i32* @i, align 8, !dbg !6, !dbg !0, !dbg !14, !dbg !15 +@indirect = global i32* @i, align 8, !dbg !6, !dbg !0, !dbg !14, !dbg !15, !dbg !16 !llvm.dbg.cu = !{!2} !llvm.module.flags = !{!10, !11, !12, !13} @@ -39,3 +39,4 @@ target triple = "x86_64-apple-macosx10.13.0" ; This is malformed, but too expensive to detect in the verifier. !14 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) !15 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression(DW_OP_LLVM_fragment, 0, 1)) +!16 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression(DW_OP_deref, DW_OP_constu, 1, DW_OP_plus, DW_OP_stack_value)) -- 2.11.0