LLVM 24.0.0git
LiveVariables.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/LiveVariables.h - Live Variable Analysis ---*- C++ -*-===//
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// This is a defunct analysis and should not be used. This pass should be
10// deleted. It's sole function is now to made adjustments to dead flags and
11// should be deleted once later passes are fixed.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_LIVEVARIABLES_H
16#define LLVM_CODEGEN_LIVEVARIABLES_H
17
18#include "llvm/ADT/BitVector.h"
19#include "llvm/ADT/DenseMap.h"
25#include "llvm/PassRegistry.h"
27
28namespace llvm {
29
32
33class LiveVariables {
35
36 MachineRegisterInfo *MRI = nullptr;
37
38 const TargetRegisterInfo *TRI = nullptr;
39
40 // PhysRegInfo - Keep track of which instruction was the last def of a
41 // physical register. This is a purely local property, because all physical
42 // register references are presumed dead across basic blocks.
43 std::vector<MachineInstr *> PhysRegDef;
44
45 // PhysRegInfo - Keep track of which instruction was the last use of a
46 // physical register. This is a purely local property, because all physical
47 // register references are presumed dead across basic blocks.
48 std::vector<MachineInstr *> PhysRegUse;
49
50 /// Track physical registers referenced in the current block, used as a
51 /// compile-time guard.
52 BitVector TrackedRegs;
53
54 // DistanceMap - Keep track the distance of a MI from the start of the
55 // current basic block.
57
58 // For legacy pass.
59 LiveVariables() = default;
60
61 LLVM_ABI void analyze(MachineFunction &MF);
62
63 /// HandlePhysRegKill - Mark the last def of Reg and its sub-registers dead
64 /// if they are not used. Pay special attention to the sub-register uses
65 /// which may come below the last use of the whole register.
66 void HandlePhysRegKill(Register Reg, MachineInstr *MI);
67
68 /// HandleRegMask - Call HandlePhysRegKill for all registers clobbered by Mask.
69 void HandleRegMask(const MachineOperand &, unsigned);
70
71 void HandlePhysRegUse(Register Reg, MachineInstr &MI);
72 void HandlePhysRegDef(Register Reg, MachineInstr *MI);
73 void UpdatePhysRegDefs(MachineInstr &MI, ArrayRef<Register> Defs);
74
75 /// FindLastRefOrPartRef - Return the last reference or partial reference of
76 /// the specified register.
77 MachineInstr *FindLastRefOrPartRef(Register Reg);
78
79 /// FindLastPartialDef - Return the last partial def of the specified
80 /// register.
81 MachineInstr *FindLastPartialDef(Register Reg);
82
83 void runOnInstr(MachineInstr &MI, unsigned NumRegs);
84
85 void runOnBlock(MachineBasicBlock *MBB, unsigned NumRegs);
86
87public:
88 LLVM_ABI LiveVariables(MachineFunction &MF);
89};
90
99
101 LiveVariables LV;
102
103public:
104 static char ID; // Pass identification, replacement for typeid
105
107
109 LV.analyze(MF);
110 return false;
111 }
112
113 void getAnalysisUsage(AnalysisUsage &AU) const override;
114};
115
116} // End llvm namespace
117
118#endif
MachineBasicBlock & MBB
This file implements the BitVector class.
#define LLVM_ABI
Definition Compiler.h:215
This file defines the DenseMap class.
IRTranslator LLVM IR MI
Register Reg
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
friend class LiveVariablesWrapperPass
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
Definition Register.h:20
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
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...
Definition Analysis.h:29