LLVM  13.0.0git
LiveDebugValues.cpp
Go to the documentation of this file.
1 //===- LiveDebugValues.cpp - Tracking Debug Value MIs ---------------------===//
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 #include "LiveDebugValues.h"
10 
14 #include "llvm/CodeGen/Passes.h"
15 #include "llvm/InitializePasses.h"
16 #include "llvm/Pass.h"
18 
19 /// \file LiveDebugValues.cpp
20 ///
21 /// The LiveDebugValues pass extends the range of variable locations
22 /// (specified by DBG_VALUE instructions) from single blocks to successors
23 /// and any other code locations where the variable location is valid.
24 /// There are currently two implementations: the "VarLoc" implementation
25 /// explicitly tracks the location of a variable, while the "InstrRef"
26 /// implementation tracks the values defined by instructions through locations.
27 ///
28 /// This file implements neither; it merely registers the pass, allows the
29 /// user to pick which implementation will be used to propagate variable
30 /// locations.
31 
32 #define DEBUG_TYPE "livedebugvalues"
33 
34 using namespace llvm;
35 
36 /// Generic LiveDebugValues pass. Calls through to VarLocBasedLDV or
37 /// InstrRefBasedLDV to perform location propagation, via the LDVImpl
38 /// base class.
40 public:
41  static char ID;
42 
45  if (TheImpl)
46  delete TheImpl;
47  }
48 
49  /// Calculate the liveness information for the given machine function.
50  bool runOnMachineFunction(MachineFunction &MF) override;
51 
55  }
56 
57  void getAnalysisUsage(AnalysisUsage &AU) const override {
58  AU.setPreservesCFG();
60  }
61 
62 private:
63  LDVImpl *TheImpl;
64  TargetPassConfig *TPC;
65 };
66 
67 char LiveDebugValues::ID = 0;
68 
70 
71 INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
72  false)
73 
74 /// Default construct and initialize the pass.
77  TheImpl = nullptr;
78 }
79 
81  if (!TheImpl) {
82  TPC = getAnalysisIfAvailable<TargetPassConfig>();
83 
84  bool InstrRefBased = false;
85  if (TPC) {
86  auto &TM = TPC->getTM<TargetMachine>();
87  InstrRefBased = TM.Options.ValueTrackingVariableLocations;
88  }
89 
90  if (InstrRefBased)
92  else
94  }
95 
96  return TheImpl->ExtendRanges(MF, TPC);
97 }
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
LiveDebugValues
Generic LiveDebugValues pass.
Definition: LiveDebugValues.cpp:39
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::SharedLiveDebugValues::LDVImpl
Definition: LiveDebugValues.h:24
llvm::initializeLiveDebugValuesPass
void initializeLiveDebugValuesPass(PassRegistry &)
Pass.h
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
MachineBasicBlock.h
llvm::MachineFunctionProperties
Properties which a MachineFunction may have at a given point in time.
Definition: MachineFunction.h:111
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: MachineFunctionPass.cpp:102
DEBUG_TYPE
#define DEBUG_TYPE
Definition: LiveDebugValues.cpp:32
llvm::LiveDebugValuesID
char & LiveDebugValuesID
LiveDebugValues pass.
Definition: LiveDebugValues.cpp:69
TargetMachine.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:166
LiveDebugValues::~LiveDebugValues
~LiveDebugValues()
Definition: LiveDebugValues.cpp:44
llvm::MachineFunctionProperties::Property::NoVRegs
@ NoVRegs
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
LiveDebugValues::getRequiredProperties
MachineFunctionProperties getRequiredProperties() const override
Definition: LiveDebugValues.cpp:52
MachineFunctionPass.h
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
LiveDebugValues::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &MF) override
Calculate the liveness information for the given machine function.
Definition: LiveDebugValues.cpp:80
llvm::makeInstrRefBasedLiveDebugValues
LDVImpl * makeInstrRefBasedLiveDebugValues()
Definition: InstrRefBasedImpl.cpp:3359
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:253
MachineFrameInfo.h
LiveDebugValues::ID
static char ID
Definition: LiveDebugValues.cpp:41
LiveDebugValues.h
INITIALIZE_PASS
INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false, false) LiveDebugValues
Default construct and initialize the pass.
Definition: LiveDebugValues.cpp:71
llvm::makeVarLocBasedLiveDebugValues
LDVImpl * makeVarLocBasedLiveDebugValues()
Definition: VarLocBasedImpl.cpp:1990
InitializePasses.h
LiveDebugValues::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: LiveDebugValues.cpp:57
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37