Skip to content

Commit

Permalink
DwarfCompileUnit: Fix another assertion failure on malformed input
Browse files Browse the repository at this point in the history
that is not rejected by the Verifier.

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
  • Loading branch information
adrian-prantl committed May 4, 2018
1 parent 60248da commit a244d9e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions lib/CodeGen/AsmPrinter/DwarfExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class DwarfExpression {
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() {
Expand Down
3 changes: 2 additions & 1 deletion test/DebugInfo/X86/global-expression.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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))

0 comments on commit a244d9e

Please sign in to comment.