From e42805d07c4540826bebebb532fb31d6dc97020f Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 26 Apr 2018 18:17:04 +0000 Subject: Fix a bug that prevents global variables from having a DW_OP_deref. For local variables the first DW_OP_deref is consumed by turning the location kind into a memeory location, but that only makes sense for values that are in a register to begin with, which cannot happen for global variables that are attached to a symbol. rdar://problem/39741860 llvm-svn: 330970 --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 2eb0157f1e0..d893db42006 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -230,8 +230,9 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( addOpAddress(*Loc, Sym); } } - if (Expr) - DwarfExpr->addExpression(Expr); + // Global variables attached to symbols are memory locations. + DwarfExpr->setMemoryLocationKind(); + DwarfExpr->addExpression(Expr); } if (Loc) addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize()); -- cgit v1.2.3