LLVM
23.0.0git
lib
Target
Hexagon
RDFDeadCode.h
Go to the documentation of this file.
1
//===--- RDFDeadCode.h ----------------------------------------------------===//
2
//
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
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// RDF-based generic dead code elimination.
10
//
11
// The main interface of this class are functions "collect" and "erase".
12
// This allows custom processing of the function being optimized by a
13
// particular consumer. The simplest way to use this class would be to
14
// instantiate an object, and then simply call "collect" and "erase",
15
// passing the result of "getDeadInstrs()" to it.
16
// A more complex scenario would be to call "collect" first, then visit
17
// all post-increment instructions to see if the address update is dead
18
// or not, and if it is, convert the instruction to a non-updating form.
19
// After that "erase" can be called with the set of nodes including both,
20
// dead defs from the updating instructions and the nodes corresponding
21
// to the dead instructions.
22
23
#ifndef RDF_DEADCODE_H
24
#define RDF_DEADCODE_H
25
26
#include "
llvm/CodeGen/RDFGraph.h
"
27
#include "
llvm/CodeGen/RDFLiveness.h
"
28
#include "
llvm/ADT/SetVector.h
"
29
30
namespace
llvm
{
31
class
MachineRegisterInfo
;
32
33
namespace
rdf
{
34
struct
DeadCodeElimination
{
35
DeadCodeElimination
(
DataFlowGraph
&dfg,
MachineRegisterInfo
&mri)
36
: Trace(
false
), DFG(dfg), MRI(mri), LV(mri, dfg) {}
37
38
bool
collect
();
39
bool
erase
(
const
SetVector<NodeId>
&Nodes);
40
void
trace
(
bool
On) { Trace = On; }
41
bool
trace
()
const
{
return
Trace; }
42
43
SetVector<NodeId>
getDeadNodes
() {
return
DeadNodes; }
44
SetVector<NodeId>
getDeadInstrs
() {
return
DeadInstrs; }
45
DataFlowGraph
&
getDFG
() {
return
DFG; }
46
47
private
:
48
bool
Trace
;
49
SetVector<NodeId>
LiveNodes;
50
SetVector<NodeId>
DeadNodes;
51
SetVector<NodeId>
DeadInstrs;
52
DataFlowGraph
&DFG;
53
MachineRegisterInfo
&MRI;
54
Liveness
LV;
55
56
template
<
typename
T>
struct
SetQueue;
57
58
bool
isLiveInstr(
NodeAddr<StmtNode*>
S)
const
;
59
void
scanInstr(
NodeAddr<InstrNode*>
IA, SetQueue<NodeId> &WorkQ);
60
void
processDef(
NodeAddr<DefNode*>
DA, SetQueue<NodeId> &WorkQ);
61
void
processUse
(
NodeAddr<UseNode*>
UA, SetQueue<NodeId> &WorkQ);
62
};
63
}
// namespace rdf
64
}
// namespace llvm
65
66
#endif
processUse
static bool processUse(CallInst *CI, bool IsV5OrAbove)
Definition
AMDGPULowerKernelAttributes.cpp:119
RDFGraph.h
RDFLiveness.h
SetVector.h
This file implements a set that has insertion order iteration characteristics.
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition
MachineRegisterInfo.h:53
llvm::SetVector
A vector that has set insertion semantics.
Definition
SetVector.h:57
llvm::Trace
Definition
Trace.h:30
false
Definition
MachinePipeliner.cpp:245
llvm::rdf
Definition
RDFGraph.h:260
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
Types.h:26
llvm::rdf::DataFlowGraph
Definition
RDFGraph.h:660
llvm::rdf::DeadCodeElimination::getDeadNodes
SetVector< NodeId > getDeadNodes()
Definition
RDFDeadCode.h:43
llvm::rdf::DeadCodeElimination::trace
void trace(bool On)
Definition
RDFDeadCode.h:40
llvm::rdf::DeadCodeElimination::trace
bool trace() const
Definition
RDFDeadCode.h:41
llvm::rdf::DeadCodeElimination::getDFG
DataFlowGraph & getDFG()
Definition
RDFDeadCode.h:45
llvm::rdf::DeadCodeElimination::collect
bool collect()
Definition
RDFDeadCode.cpp:117
llvm::rdf::DeadCodeElimination::DeadCodeElimination
DeadCodeElimination(DataFlowGraph &dfg, MachineRegisterInfo &mri)
Definition
RDFDeadCode.h:35
llvm::rdf::DeadCodeElimination::getDeadInstrs
SetVector< NodeId > getDeadInstrs()
Definition
RDFDeadCode.h:44
llvm::rdf::DeadCodeElimination::erase
bool erase(const SetVector< NodeId > &Nodes)
Definition
RDFDeadCode.cpp:180
llvm::rdf::Liveness
Definition
RDFLiveness.h:55
llvm::rdf::NodeAddr
Definition
RDFGraph.h:344
Generated on
for LLVM by
1.14.0