[PATCH] D138995: [CodeView] Add support for local S_CONSTANT records

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 03:00:35 PST 2022


thieta created this revision.
thieta added reviewers: aganea, rnk, hans, efriedma, saudi, jmorse.
Herald added a subscriber: hiraditya.
Herald added a project: All.
thieta requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: LLVM.

CodeView doesn't have the ability to represent variables
in other ways than as in registers or memory values, but
LLVM very often transforms simple values into constants,
consider this program:

int f () { int i = 123; return i; }

LLVM will transform `i` into a constant value and just
leave behind a llvm.dbg.value, this can't be represented
as a S_LOCAL record in CodeView. But we can represent it
as a S_CONSTANT record.

This patch checks if the location of a debug value is null,
then we will insert a S_CONSTANT record instead of a S_LOCAL
value with the flag "OptimizedAway".

In lld we then output the S_CONSTANT in the right scope, before
they where always inserted in the global stream, now we check
the scope before inserting it.

This has shown to improve debugging for our developers
internally.

Fixes to llvm/llvm-project#55958


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138995

Files:
  lld/COFF/PDB.cpp
  lld/test/COFF/Inputs/pdb-local-constants.s
  lld/test/COFF/pdb-local-constants.test
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/test/DebugInfo/COFF/local-constant.ll
  llvm/test/DebugInfo/COFF/pieces.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138995.478871.patch
Type: text/x-patch
Size: 19212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221130/ce456e51/attachment.bin>


More information about the llvm-commits mailing list