LLVM  14.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"
19 
20 /// \file LiveDebugValues.cpp
21 ///
22 /// The LiveDebugValues pass extends the range of variable locations
23 /// (specified by DBG_VALUE instructions) from single blocks to successors
24 /// and any other code locations where the variable location is valid.
25 /// There are currently two implementations: the "VarLoc" implementation
26 /// explicitly tracks the location of a variable, while the "InstrRef"
27 /// implementation tracks the values defined by instructions through locations.
28 ///
29 /// This file implements neither; it merely registers the pass, allows the
30 /// user to pick which implementation will be used to propagate variable
31 /// locations.
32 
33 #define DEBUG_TYPE "livedebugvalues"
34 
35 using namespace llvm;
36 
37 static cl::opt<bool>
38  ForceInstrRefLDV("force-instr-ref-livedebugvalues", cl::Hidden,
39  cl::desc("Use instruction-ref based LiveDebugValues with "
40  "normal DBG_VALUE inputs"),
41  cl::init(false));
42 
43 /// Generic LiveDebugValues pass. Calls through to VarLocBasedLDV or
44 /// InstrRefBasedLDV to perform location propagation, via the LDVImpl
45 /// base class.
47 public:
48  static char ID;
49 
52  if (TheImpl)
53  delete TheImpl;
54  }
55 
56  /// Calculate the liveness information for the given machine function.
57  bool runOnMachineFunction(MachineFunction &MF) override;
58 
62  }
63 
64  void getAnalysisUsage(AnalysisUsage &AU) const override {
65  AU.setPreservesCFG();
67  }
68 
69 private:
70  LDVImpl *TheImpl;
71  TargetPassConfig *TPC;
72 };
73 
74 char LiveDebugValues::ID = 0;
75 
77 
78 INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
79  false)
80 
81 /// Default construct and initialize the pass.
84  TheImpl = nullptr;
85 }
86 
88  if (!TheImpl) {
89  TPC = getAnalysisIfAvailable<TargetPassConfig>();
90 
91  bool InstrRefBased = false;
92  if (TPC) {
93  auto &TM = TPC->getTM<TargetMachine>();
94  InstrRefBased = TM.Options.ValueTrackingVariableLocations;
95  }
96 
97  // Allow the user to force selection of InstrRef LDV.
98  InstrRefBased |= ForceInstrRefLDV;
99 
100  if (InstrRefBased)
102  else
104  }
105 
106  return TheImpl->ExtendRanges(MF, TPC);
107 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
LiveDebugValues
Generic LiveDebugValues pass.
Definition: LiveDebugValues.cpp:46
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::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
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:33
CommandLine.h
llvm::LiveDebugValuesID
char & LiveDebugValuesID
LiveDebugValues pass.
Definition: LiveDebugValues.cpp:76
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:169
LiveDebugValues::~LiveDebugValues
~LiveDebugValues()
Definition: LiveDebugValues.cpp:51
ForceInstrRefLDV
static cl::opt< bool > ForceInstrRefLDV("force-instr-ref-livedebugvalues", cl::Hidden, cl::desc("Use instruction-ref based LiveDebugValues with " "normal DBG_VALUE inputs"), cl::init(false))
llvm::MachineFunctionProperties::Property::NoVRegs
@ NoVRegs
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::cl::opt< bool >
LiveDebugValues::getRequiredProperties
MachineFunctionProperties getRequiredProperties() const override
Definition: LiveDebugValues.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
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:87
llvm::makeInstrRefBasedLiveDebugValues
LDVImpl * makeInstrRefBasedLiveDebugValues()
Definition: InstrRefBasedImpl.cpp:3690
llvm::MachineFunction
Definition: MachineFunction.h:230
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:48
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:78
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::cl::desc
Definition: CommandLine.h:414
llvm::makeVarLocBasedLiveDebugValues
LDVImpl * makeVarLocBasedLiveDebugValues()
Definition: VarLocBasedImpl.cpp:2223
InitializePasses.h
LiveDebugValues::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: LiveDebugValues.cpp:64
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38