1//===-- llvm/CodeGen/AssignmentTrackingAnalysis.h --------------*- C++ -*--===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9#ifndef LLVM_CODEGEN_ASSIGNMENTTRACKINGANALYSIS_H
10#define LLVM_CODEGEN_ASSIGNMENTTRACKINGANALYSIS_H
25/// Type wrapper for integer ID for Variables. 0 is reserved.
27/// Variable location definition used by FunctionVarLocs.
35/// Data structure describing the variable locations in a function. Used as the
36/// result of the AssignmentTrackingAnalysis pass. Essentially read-only
37/// outside of AssignmentTrackingAnalysis where it is built.
39 /// Maps VarLocInfo.VariableID to a DebugVariable for VarLocRecords.
41 /// List of variable location changes grouped by the instruction the
42 /// change occurs before (see VarLocsBeforeInst). The elements from
43 /// zero to SingleVarLocEnd represent variables with a single location.
45 /// End of range of VarLocRecords that represent variables with a single
46 /// location that is valid for the entire scope. Range starts at 0.
47 unsigned SingleVarLocEnd = 0;
48 /// Maps an instruction to a range of VarLocs that start just before it.
53 /// Return the DILocalVariable for the location definition represented by \p
59 /// Return the DILocalVariable of the variable represented by \p ID.
63 /// Return the DebugVariable represented by \p ID.
65 return Variables[
static_cast<unsigned>(
ID)];
70 /// First single-location variable location definition.
72 /// One past the last single-location variable location definition.
74 const auto *It = VarLocRecords.begin();
75 std::advance(It, SingleVarLocEnd);
78 /// First variable location definition that comes before \p Before.
80 auto Span = VarLocsBeforeInst.lookup(Before);
81 const auto *It = VarLocRecords.begin();
82 std::advance(It, Span.first);
85 /// One past the last variable location definition that comes before \p
88 auto Span = VarLocsBeforeInst.lookup(Before);
89 const auto *It = VarLocRecords.begin();
90 std::advance(It, Span.second);
98 /// Non-const methods used by AssignmentTrackingAnalysis (which invalidate
99 /// analysis results if called incorrectly).
125 std::unique_ptr<FunctionVarLocs> Results;
143}
// end namespace llvm
144#endif // LLVM_CODEGEN_ASSIGNMENTTRACKINGANALYSIS_H
This header defines various interfaces for pass management in LLVM.
FunctionAnalysisManager FAM
Helper class to build FunctionVarLocs, since that class isn't easy to modify.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
AssignmentTrackingAnalysis()
const FunctionVarLocs * getResults()
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Result run(Function &F, FunctionAnalysisManager &FAM)
DebugAssignmentTrackingPrinterPass(raw_ostream &OS)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Identifies a unique instance of a variable.
const DILocalVariable * getVariable() const
Data structure describing the variable locations in a function.
void print(raw_ostream &OS, const Function &Fn) const
const VarLocInfo * locs_begin(const Instruction *Before) const
First variable location definition that comes before Before.
const VarLocInfo * single_locs_begin() const
DILocalVariable * getDILocalVariable(const VarLocInfo *Loc) const
Return the DILocalVariable for the location definition represented by ID.
DILocalVariable * getDILocalVariable(VariableID ID) const
Return the DILocalVariable of the variable represented by ID.
const DebugVariable & getVariable(VariableID ID) const
Return the DebugVariable represented by ID.
const VarLocInfo * locs_end(const Instruction *Before) const
One past the last variable location definition that comes before Before.
const VarLocInfo * single_locs_end() const
One past the last single-location variable location definition.
void init(FunctionVarLocsBuilder &Builder)
A set of analyses that are preserved following a run of a transformation pass.
Lightweight class that wraps the location operand metadata of a debug intrinsic.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.
VariableID
Type wrapper for integer ID for Variables. 0 is reserved.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A CRTP mix-in to automatically provide informational APIs needed for passes.
Variable location definition used by FunctionVarLocs.
RawLocationWrapper Values
llvm::VariableID VariableID