llvm-project/llvm/test/DebugInfo/NVPTX
Bjorn Pettersson 2b698a13a1 [DwarfExpression] Disallow some rewrites to avoid undefined behavior
Summary:
The value operand in DW_OP_plus_uconst/DW_OP_constu value can be
large (it uses uint64_t as representation internally in LLVM).
This means that in the uint64_t to int conversions, previously done
by DwarfExpression::addMachineRegExpression, could lose information.
Also, the negation done in "-Offset" was undefined behavior in case
Offset was exactly INT_MIN.

To avoid the above problems, we now avoid transformation like
 [Reg, DW_OP_plus_uconst, Offset] --> [DW_OP_breg, Offset]
and
 [Reg, DW_OP_constu, Offset, DW_OP_plus]  --> [DW_OP_breg, Offset]
when Offset > INT_MAX.

And we avoid to transform
 [Reg, DW_OP_constu, Offset, DW_OP_minus] --> [DW_OP_breg,-Offset]
when Offset > INT_MAX+1.

The patch also adjusts DwarfCompileUnit::constructVariableDIEImpl
to make sure that "DW_OP_constu, Offset, DW_OP_minus" is used
instead of "DW_OP_plus_uconst, Offset" when creating DIExpressions
with negative frame index offsets.

Notice that this might just be the tip of the iceberg. There
are lots of fishy handling related to these constants. I think both
DIExpression::appendOffset and DIExpression::extractIfOffset may
trigger undefined behavior for certain values.

Reviewers: sdesmalen, rnk, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: jholewinski, aprantl, hiraditya, ychen, uabelho, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D67263

llvm-svn: 371304
2019-09-07 11:40:10 +00:00
..
cu-range-hole.ll [NVPTX][DEBUGINFO]Temp workaround for crash of ptxas: disable packed bytes in debug sections. 2019-03-08 21:29:17 +00:00
dbg-declare-alloca.ll [DwarfExpression] Disallow some rewrites to avoid undefined behavior 2019-09-07 11:40:10 +00:00
dbg-value-const-byref.ll [DebugInfo][DAG] Process FrameIndex dbg.values unconditionally 2019-01-29 09:40:05 +00:00
debug-addr-class.ll [NVPTX][DEBUGINFO]Temp workaround for crash of ptxas: disable packed bytes in debug sections. 2019-03-08 21:29:17 +00:00
debug-empty.ll [DEBUG_INFO][NVPTX]Emit empty .debug_loc section in presence of the debug option. 2019-03-08 20:08:04 +00:00
debug-file-loc-only.ll [DEBUGINFO, NVPTX] Disable emission of ',debug' option if only debug directives are allowed. 2018-12-06 16:25:35 +00:00
debug-file-loc.ll [NVPTX][DEBUGINFO]Temp workaround for crash of ptxas: disable packed bytes in debug sections. 2019-03-08 21:29:17 +00:00
debug-info.ll [DebugInfo] Add column info for inline sites 2019-07-12 19:25:45 +00:00
debug-loc-offset.ll [NVPTX][DEBUGINFO]Temp workaround for crash of ptxas: disable packed bytes in debug sections. 2019-03-08 21:29:17 +00:00
lit.local.cfg