llvm-6502/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
Adrian Prantl 988b78a846 This reapplies r207235 with an additional bugfixes caught by the msan
buildbot - do not insert debug intrinsics before phi nodes.

Debug info for optimized code: Support variables that are on the stack and
described by DBG_VALUEs during their lifetime.

Previously, when a variable was at a FrameIndex for any part of its
lifetime, this would shadow all other DBG_VALUEs and only a single
fbreg location would be emitted, which in fact is only valid for a small
range and not the entire lexical scope of the variable. The included
dbg-value-const-byref testcase demonstrates this.

This patch fixes this by
Local
- emitting dbg.value intrinsics for allocas that are passed by reference
- dropping all dbg.declares (they are now fully lowered to dbg.values)
SelectionDAG
- renamed constructors for SDDbgValue for better readability.
- fix UserValue::match() to handle indirect values correctly
- not inserting an MMI table entries for dbg.values that describe allocas.
- lowering dbg.values that describe allocas into *indirect* DBG_VALUEs.
CodeGenPrepare
- leaving dbg.values for an alloca were they are (see comment)
Other
- regenerated/updated instcombine.ll testcase and included source

rdar://problem/16679879
http://reviews.llvm.org/D3374

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207269 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 20:49:25 +00:00

123 lines
3.5 KiB
C++

//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the SDDbgValue class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_SDNODEDBGVALUE_H
#define LLVM_CODEGEN_SDNODEDBGVALUE_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Support/DataTypes.h"
namespace llvm {
class MDNode;
class SDNode;
class Value;
/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
/// We do not use SDValue here to avoid including its header.
class SDDbgValue {
public:
enum DbgValueKind {
SDNODE = 0, // value is the result of an expression
CONST = 1, // value is a constant
FRAMEIX = 2 // value is contents of a stack location
};
private:
enum DbgValueKind kind;
union {
struct {
SDNode *Node; // valid for expressions
unsigned ResNo; // valid for expressions
} s;
const Value *Const; // valid for constants
unsigned FrameIx; // valid for stack objects
} u;
MDNode *mdPtr;
bool IsIndirect;
uint64_t Offset;
DebugLoc DL;
unsigned Order;
bool Invalid;
public:
// Constructor for non-constants.
SDDbgValue(MDNode *mdP, SDNode *N, unsigned R,
bool indir, uint64_t off, DebugLoc dl,
unsigned O) : mdPtr(mdP), IsIndirect(indir),
Offset(off), DL(dl), Order(O),
Invalid(false) {
kind = SDNODE;
u.s.Node = N;
u.s.ResNo = R;
}
// Constructor for constants.
SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl,
unsigned O) :
mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
Invalid(false) {
kind = CONST;
u.Const = C;
}
// Constructor for frame indices.
SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
Invalid(false) {
kind = FRAMEIX;
u.FrameIx = FI;
}
// Returns the kind.
DbgValueKind getKind() { return kind; }
// Returns the MDNode pointer.
MDNode *getMDPtr() { return mdPtr; }
// Returns the SDNode* for a register ref
SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
// Returns the ResNo for a register ref
unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
// Returns the Value* for a constant
const Value *getConst() { assert (kind==CONST); return u.Const; }
// Returns the FrameIx for a stack object
unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
// Returns whether this is an indirect value.
bool isIndirect() { return IsIndirect; }
// Returns the offset.
uint64_t getOffset() { return Offset; }
// Returns the DebugLoc.
DebugLoc getDebugLoc() { return DL; }
// Returns the SDNodeOrder. This is the order of the preceding node in the
// input.
unsigned getOrder() { return Order; }
// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
// property. A SDDbgValue is invalid if the SDNode that produces the value is
// deleted.
void setIsInvalidated() { Invalid = true; }
bool isInvalidated() { return Invalid; }
};
} // end llvm namespace
#endif