Skip to content

Commit

Permalink
Revert r218778 while investigating buldbot breakage.
Browse files Browse the repository at this point in the history
"Move the complex address expression out of DIVariable and into an extra"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218782 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
adrian-prantl committed Oct 1, 2014
1 parent 076fd5d commit 10c4265
Show file tree
Hide file tree
Showing 257 changed files with 1,378 additions and 1,530 deletions.
17 changes: 2 additions & 15 deletions docs/SourceLevelDebugging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ Local variables
metadata, ;; Reference to the type descriptor
i32, ;; flags
metadata ;; (optional) Reference to inline location
metadata ;; (optional) Reference to a complex expression.
metadata ;; (optional) Reference to a complex expression (see below)
}
These descriptors are used to define variables local to a sub program. The
Expand All @@ -590,20 +590,7 @@ The context is either the subprogram or block where the variable is defined.
Name the source variable name. Context and line indicate where the variable
was defined. Type descriptor defines the declared type of the variable.

Complex Expressions
^^^^^^^^^^^^^^^^^^^
.. code-block:: llvm
!8 = metadata !{
i32, ;; DW_TAG_expression
...
}
Complex expressions describe variable storage locations in terms of
prefix-notated DWARF expressions. Currently the only supported
operators are ``DW_OP_plus``, ``DW_OP_deref``, and ``DW_OP_piece``.

The ``DW_OP_piece`` operator is used for (typically larger aggregate)
The ``OpPiece`` operator is used for (typically larger aggregate)
variables that are fragmented across several locations. It takes two
i32 arguments, an offset and a size in bytes to describe which piece
of the variable is at this location.
Expand Down
16 changes: 3 additions & 13 deletions include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,12 @@ class MachineInstr : public ilist_node<MachineInstr> {
///
DebugLoc getDebugLoc() const { return debugLoc; }

/// \brief Return the debug variable referenced by
/// getDebugVariable() - Return the debug variable referenced by
/// this DBG_VALUE instruction.
DIVariable getDebugVariable() const {
assert(isDebugValue() && "not a DBG_VALUE");
DIVariable Var(getOperand(2).getMetadata());
assert(Var.Verify() && "not a DIVariable");
return Var;
}

/// \brief Return the complex address expression referenced by
/// this DBG_VALUE instruction.
DIExpression getDebugExpression() const {
assert(isDebugValue() && "not a DBG_VALUE");
DIExpression Expr(getOperand(3).getMetadata());
assert(Expr.Verify() && "not a DIExpression");
return Expr;
const MDNode *Var = getOperand(getNumOperands() - 1).getMetadata();
return DIVariable(Var);
}

/// emitError - Emit an error referring to the source location of this
Expand Down
45 changes: 21 additions & 24 deletions include/llvm/CodeGen/MachineInstrBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ class MachineInstrBuilder {

const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
assert((MI->isDebugValue() ? MI->getDebugVariable().Verify() : true) &&
"first MDNode argument of a DBG_VALUE not a DIVariable");
return *this;
}

Expand Down Expand Up @@ -347,25 +345,24 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
/// address. The convention is that a DBG_VALUE is indirect iff the
/// second operand is an immediate.
///
inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
assert(DIVariable(Variable).Verify() && "not a DIVariable");
assert(DIExpression(Expr).Verify() && "not a DIExpression");
inline MachineInstrBuilder BuildMI(MachineFunction &MF,
DebugLoc DL,
const MCInstrDesc &MCID,
bool IsIndirect,
unsigned Reg,
unsigned Offset,
const MDNode *MD) {
if (IsIndirect)
return BuildMI(MF, DL, MCID)
.addReg(Reg, RegState::Debug)
.addImm(Offset)
.addMetadata(Variable)
.addMetadata(Expr);
.addReg(Reg, RegState::Debug)
.addImm(Offset)
.addMetadata(MD);
else {
assert(Offset == 0 && "A direct address cannot have an offset.");
return BuildMI(MF, DL, MCID)
.addReg(Reg, RegState::Debug)
.addReg(0U, RegState::Debug)
.addMetadata(Variable)
.addMetadata(Expr);
.addReg(Reg, RegState::Debug)
.addReg(0U, RegState::Debug)
.addMetadata(MD);
}
}

Expand All @@ -374,15 +371,15 @@ inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
/// address and inserts it at position I.
///
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::iterator I, DebugLoc DL,
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
assert(DIVariable(Variable).Verify() && "not a DIVariable");
assert(DIExpression(Expr).Verify() && "not a DIExpression");
MachineBasicBlock::iterator I,
DebugLoc DL,
const MCInstrDesc &MCID,
bool IsIndirect,
unsigned Reg,
unsigned Offset,
const MDNode *MD) {
MachineFunction &MF = *BB.getParent();
MachineInstr *MI =
BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
MachineInstr *MI = BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, MD);
BB.insert(I, MI);
return MachineInstrBuilder(MF, MI);
}
Expand Down
6 changes: 2 additions & 4 deletions include/llvm/CodeGen/MachineModuleInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class MachineModuleInfo : public ImmutablePass {

struct VariableDbgInfo {
TrackingVH<MDNode> Var;
TrackingVH<MDNode> Expr;
unsigned Slot;
DebugLoc Loc;
};
Expand Down Expand Up @@ -391,9 +390,8 @@ class MachineModuleInfo : public ImmutablePass {

/// setVariableDbgInfo - Collect information used to emit debugging
/// information of a variable.
void setVariableDbgInfo(MDNode *Var, MDNode *Expr, unsigned Slot,
DebugLoc Loc) {
VariableDbgInfo Info = {Var, Expr, Slot, Loc};
void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc) {
VariableDbgInfo Info = { N, Slot, Loc };
VariableDbgInfos.push_back(std::move(Info));
}

Expand Down
21 changes: 9 additions & 12 deletions include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,18 +984,15 @@ class SelectionDAG {

/// getDbgValue - Creates a SDDbgValue node.
///
/// SDNode
SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R,
bool IsIndirect, uint64_t Off, DebugLoc DL,
unsigned O);

/// Constant
SDDbgValue *getConstantDbgValue(MDNode *Var, MDNode *Expr, const Value *C,
uint64_t Off, DebugLoc DL, unsigned O);

/// FrameIndex
SDDbgValue *getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, unsigned FI,
uint64_t Off, DebugLoc DL, unsigned O);
SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R,
bool IsIndirect, uint64_t Off,
DebugLoc DL, unsigned O);
/// Constant.
SDDbgValue *getConstantDbgValue(MDNode *MDPtr, const Value *C, uint64_t Off,
DebugLoc DL, unsigned O);
/// Frame index.
SDDbgValue *getFrameIndexDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off,
DebugLoc DL, unsigned O);

/// RemoveDeadNode - Remove the specified node from the system. If any of its
/// operands then becomes dead, remove them as well. Inform UpdateListener
Expand Down
39 changes: 26 additions & 13 deletions include/llvm/IR/DIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace llvm {

public:
explicit DIBuilder(Module &M);
enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
enum DebugEmissionKind { FullDebug=1, LineTablesOnly };

/// finalize - Construct any deferred debug info descriptors.
Expand Down Expand Up @@ -500,18 +501,33 @@ namespace llvm {
unsigned Flags = 0,
unsigned ArgNo = 0);

/// createExpression - Create a new descriptor for the specified

/// createComplexVariable - Create a new descriptor for the specified
/// variable which has a complex address expression for its address.
/// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
/// DW_TAG_arg_variable.
/// @param Scope Variable scope.
/// @param Name Variable name.
/// @param F File where this variable is defined.
/// @param LineNo Line number.
/// @param Ty Variable Type
/// @param Addr An array of complex address operations.
DIExpression createExpression(ArrayRef<Value *> Addr = None);
/// @param ArgNo If this variable is an argument then this argument's
/// number. 1 indicates 1st argument.
DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
StringRef Name, DIFile F, unsigned LineNo,
DITypeRef Ty, ArrayRef<Value *> Addr,
unsigned ArgNo = 0);

/// createPieceExpression - Create a descriptor to describe one part
/// createVariablePiece - Create a descriptor to describe one part
/// of aggregate variable that is fragmented across multiple Values.
///
/// @param Variable Variable that is partially represented by this.
/// @param OffsetInBytes Offset of the piece in bytes.
/// @param SizeInBytes Size of the piece in bytes.
DIExpression createPieceExpression(unsigned OffsetInBytes,
unsigned SizeInBytes);
DIVariable createVariablePiece(DIVariable Variable,
unsigned OffsetInBytes,
unsigned SizeInBytes);

/// createFunction - Create a new descriptor for the specified subprogram.
/// See comments in DISubprogram for descriptions of these fields.
Expand Down Expand Up @@ -659,37 +675,34 @@ namespace llvm {
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
/// @param Storage llvm::Value of the variable
/// @param VarInfo Variable's debug info descriptor.
/// @param Expr A complex location expression.
/// @param InsertAtEnd Location for the new intrinsic.
Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
DIExpression Expr, BasicBlock *InsertAtEnd);
BasicBlock *InsertAtEnd);

/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
/// @param Storage llvm::Value of the variable
/// @param VarInfo Variable's debug info descriptor.
/// @param Expr A complex location expression.
/// @param InsertBefore Location for the new intrinsic.
Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
DIExpression Expr, Instruction *InsertBefore);
Instruction *InsertBefore);


/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
/// @param Val llvm::Value of the variable
/// @param Offset Offset
/// @param VarInfo Variable's debug info descriptor.
/// @param Expr A complex location expression.
/// @param InsertAtEnd Location for the new intrinsic.
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
DIVariable VarInfo, DIExpression Expr,
DIVariable VarInfo,
BasicBlock *InsertAtEnd);

/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
/// @param Val llvm::Value of the variable
/// @param Offset Offset
/// @param VarInfo Variable's debug info descriptor.
/// @param Expr A complex location expression.
/// @param InsertBefore Location for the new intrinsic.
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
DIVariable VarInfo, DIExpression Expr,
DIVariable VarInfo,
Instruction *InsertBefore);
};
} // end namespace llvm
Expand Down
52 changes: 22 additions & 30 deletions include/llvm/IR/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class DIDescriptor {
bool isTemplateValueParameter() const;
bool isObjCProperty() const;
bool isImportedEntity() const;
bool isExpression() const;

/// print - print descriptor.
void print(raw_ostream &OS) const;
Expand Down Expand Up @@ -721,6 +720,20 @@ class DIVariable : public DIDescriptor {
/// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;

/// HasComplexAddr - Return true if the variable has a complex address.
bool hasComplexAddress() const { return getNumAddrElements() > 0; }

/// \brief Return the size of this variable's complex address or
/// zero if there is none.
unsigned getNumAddrElements() const {
if (DbgNode->getNumOperands() < 9)
return 0;
return getDescriptorField(8)->getNumOperands();
}

/// \brief return the Idx'th complex address element.
uint64_t getAddrElement(unsigned Idx) const;

/// isBlockByrefVariable - Return true if the variable was declared as
/// a "__block" variable (Apple Blocks).
bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
Expand All @@ -731,42 +744,18 @@ class DIVariable : public DIDescriptor {
/// information for an inlined function arguments.
bool isInlinedFnArgument(const Function *CurFn);

/// Return the size reported by the variable's type.
unsigned getSizeInBits(const DITypeIdentifierMap &Map);

void printExtendedName(raw_ostream &OS) const;
};

/// DIExpression - A complex location expression.
class DIExpression : public DIDescriptor {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;

public:
explicit DIExpression(const MDNode *N = nullptr) : DIDescriptor(N) {}

/// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;

/// \brief Return the number of elements in the complex expression.
unsigned getNumElements() const {
if (!DbgNode)
return 0;
unsigned N = DbgNode->getNumOperands();
assert(N > 0 && "missing tag");
return N - 1;
}

/// \brief return the Idx'th complex address element.
uint64_t getElement(unsigned Idx) const;

/// isVariablePiece - Return whether this is a piece of an aggregate
/// variable.
bool isVariablePiece() const;
/// getPieceOffset - Return the offset of this piece in bytes.
uint64_t getPieceOffset() const;
/// getPieceSize - Return the size of this piece in bytes.
uint64_t getPieceSize() const;

/// Return the size reported by the variable's type.
unsigned getSizeInBits(const DITypeIdentifierMap &Map);

void printExtendedName(raw_ostream &OS) const;
};

/// DILocation - This object holds location information. This object
Expand Down Expand Up @@ -883,6 +872,9 @@ DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
/// cleanseInlinedVariable - Remove inlined scope from the variable.
DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);

/// getEntireVariable - Remove OpPiece exprs from the variable.
DIVariable getEntireVariable(DIVariable DV);

/// Construct DITypeIdentifierMap by going through retained types of each CU.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);

Expand Down
2 changes: 0 additions & 2 deletions include/llvm/IR/IntrinsicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ namespace llvm {
public:
Value *getAddress() const;
MDNode *getVariable() const { return cast<MDNode>(getArgOperand(1)); }
MDNode *getExpression() const { return cast<MDNode>(getArgOperand(2)); }

// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const IntrinsicInst *I) {
Expand All @@ -104,7 +103,6 @@ namespace llvm {
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
}
MDNode *getVariable() const { return cast<MDNode>(getArgOperand(2)); }
MDNode *getExpression() const { return cast<MDNode>(getArgOperand(3)); }

// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const IntrinsicInst *I) {
Expand Down
5 changes: 1 addition & 4 deletions include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,9 @@ let Properties = [IntrNoMem] in {
// places.
let Properties = [IntrNoMem] in {
def int_dbg_declare : Intrinsic<[],
[llvm_metadata_ty,
llvm_metadata_ty,
llvm_metadata_ty]>;
[llvm_metadata_ty, llvm_metadata_ty]>;
def int_dbg_value : Intrinsic<[],
[llvm_metadata_ty, llvm_i64_ty,
llvm_metadata_ty,
llvm_metadata_ty]>;
}

Expand Down
1 change: 0 additions & 1 deletion include/llvm/Support/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ enum LLVMConstants : uint32_t {

DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
DW_TAG_arg_variable = 0x101, // Tag for argument variables.
DW_TAG_expression = 0x102, // Tag for complex address expressions.

DW_TAG_user_base = 0x1000, // Recommended base for user tags.

Expand Down
Loading

0 comments on commit 10c4265

Please sign in to comment.