<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Multiple debug variables sharing a stack slot are incorrectly formatted in MIR"
   href="https://bugs.llvm.org/show_bug.cgi?id=49144">49144</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Multiple debug variables sharing a stack slot are incorrectly formatted in MIR
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stephen.tozer@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24514" name="attach_24514" title="Call with llc -run-pass=stack-coloring to reproduce; also functions as a lit test.">attachment 24514</a> <a href="attachment.cgi?id=24514&action=edit" title="Call with llc -run-pass=stack-coloring to reproduce; also functions as a lit test.">[details]</a></span>
Call with llc -run-pass=stack-coloring to reproduce; also functions as a lit
test.

This is a bug that occurs when we have two (or more) stack slots that have
associated debug declares, and the stack coloring pass merges them so that we
have a stack slot with multiple debug declares. Instead of printing them out as
a list of some kind, we simply print them off adjacent in a syntactically
invalid format; attempting to parse the resulting MIR simply results in a
crash.

For example, from the reproducer:

stack:
  - { id: 0, ...,
      debug-info-variable: '!4', debug-info-expression: '!DIExpression()', 
      debug-info-location: '!7' }
  - { id: 1, ..., 
      debug-info-variable: '!8', debug-info-expression: '!DIExpression()', 
      debug-info-location: '!7' }

llc -run-pass=stack-coloring reproducer.mir

stack:
  - { id: 0, ...,
      debug-info-variable: '!4!8', debug-info-expression:
'!DIExpression()!DIExpression()',
      debug-info-location: '!7!7' }

This issue can be traced back to MIRPrinter::printStackObjectDbgInfo, and its
single caller MIRPrinter::convertStackObjects. In these functions, we iterate
through the VariableDbgInfo for the function, fetch the string streams for the
associated stack slots, and append the debug info to those. Instead of simply
directly appending, there should be some kind of separator if a value has
already been written to the stream; the parser will also need to be updated to
support this.</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>