[all-commits] [llvm/llvm-project] 75aa3d: Add a DIExpression const-folder to prevent silly e...

Paul T Robinson via All-commits all-commits at lists.llvm.org
Thu Aug 5 06:14:57 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 75aa3d520d53fb0d2a279736245ad255ec720a5b
      https://github.com/llvm/llvm-project/commit/75aa3d520d53fb0d2a279736245ad255ec720a5b
  Author: Paul Robinson <paul.robinson at sony.com>
  Date:   2021-08-05 (Thu, 05 Aug 2021)

  Changed paths:
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
    M llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
    M llvm/lib/IR/DebugInfoMetadata.cpp
    A llvm/test/DebugInfo/X86/DIExpr-const-folding.ll
    M llvm/test/DebugInfo/X86/convert-debugloc.ll
    M llvm/test/DebugInfo/X86/convert-linked.ll
    M llvm/test/DebugInfo/X86/convert-loclist.ll
    M llvm/unittests/IR/MetadataTest.cpp

  Log Message:
  -----------
  Add a DIExpression const-folder to prevent silly expressions.

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.

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




More information about the All-commits mailing list