diff options
author | Bob Haarman <llvm@inglorion.net> | 2017-08-29 20:59:25 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2017-08-29 20:59:25 +0000 |
commit | 223303c5a39b232bd3d6f4b207e6e0b01febf4c5 (patch) | |
tree | 573984cc1df9510343aee9fed7a06bc3f9754302 /llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h | |
parent | 4faeb87ebe8942dc7b997f763ed8899a0bcfb963 (diff) | |
download | bcm5719-llvm-223303c5a39b232bd3d6f4b207e6e0b01febf4c5.tar.gz bcm5719-llvm-223303c5a39b232bd3d6f4b207e6e0b01febf4c5.zip |
Reland r311957 [codeview] support more DW_OPs for more complete debug info
Summary:
Some variables show up in Visual Studio as "optimized out" even in -O0
-Od builds. This change fixes two issues that would cause this to
happen. The first issue is that not all DIExpressions we generate were
recognized by the CodeView writer. This has been addressed by adding
support for DW_OP_constu, DW_OP_minus, and DW_OP_plus. The second
issue is that we had no way to encode DW_OP_deref in CodeView. We get
around that by changinge the type we encode in the debug info to be
a reference to the type in the source code.
This fixes PR34261.
The reland adds two extra checks to the original: It checks if the
DbgVariableLocation is valid before checking any of its fields, and
it only emits ranges with nonzero registers.
Reviewers: aprantl, rnk, zturner
Reviewed By: rnk
Subscribers: mgorny, llvm-commits, aprantl, hiraditya
Differential Revision: https://reviews.llvm.org/D36907
llvm-svn: 312034
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h index 659a921e1fc..670300cd7a6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h @@ -17,14 +17,44 @@ #include "AsmPrinterHandler.h" #include "DbgValueHistoryCalculator.h" +#include "llvm/ADT/Optional.h" #include "llvm/CodeGen/LexicalScopes.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/IR/DebugInfoMetadata.h" namespace llvm { class AsmPrinter; +class MachineInstr; class MachineModuleInfo; +/// Represents the location at which a variable is stored. +struct DbgVariableLocation { + /// Offset relative to base register. + int64_t Offset; + + /// Base register. + unsigned Register; + + /// If false, Register is the location. If true, + /// Register+Offset point at the location. + unsigned InMemory : 1; + + /// If false, the location holds the variable's value. + /// If true, the location holds the variable's address. + unsigned Deref : 1; + + /// Present if the location is part of a larger variable. + llvm::Optional<llvm::DIExpression::FragmentInfo> FragmentInfo; + + /// Extract a VariableLocation from a MachineInstr. The struct passed in as + /// Location is populated. The MachineInstr must be a debug value + /// instruction. + /// @return true if successful and false if not. + static bool extractFromMachineInstruction(DbgVariableLocation &Location, + const MachineInstr &Instruction); +}; + /// Base class for debug information backends. Common functionality related to /// tracking which variables and scopes are alive at a given PC live here. class DebugHandlerBase : public AsmPrinterHandler { |