aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2020-07-22 09:25:14 +0100
committerOCHyams <orlando.hyams@sony.com>2020-07-22 12:45:21 +0100
commitce6de3747bce66b122134d02bb6d25827730d498 (patch)
tree63d70001b2851136f31bd6503306d61d2a73062a /llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
parent3520297039d69381cb5776235209fc08863b9095 (diff)
downloadllvm-ce6de3747bce66b122134d02bb6d25827730d498.zip
llvm-ce6de3747bce66b122134d02bb6d25827730d498.tar.gz
llvm-ce6de3747bce66b122134d02bb6d25827730d498.tar.bz2
[DebugInfo] Drop location ranges for variables which exist entirely outside the variable's scope
Summary: This patch reduces file size in debug builds by dropping variable locations a debugger user will not see. After building the debug entity history map we loop through it. For each variable we look at each entry. If the entry opens a location range which does not intersect any of the variable's scope's ranges then we mark it for removal. After visiting the entries for each variable we also mark any clobbering entries which will no longer be referenced for removal, and then finally erase the marked entries. This all requires the ability to query the order of instructions, so before this runs we number them. Tests: Added llvm/test/DebugInfo/X86/trim-var-locs.mir Modified llvm/test/DebugInfo/COFF/register-variables.ll Branch folding merges the tails of if.then and if.else into if.else. Each blocks' debug-locations point to different scopes so when they're merged we can't use either. Because of this the variable 'c' ends up with a location range which doesn't cover any instructions in its scope; with the patch applied the location range is dropped and its flag changes to IsOptimizedOut. Modified llvm/test/DebugInfo/X86/live-debug-variables.ll Modified llvm/test/DebugInfo/ARM/PR26163.ll In both tests an out of scope location is now removed. The remaining location covers the entire scope of the variable allowing us to emit it as a single location. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D82129
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 880791a..a46de83 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -21,11 +21,16 @@
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/CommandLine.h"
using namespace llvm;
#define DEBUG_TYPE "dwarfdebug"
+/// If true, we drop variable location ranges which exist entirely outside the
+/// variable's lexical scope instruction ranges.
+static cl::opt<bool> TrimVarLocs("trim-var-locs", cl::Hidden, cl::init(true));
+
Optional<DbgVariableLocation>
DbgVariableLocation::extractFromMachineInstruction(
const MachineInstr &Instruction) {
@@ -191,6 +196,8 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
assert(DbgLabels.empty() && "DbgLabels map wasn't cleaned!");
calculateDbgEntityHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(),
DbgValues, DbgLabels);
+ if (TrimVarLocs)
+ DbgValues.trimLocationRanges(*MF, LScopes);
LLVM_DEBUG(DbgValues.dump());
// Request labels for the full history.