[PATCH] D101247: [Debug-Info] strict dwarf for DW_OP_stack_value

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 22:30:14 PDT 2021


shchenz added a comment.

In D101247#2763927 <https://reviews.llvm.org/D101247#2763927>, @jmorse wrote:

> Hi @shchenz, is it feasible to use DIExpression::isImplicit at a higher level to filter out these kinds of expressions? I believe it's possible to parse a DIExpression before it's lowered to a DWARF expression, and there are places where we rely on the isImplicit method for correctness already. Also paging @StephenTozer who's touched this area recently.
>
> I believe this would work for DW_AT_location attributes of DW_TAG_variable and DW_TAG_formal_parameter's, I'm less certain about other parts of DWARF that use expressions.

Hi @jmorse , first of all, thanks very much for your comment. Yes, `DIExpression::isImplicit()` should work to check if a `DW_AT_location` attribute has a `DW_OP_stack_value` operation. But this will only work if the location-related attributes are added by `DIEDwarfExpression.addExpression()`, right? There are also some other places that add location-related attributes not involving `DIEDwarfExpression`. See the below example:

  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
  addOpAddress(*Loc, Asm->getSymbol(GV));
  // Emit DW_OP_stack_value to use the address as the immediate value of
  // the parameter, rather than a pointer to it.
  addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
  addBlock(ParamDIE, dwarf::DW_AT_location, Loc);

We need a refactor here to change all places that call ` addBlock(, location_attr, )` to use `DIEDwarfExpression`, so that we have a common interface to add location-related attributes.
To achieve this goal, we also need some other refactors, see comment https://reviews.llvm.org/D101247#2750145


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101247/new/

https://reviews.llvm.org/D101247



More information about the llvm-commits mailing list