[PATCH] D99273: [DebugInfo] Support for signed constants inside DIExpression

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 29 14:51:16 PDT 2021


aprantl added inline comments.


================
Comment at: llvm/lib/IR/DebugInfoMetadata.cpp:1472
+       getElement(2) != dwarf::DW_OP_stack_value))
     return false;
   return true;
----------------
SouraVX wrote:
> aprantl wrote:
> > dstenb wrote:
> > > Why do we not allow fragmented expressions here but we do for the unsigned variant?
> > It's costly to maintain two function that share 95% of their implementation. What would you think about having a single function
> > 
> > `llvm::Optional<enum {unsigned, signed}> DIExpression::isConstant() const;`
> > 
> > instead? Then it can serve as a drop-in replacements for call sites that don't care about the signedness and ones that do still get that information.
> > 
> Thanks for the suggestion! I went a little ahead and did it in a more functional way, preserving the semantics in individual lambdas.
> Please let me know, WDYT ?
You implemented my suggestion very literally. Ideally we would share the *implementation* of the two lambdas as well, for example, by inverting the condition and use early exists:

```
if ((getNumElements() == 2 && (getElement(0) != dwarf::DW_OP_consts))
  return true;
if  (getNumElements() != 3_
  return false;
if ((getElement(0) != dwarf::DW_OP_consts || (getElement(0) != dwarf::DW_OP_constu))
  return false;
return getElement(2) != dwarf::DW_OP_stack_value);
```
...




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99273



More information about the llvm-commits mailing list