Don't emit locations that need a DW_OP_stack_value in DWARF 2 & 3.

https://bugs.llvm.org/show_bug.cgi?id=32382

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adrian Prantl 2017-04-20 20:42:33 +00:00
parent 060f30deeb
commit 52a72dacab
3 changed files with 19 additions and 1 deletions

View File

@ -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];

View File

@ -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<DIExpression::FragmentInfo> getFragmentInfo() const {

View File

@ -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