llvm.org GIT mirror llvm / bb7b23f
Stub out a new LiveDebugVariables pass. This analysis is going to run immediately after LiveIntervals. It will stay alive during register allocation and keep track of user variables mentioned in DBG_VALUE instructions. When the register allocator is moving values between registers and the stack, it is very hard to keep track of DBG_VALUE instructions. We usually get it wrong. This analysis maintains a data structure that makes it easy to update DBG_VALUE instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120385 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 9 years ago
5 changed file(s) with 110 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
116116 void initializeLazyValueInfoPass(PassRegistry&);
117117 void initializeLibCallAliasAnalysisPass(PassRegistry&);
118118 void initializeLintPass(PassRegistry&);
119 void initializeLiveDebugVariablesPass(PassRegistry&);
119120 void initializeLiveIntervalsPass(PassRegistry&);
120121 void initializeLiveStacksPass(PassRegistry&);
121122 void initializeLiveValuesPass(PassRegistry&);
1919 IntrinsicLowering.cpp
2020 LLVMTargetMachine.cpp
2121 LatencyPriorityQueue.cpp
22 LiveDebugVariables.cpp
2223 LiveInterval.cpp
2324 LiveIntervalAnalysis.cpp
2425 LiveIntervalUnion.cpp
2222 initializeDeadMachineInstructionElimPass(Registry);
2323 initializeGCModuleInfoPass(Registry);
2424 initializeIfConverterPass(Registry);
25 initializeLiveDebugVariablesPass(Registry);
2526 initializeLiveIntervalsPass(Registry);
2627 initializeLiveStacksPass(Registry);
2728 initializeLiveVariablesPass(Registry);
0 //===- LiveDebugVariables.cpp - Tracking debug info variables -------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the LiveDebugVariables analysis.
10 //
11 // Remove all DBG_VALUE instructions referencing virtual registers and replace
12 // them with a data structure tracking where live user variables are kept - in a
13 // virtual register or in a stack slot.
14 //
15 // Allow the data structure to be updated during register allocation when values
16 // are moved between registers and stack slots. Finally emit new DBG_VALUE
17 // instructions after register allocation is complete.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #include "LiveDebugVariables.h"
22 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
23 #include "llvm/CodeGen/MachineFunction.h"
24 #include "llvm/CodeGen/Passes.h"
25 #include "llvm/Target/TargetMachine.h"
26
27 using namespace llvm;
28
29 char LiveDebugVariables::ID = 0;
30
31 INITIALIZE_PASS_BEGIN(LiveDebugVariables, "livedebugvars",
32 "Debug Variable Analysis", false, false)
33 INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
34 INITIALIZE_PASS_END(LiveDebugVariables, "livedebugvars",
35 "Debug Variable Analysis", false, false)
36
37 void LiveDebugVariables::getAnalysisUsage(AnalysisUsage &AU) const {
38 AU.addRequiredTransitive();
39 AU.setPreservesAll();
40 MachineFunctionPass::getAnalysisUsage(AU);
41 }
42
43 LiveDebugVariables::LiveDebugVariables() : MachineFunctionPass(ID) {
44 initializeLiveDebugVariablesPass(*PassRegistry::getPassRegistry());
45 }
46
47 bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) {
48 return false;
49 }
0 //===- LiveDebugVariables.h - Tracking debug info variables ----*- c++ -*--===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the interface to the LiveDebugVariables analysis.
10 //
11 // The analysis removes DBG_VALUE instructions for virtual registers and tracks
12 // live user variables in a data structure that can be updated during register
13 // allocation.
14 //
15 // After register allocation new DBG_VALUE instructions are emitted to reflect
16 // the new locations of user variables.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
21 #define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
22
23 #include "llvm/CodeGen/MachineFunctionPass.h"
24
25 namespace llvm {
26
27 class LiveDebugVariables : public MachineFunctionPass {
28 void *pImpl;
29 public:
30 static char ID; // Pass identification, replacement for typeid
31
32 LiveDebugVariables();
33
34 /// renameRegister - Move any user variables in OldReg to NewReg:SubIdx.
35 /// @param OldReg Old virtual register that is going away.
36 /// @param NewReg New register holding the user variables.
37 /// @param SubIdx If NewReg is a virtual register, SubIdx may indicate a sub-
38 /// register.
39 void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx);
40
41 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
42 /// that happened during register allocation.
43 void emitDebugValues();
44
45 private:
46
47 /// runOnMachineFunction - Analyze and remove DBG_VALUE instructions.
48 virtual bool runOnMachineFunction(MachineFunction &);
49
50 virtual void getAnalysisUsage(AnalysisUsage &) const;
51
52 };
53
54 } // namespace llvm
55
56 #endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H