[all-commits] [llvm/llvm-project] 26382a: Reapply [Assignment Tracking][5/*] Add core infras...

Orlando Cazalet-Hyams via All-commits all-commits at lists.llvm.org
Tue Nov 8 06:57:07 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 26382a4412d29e1c31fc3cda5071d5d60832b69c
      https://github.com/llvm/llvm-project/commit/26382a4412d29e1c31fc3cda5071d5d60832b69c
  Author: OCHyams <orlando.hyams at sony.com>
  Date:   2022-11-08 (Tue, 08 Nov 2022)

  Changed paths:
    M llvm/include/llvm/AsmParser/LLParser.h
    M llvm/include/llvm/IR/DebugInfo.h
    M llvm/include/llvm/IR/Instruction.h
    M llvm/include/llvm/module.modulemap
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/IR/DebugInfo.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/IR/LLVMContextImpl.h
    M llvm/lib/IR/Metadata.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll
    M llvm/unittests/IR/DebugInfoTest.cpp

  Log Message:
  -----------
  Reapply [Assignment Tracking][5/*] Add core infrastructure for instruction reference

Previously reverted in 41f5a0004e442ae71c8e754fdadb4bd1e172fb2d. Fold in
D133576 previously reverted in d29d5ffb6332569e85d5eda5130603bbd8664635.

---

The Assignment Tracking debug-info feature is outlined in this RFC:

https://discourse.llvm.org/t/
rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir

Overview
It's possible to find intrinsics linked to an instruction by looking at the
MetadataAsValue uses of the attached DIAssignID. That covers instruction ->
intrinsic(s) lookup. Add a global DIAssignID -> instruction(s) map which gives
us the ability to perform intrinsic -> instruction(s) lookup. Add plumbing to
keep the map up to date through optimisations and add utility functions
including two that perform those lookups. Finally, add a unittest.

Details
In llvm/lib/IR/LLVMContextImpl.h add AssignmentIDToInstrs which maps DIAssignID
* attachments to Instruction *s. Because the DIAssignID * is the key we can't
use a TrackingMDNodeRef for it, and therefore cannot easily update the mapping
when a temporary DIAssignID is replaced.

Temporary DIAssignID's are only used in IR parsing to deal with metadata
forward references. Update llvm/lib/AsmParser/LLParser.cpp to avoid using
temporary DIAssignID's for attachments.

In llvm/lib/IR/Metadata.cpp add Instruction::updateDIAssignIDMapping which is
called to remove or add an entry (or both) to AssignmentIDToInstrs. Call this
from Instruction::setMetadata and add a call to setMetadata in Intruction's
dtor that explicitly unsets the DIAssignID so that the mappging gets updated.

In llvm/lib/IR/DebugInfo.cpp and DebugInfo.h add utility functions:

    getAssignmentInsts(const DbgAssignIntrinsic *DAI)
    getAssignmentMarkers(const Instruction *Inst)
    RAUW(DIAssignID *Old, DIAssignID *New)
    deleteAll(Function *F)
    deleteAssignmentMarkers(const Instruction *Inst)

These core utils are tested in llvm/unittests/IR/DebugInfoTest.cpp.

Reviewed By: jmorse

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




More information about the All-commits mailing list