1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[LiveDebugValues] Add switches for using instr-ref variable locations

This patch adds the -Xclang option
"-fexperimental-debug-variable-locations" and same LLVM CodeGen option,
to pick which variable location tracking solution to use.

Right now all the switch does is pick which LiveDebugValues
implementation to use, the normal VarLoc one or the instruction
referencing one in rGae6f78824031. Over time, the aim is to add fragments
of support in aid of the value-tracking RFC:

  http://lists.llvm.org/pipermail/llvm-dev/2020-February/139440.html

also controlled by this command line switch. That will slowly move
variable locations to be defined by an instruction calculating a value,
and a DBG_INSTR_REF instruction referring to that value. Thus, this is
going to grow into a "use the new kind of variable locations" switch,
rather than just "use the new LiveDebugValues implementation".

Differential Revision: https://reviews.llvm.org/D83048
This commit is contained in:
Jeremy Morse 2020-08-25 14:23:14 +01:00
parent 1a92d5b134
commit f5080847e6
4 changed files with 39 additions and 5 deletions

View File

@ -116,6 +116,8 @@ bool getEmitCallSiteInfo();
bool getEnableDebugEntryValues();
bool getValueTrackingVariableLocations();
bool getForceDwarfFrameSection();
bool getXRayOmitFunctionIndex();

View File

@ -126,8 +126,8 @@ namespace llvm {
EmitStackSizeSection(false), EnableMachineOutliner(false),
SupportsDefaultOutlining(false), EmitAddrsig(false),
EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
EnableDebugEntryValues(false), ForceDwarfFrameSection(false),
XRayOmitFunctionIndex(false),
EnableDebugEntryValues(false), ValueTrackingVariableLocations(false),
ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
/// DisableFramePointerElim - This returns true if frame pointer elimination
@ -285,6 +285,11 @@ namespace llvm {
/// production.
bool ShouldEmitDebugEntryValues() const;
// When set to true, use experimental new debug variable location tracking,
// which seeks to follow the values of variables rather than their location,
// post isel.
unsigned ValueTrackingVariableLocations : 1;
/// Emit DWARF debug frame section.
unsigned ForceDwarfFrameSection : 1;

View File

@ -85,6 +85,7 @@ CGOPT(bool, EnableStackSizeSection)
CGOPT(bool, EnableAddrsig)
CGOPT(bool, EmitCallSiteInfo)
CGOPT(bool, EnableDebugEntryValues)
CGOPT(bool, ValueTrackingVariableLocations)
CGOPT(bool, ForceDwarfFrameSection)
CGOPT(bool, XRayOmitFunctionIndex)
@ -400,6 +401,12 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
cl::init(false));
CGBINDOPT(EnableDebugEntryValues);
static cl::opt<bool> ValueTrackingVariableLocations(
"experimental-debug-variable-locations",
cl::desc("Use experimental new value-tracking variable locations"),
cl::init(false));
CGBINDOPT(ValueTrackingVariableLocations);
static cl::opt<bool> ForceDwarfFrameSection(
"force-dwarf-frame-section",
cl::desc("Always emit a debug frame section."), cl::init(false));
@ -475,6 +482,7 @@ TargetOptions codegen::InitTargetOptionsFromCodeGenFlags() {
Options.EmitAddrsig = getEnableAddrsig();
Options.EmitCallSiteInfo = getEmitCallSiteInfo();
Options.EnableDebugEntryValues = getEnableDebugEntryValues();
Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations();
Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();

View File

@ -14,6 +14,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetMachine.h"
/// \file LiveDebugValues.cpp
///
@ -40,7 +41,10 @@ public:
static char ID;
LiveDebugValues();
~LiveDebugValues() { delete TheImpl; }
~LiveDebugValues() {
if (TheImpl)
delete TheImpl;
}
/// Calculate the liveness information for the given machine function.
bool runOnMachineFunction(MachineFunction &MF) override;
@ -57,6 +61,7 @@ public:
private:
LDVImpl *TheImpl;
TargetPassConfig *TPC;
};
char LiveDebugValues::ID = 0;
@ -69,10 +74,24 @@ INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
/// Default construct and initialize the pass.
LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry());
TheImpl = llvm::makeVarLocBasedLiveDebugValues();
TheImpl = nullptr;
}
bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
if (!TheImpl) {
TPC = getAnalysisIfAvailable<TargetPassConfig>();
bool InstrRefBased = false;
if (TPC) {
auto &TM = TPC->getTM<TargetMachine>();
InstrRefBased = TM.Options.ValueTrackingVariableLocations;
}
if (InstrRefBased)
TheImpl = llvm::makeInstrRefBasedLiveDebugValues();
else
TheImpl = llvm::makeVarLocBasedLiveDebugValues();
}
return TheImpl->ExtendRanges(MF, TPC);
}