aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2020-08-22 14:10:16 +0100
committerJeremy Morse <jeremy.morse@sony.com>2020-08-22 14:50:22 +0100
commit20bb9fe565ab2c70b768d829d42bbbaea2be85cc (patch)
tree6133c16c174692404ed7f189b8c77dd0b2652f7f /llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
parente7d9182a666a2a8f903bd330c82d7c623b783371 (diff)
downloadllvm-20bb9fe565ab2c70b768d829d42bbbaea2be85cc.zip
llvm-20bb9fe565ab2c70b768d829d42bbbaea2be85cc.tar.gz
llvm-20bb9fe565ab2c70b768d829d42bbbaea2be85cc.tar.bz2
[LiveDebugValues] Install an implementation-picking LiveDebugValues pass
This patch renames the current LiveDebugValues class to "VarLocBasedLDV" and removes the pass-registration code from it. It creates a separate LiveDebugValues class that deals with pass registration and management, that calls through to VarLocBasedLDV::ExtendRanges when runOnMachineFunction is called. This is done through the "LDVImpl" abstract class, so that a future patch can install the new instruction-referencing LiveDebugValues implementation and have it picked at runtime. No functional change is intended, just shuffling responsibilities. Differential Revision: https://reviews.llvm.org/D83046
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
new file mode 100644
index 0000000..b8584e8
--- /dev/null
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -0,0 +1,78 @@
+//===- LiveDebugValues.cpp - Tracking Debug Value MIs ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "LiveDebugValues.h"
+
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+
+/// \file LiveDebugValues.cpp
+///
+/// The LiveDebugValues pass extends the range of variable locations
+/// (specified by DBG_VALUE instructions) from single blocks to successors
+/// and any other code locations where the variable location is valid.
+/// There are currently two implementations: the "VarLoc" implementation
+/// explicitly tracks the location of a variable, while the "InstrRef"
+/// implementation tracks the values defined by instructions through locations.
+///
+/// This file implements neither; it merely registers the pass, allows the
+/// user to pick which implementation will be used to propagate variable
+/// locations.
+
+#define DEBUG_TYPE "livedebugvalues"
+
+using namespace llvm;
+
+/// Generic LiveDebugValues pass. Calls through to VarLocBasedLDV or
+/// InstrRefBasedLDV to perform location propagation, via the LDVImpl
+/// base class.
+class LiveDebugValues : public MachineFunctionPass {
+public:
+ static char ID;
+
+ LiveDebugValues();
+ ~LiveDebugValues() { delete TheImpl; }
+
+ /// Calculate the liveness information for the given machine function.
+ bool runOnMachineFunction(MachineFunction &MF) override;
+
+ MachineFunctionProperties getRequiredProperties() const override {
+ return MachineFunctionProperties().set(
+ MachineFunctionProperties::Property::NoVRegs);
+ }
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesCFG();
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
+
+private:
+ LDVImpl *TheImpl;
+};
+
+char LiveDebugValues::ID = 0;
+
+char &llvm::LiveDebugValuesID = LiveDebugValues::ID;
+
+INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
+ false)
+
+/// Default construct and initialize the pass.
+LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
+ initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry());
+ TheImpl = llvm::makeVarLocBasedLiveDebugValues();
+}
+
+bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
+ auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
+ return TheImpl->ExtendRanges(MF, TPC);
+}