<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [IR] DIGlobalVariable should not hold a DIExpression"
href="https://llvm.org/bugs/show_bug.cgi?id=31013">31013</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[IR] DIGlobalVariable should not hold a DIExpression
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aprantl@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Currently, DIGlobalVariables holds a DIExpression. This is not the best way to
model this:
(1) The DIGlobalVariable should describe the source level variable, not how to
get to its location.
(2) It makes it unsafe/hard to update the expressions when we call
replaceExpression on the DIGLobalVariable.
(3) It makes it impossible to represent a global variable that is in more than
one location (e.g., a variable with multiple DW_OP_piece-s).
We also moved away from attaching the DIExpression to DILocalVariable for the
same reasons.
A better representation would be to add a DIGlobalVariableExpression(var:
!DIGlobalVariable(...), expr: !DIExpression(...)) that wraps a global variable
and an expression. For example, let's say we have a global symbol g that
doesn't need an expression — this would still be represented as:
@g = global i32 0, !dbg !0
!0 = DIGlobalVariable(name: "g", ...)
Later, after some transformation, this becomes:
@opt_g = global i32 *, !dbg !1
!0 = distinct !DIGlobalVariable(name: "g", ...) ; Identical to !0 above.
!1 = !DIGlobalVariableExpr(var: !0, expr: !2) ; Not distinct.
!2 = !DIExpression(DW_OP_deref, ...)
This allows transformations to just add new mergeable metadata on top of the
existing DIGlobalVariable without blowing up the representation if they aren't
needed.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>