Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 5420de3

Browse files
committed
DebugInfo: New metadata representation for global variables.
This patch reverses the edge from DIGlobalVariable to GlobalVariable. This will allow us to more easily preserve debug info metadata when manipulating global variables. Fixes PR30362. A program for upgrading test cases is attached to that bug. Differential Revision: http://reviews.llvm.org/D20147 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281284 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8d684ca commit 5420de3

File tree

159 files changed

+922
-796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+922
-796
lines changed

include/llvm/IR/DIBuilder.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,20 +454,21 @@ namespace llvm {
454454
/// \param Ty Variable Type.
455455
/// \param isLocalToUnit Boolean flag indicate whether this variable is
456456
/// externally visible or not.
457-
/// \param Val llvm::Value of the variable.
457+
/// \param Expr The location of the global relative to the attached
458+
/// GlobalVariable.
458459
/// \param Decl Reference to the corresponding declaration.
459460
DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
460461
StringRef LinkageName, DIFile *File,
461462
unsigned LineNo, DIType *Ty,
462463
bool isLocalToUnit,
463-
llvm::Constant *Val,
464+
DIExpression *Expr = nullptr,
464465
MDNode *Decl = nullptr);
465466

466467
/// Identical to createGlobalVariable
467468
/// except that the resulting DbgNode is temporary and meant to be RAUWed.
468469
DIGlobalVariable *createTempGlobalVariableFwdDecl(
469470
DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
470-
unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
471+
unsigned LineNo, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
471472
MDNode *Decl = nullptr);
472473

473474
/// Create a new descriptor for an auto variable. This is a local variable
@@ -514,6 +515,13 @@ namespace llvm {
514515
DIExpression *createBitPieceExpression(unsigned OffsetInBits,
515516
unsigned SizeInBits);
516517

518+
/// Create an expression for a variable that does not have an address, but
519+
/// does have a constant value.
520+
DIExpression *createConstantValueExpression(uint64_t Val) {
521+
return DIExpression::get(
522+
VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
523+
}
524+
517525
/// Create a new descriptor for the specified subprogram.
518526
/// See comments in DISubprogram* for descriptions of these fields.
519527
/// \param Scope Function scope.

0 commit comments

Comments
 (0)