[PATCH] D106915: Add a DIExpression const-folder to prevent silly expressions

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 27 13:46:00 PDT 2021


probinson created this revision.
probinson added reviewers: StephenTozer, aprantl, dblaikie.
probinson added a project: debug-info.
Herald added subscribers: dexonsmith, hiraditya.
probinson requested review of this revision.
Herald added a project: LLVM.

It's entirely possible (because it actually happened) for a bool
variable to end up with a 256-bit DW_AT_const_value.  This came about
when a local bool variable was initialized from a bitfield in a
32-byte struct of bitfields, and after inlining and constant
propagation, the variable did have a constant value. The sequence of
optimizations had it carrying "i256" values around, but once the
constant made it into the llvm.dbg.value, no further IR changes could
affect it.

Technically the llvm.dbg.value did have a DIExpression to reduce it
back down to 8 bits, but the compiler is in no way ready to emit an
oversized constant *and* a DWARF expression to manipulate it.
Depending on the circumstances, we had either just the very fat bool
value, or an expression with no starting value.

The sequence of optimizations that led to this state did seem pretty
reasonable, so the solution I came up with was to invent a DWARF
constant expression folder.  Currently it only does convert ops, but
there's no reason it couldn't do other ops if that became useful.

This broke three tests that depended on having convert ops survive
into the DWARF, so I added an operator that would abort the folder to
each of those tests.


https://reviews.llvm.org/D106915

Files:
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/test/DebugInfo/X86/DIExpr-const-folding.ll
  llvm/test/DebugInfo/X86/convert-debugloc.ll
  llvm/test/DebugInfo/X86/convert-linked.ll
  llvm/test/DebugInfo/X86/convert-loclist.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106915.362170.patch
Type: text/x-patch
Size: 17293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210727/ce1ddbbe/attachment.bin>


More information about the llvm-commits mailing list