2017-08-25 05:21:39 +08:00
|
|
|
//===- LiveDebugVariables.h - Tracking debug info variables -----*- C++ -*-===//
|
2010-11-30 10:17:10 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides the interface to the LiveDebugVariables analysis.
|
|
|
|
//
|
|
|
|
// The analysis removes DBG_VALUE instructions for virtual registers and tracks
|
|
|
|
// live user variables in a data structure that can be updated during register
|
|
|
|
// allocation.
|
|
|
|
//
|
|
|
|
// After register allocation new DBG_VALUE instructions are emitted to reflect
|
|
|
|
// the new locations of user variables.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
|
|
|
|
#define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
|
2010-11-30 10:17:10 +08:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2017-08-25 05:21:39 +08:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2010-11-30 10:17:10 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2016-04-18 17:17:29 +08:00
|
|
|
template <typename T> class ArrayRef;
|
2013-08-15 07:50:04 +08:00
|
|
|
class LiveIntervals;
|
2010-12-04 05:47:10 +08:00
|
|
|
class VirtRegMap;
|
|
|
|
|
2015-07-01 22:47:39 +08:00
|
|
|
class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
|
2017-08-25 05:21:39 +08:00
|
|
|
void *pImpl = nullptr;
|
2015-04-18 07:20:10 +08:00
|
|
|
|
2010-11-30 10:17:10 +08:00
|
|
|
public:
|
|
|
|
static char ID; // Pass identification, replacement for typeid
|
|
|
|
|
|
|
|
LiveDebugVariables();
|
2015-04-11 10:11:45 +08:00
|
|
|
~LiveDebugVariables() override;
|
2010-11-30 10:17:10 +08:00
|
|
|
|
2011-05-07 02:00:02 +08:00
|
|
|
/// splitRegister - Move any user variables in OldReg to the live ranges in
|
|
|
|
/// NewRegs where they are live. Mark the values as unavailable where no new
|
|
|
|
/// register is live.
|
2013-08-15 07:50:04 +08:00
|
|
|
void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
|
|
|
|
LiveIntervals &LIS);
|
2011-05-07 02:00:02 +08:00
|
|
|
|
2010-11-30 10:17:10 +08:00
|
|
|
/// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
|
|
|
|
/// that happened during register allocation.
|
2010-12-04 05:47:10 +08:00
|
|
|
/// @param VRM Rename virtual registers according to map.
|
|
|
|
void emitDebugValues(VirtRegMap *VRM);
|
2010-11-30 10:17:10 +08:00
|
|
|
|
2010-12-03 02:15:44 +08:00
|
|
|
/// dump - Print data structures to dbgs().
|
2017-06-22 06:19:17 +08:00
|
|
|
void dump() const;
|
2010-12-03 02:15:44 +08:00
|
|
|
|
2010-11-30 10:17:10 +08:00
|
|
|
private:
|
2014-03-07 17:26:03 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &) override;
|
|
|
|
void releaseMemory() override;
|
|
|
|
void getAnalysisUsage(AnalysisUsage &) const override;
|
Recommit r212203: Don't try to construct debug LexicalScopes hierarchy for functions that do not have top level debug information.
Reverted by Eric Christopher (Thanks!) in r212203 after Bob Wilson
reported LTO issues. Duncan Exon Smith and Aditya Nandakumar helped
provide a reduced reproduction, though the failure wasn't too hard to
guess, and even easier with the example to confirm.
The assertion that the subprogram metadata associated with an
llvm::Function matches the scope data referenced by the DbgLocs on the
instructions in that function is not valid under LTO. In LTO, a C++
inline function might exist in multiple CUs and the subprogram metadata
nodes will refer to the same llvm::Function. In this case, depending on
the order of the CUs, the first intance of the subprogram metadata may
not be the one referenced by the instructions in that function and the
assertion will fail.
A test case (test/DebugInfo/cross-cu-linkonce-distinct.ll) is added, the
assertion removed and a comment added to explain this situation.
This was then reverted again in r213581 as it caused PR20367. The root
cause of this was the early exit in LiveDebugVariables meant that
spurious DBG_VALUE intrinsics that referenced dead variables were not
removed, causing an assertion/crash later on. The fix is to have
LiveDebugVariables strip all DBG_VALUE intrinsics in functions without
debug info as they're not needed anyway. Test case added to cover this
situation (that occurs when a debug-having function is inlined into a
nodebug function) in test/DebugInfo/X86/nodebug_with_debug_loc.ll
Original commit message:
If a function isn't actually in a CU's subprogram list in the debug info
metadata, ignore all the DebugLocs and don't try to build scopes, track
variables, etc.
While this is possibly a minor optimization, it's also a correctness fix
for an incoming patch that will add assertions to LexicalScopes and the
debug info verifier to ensure that all scope chains lead to debug info
for the current function.
Fix up a few test cases that had broken/incomplete debug info that could
violate this constraint.
Add a test case where this occurs by design (inlining a
debug-info-having function in an attribute nodebug function - we want
this to work because /if/ the nodebug function is then inlined into a
debug-info-having function, it should be fine (and will work fine - we
just stitch the scopes up as usual), but should the inlining not happen
we need to not assert fail either).
llvm-svn: 213952
2014-07-26 00:10:16 +08:00
|
|
|
bool doInitialization(Module &) override;
|
2010-11-30 10:17:10 +08:00
|
|
|
};
|
|
|
|
|
2017-08-25 05:21:39 +08:00
|
|
|
} // end namespace llvm
|
2010-11-30 10:17:10 +08:00
|
|
|
|
2017-08-25 05:21:39 +08:00
|
|
|
#endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
|