Page MenuHomePhabricator

[DebugInfo] Make base type placeholder values larger than 0
Needs ReviewPublic

Authored by dstenb on Mar 19 2020, 3:33 AM.

Details

Summary

This is a preparatory change for allowing LLVM to emit DW_OP_convert
operations converting to the generic type.

When we emit a base type reference in location lists, we first emit a
placeholder in the byte stream, and later on resolve that to the DIE's
actual offset. That placeholder value was the index in the
ExprRefedBaseTypes array; i.e. starting from 0. To allow us to
distinguish generic type DW_OP_convert operations (i.e., with operand 0)
from the ones that refer to base types, this patch changes the code so
that the placeholder values instead start at 1. To avoid future
programmering errors due to this change, this patch also does some
refactoring:

  • Makes ExprRefedBaseTypes private in DwarfCompileUnit, and adds helper functions to create and retrieve base types, so that outside users don't index the array directly.
  • Renames the placeholder "index" to "key" instead to reduce the risk for off-by-one errors in the code.

This patch means that we reduce the number of unique placeholder values
by one (now 2^28 - 1). However, as the resolved DIE offsets must fit
inside the same ULEB widths as the placeholder values, we cannot support
nearly that many base types, so this should not be a problem in
practice. Otherwise, this should be a non-functional change, so I have
not added any new tests.

Diff Detail