summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/FuncletLayout.cpp
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2019-09-07 11:40:10 +0000
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2019-09-07 11:40:10 +0000
commit2b698a13a11e0b007c9e1d71bc69fcf4a194eab1 (patch)
tree60ec48669df5b7aaf91e6653a6e1fd0ee4870c34 /llvm/lib/CodeGen/FuncletLayout.cpp
parente85acf946d3b5bd62c97ac9d49e95e4b8a4cbe83 (diff)
downloadbcm5719-llvm-2b698a13a11e0b007c9e1d71bc69fcf4a194eab1.tar.gz
bcm5719-llvm-2b698a13a11e0b007c9e1d71bc69fcf4a194eab1.zip
[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
Diffstat (limited to 'llvm/lib/CodeGen/FuncletLayout.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud