<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_CONFIRMED "
   title="CONFIRMED - [DebugInfo@O2] InstCombine drops dbg.value of an argument"
   href="https://bugs.llvm.org/show_bug.cgi?id=40648">40648</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DebugInfo@O2] InstCombine drops dbg.value of an argument
          </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>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>CONFIRMED
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>wrong-debug
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jeremy.morse.llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>chackz0x12@gmail.com, dblaikie@gmail.com, greg.bedwell@sony.com, international.phantom@gmail.com, llvm-bugs@lists.llvm.org, paul.robinson@am.sony.com
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>38768
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With the code below, llvm/clang r352480, and command line "-O2 -g -c", the
'nose' argument does not have a location in the output file. This is not the
same as <a class="bz_bug_link 
          bz_status_CONFIRMED "
   title="CONFIRMED - [DebugInfo@O2] EarlyCSE accidentally deletes unused arguments"
   href="show_bug.cgi?id=40645">bug 40645</a> despite being similar code, because the dbg.value records for
'nose' are deleted by InstCombine, and it doesn't leave dbg.value(undef...)
hanging around.

Reproducer is slightly convoluted because I was trying to stimulate
InstCombines instruction sinking between two blocks where control flow always
moves exclusively from one block to exclusively the other block. This would
normally never happen, but the try-catch block forces that to happen.

-------->8--------
struct chin {
  int a;
  int b;
};

int ext(int a, int b);

int toinline(int a, int b)
{
  return 0;
}

int
foo(struct chin nose, int more, int a, int b)
{

  try {
    ext(a, b);
  } catch (int i) {
    return 0;
  }

  more += toinline(nose.a, nose.b);

  return more;
}
--------8<--------</pre>
        </div>
      </p>

        <div id="referenced">
          <hr style="border: 1px dashed #969696">
          <b>Referenced Bugs:</b>
          <ul>
              <li>
                [<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [meta][DebugInfo] Umbrella bug for poor debug experiences"
   href="https://bugs.llvm.org/show_bug.cgi?id=38768">Bug 38768</a>] [meta][DebugInfo] Umbrella bug for poor debug experiences
              </li>
          </ul>
        </div>
        <br>

      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>