A fix for PR21176.

DW_OP_const <const> doesn't describe a constant value, but a value at a constant address. 
The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value. 
Added DW_OP_stack_value to the stack. 

Marked incorrect-variable-debugloc1.ll to xfail for PowerPC64, while the the failure (PR21881) 
is being investigated. 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224098 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ekaterina Romanova
2014-12-12 05:11:47 +00:00
parent a511846bdf
commit e0b0363e44
2 changed files with 89 additions and 0 deletions

View File

@@ -1722,6 +1722,18 @@ void DwarfDebug::emitDebugLocValue(ByteStreamer &Streamer,
Streamer.EmitInt8(dwarf::DW_OP_constu, "DW_OP_constu");
Streamer.EmitULEB128(Value.getInt());
}
// The proper way to describe a constant value is
// DW_OP_constu <const>, DW_OP_stack_value.
// Unfortunately, DW_OP_stack_value was not available until DWARF-4,
// so we will continue to generate DW_OP_constu <const> for DWARF-2
// and DWARF-3. Technically, this is incorrect since DW_OP_const <const>
// actually describes a value at a constant addess, not a constant value.
// However, in the past there was no better way to describe a constant
// value, so the producers and consumers started to rely on heuristics
// to disambiguate the value vs. location status of the expression.
// See PR21176 for more details.
if (getDwarfVersion() >= 4)
Streamer.EmitInt8(dwarf::DW_OP_stack_value, "DW_OP_stack_value");
} else if (Value.isLocation()) {
MachineLocation Loc = Value.getLoc();
DIExpression Expr = Value.getExpression();