From: Adrian Prantl Date: Thu, 20 Apr 2017 20:42:33 +0000 (+0000) Subject: Don't emit locations that need a DW_OP_stack_value in DWARF 2 & 3. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ada104888efce709181b5c82983b331e40015d36;p=platform%2Fupstream%2Fllvm.git Don't emit locations that need a DW_OP_stack_value in DWARF 2 & 3. https://bugs.llvm.org/show_bug.cgi?id=32382 llvm-svn: 300883 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 55397c3..f65dc15 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -226,8 +226,15 @@ bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI, return true; } - // FIXME: // Don't emit locations that cannot be expressed without DW_OP_stack_value. + if (DwarfVersion < 4) + if (std::any_of(ExprCursor.begin(), ExprCursor.end(), + [](DIExpression::ExprOperand Op) -> bool { + return Op.getOp() == dwarf::DW_OP_stack_value; + })) { + DwarfRegs.clear(); + return false; + } assert(DwarfRegs.size() == 1); auto Reg = DwarfRegs[0]; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 203990d..de86132 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -72,6 +72,8 @@ public: } /// Determine whether there are any operations left in this expression. operator bool() const { return Start != End; } + DIExpression::expr_op_iterator begin() const { return Start; } + DIExpression::expr_op_iterator end() const { return End; } /// Retrieve the fragment information, if any. Optional getFragmentInfo() const { diff --git a/llvm/test/DebugInfo/X86/dw_op_minus_direct.ll b/llvm/test/DebugInfo/X86/dw_op_minus_direct.ll index a204b29..8d346be 100644 --- a/llvm/test/DebugInfo/X86/dw_op_minus_direct.ll +++ b/llvm/test/DebugInfo/X86/dw_op_minus_direct.ll @@ -1,11 +1,20 @@ ; Test dwarf codegen of DW_OP_minus. ; RUN: llc -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s +; RUN: llc -dwarf-version=2 -filetype=obj < %s | llvm-dwarfdump - \ +; RUN: | FileCheck %s --check-prefix=DWARF2 +; RUN: llc -dwarf-version=3 -filetype=obj < %s | llvm-dwarfdump - \ +; RUN: | FileCheck %s --check-prefix=DWARF2 ; This was derived manually from: ; int inc(int i) { ; return i+1; ; } +; DWARF2: .debug_info +; DWARF2: DW_TAG_formal_parameter +; DWARF2-NEXT: DW_AT_name {{.*}}"i" +; DWARF2-NOT: DW_AT_location + ; CHECK: Beginning address offset: 0x0000000000000000 ; CHECK: Ending address offset: 0x0000000000000004 ; CHECK: Location description: 70 00 10 ff ff ff ff 0f 1a 10 01 1c 9f