<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 - phi inserted before landingpad by GCOVProfiling causes incorrect code generation"
   href="https://bugs.llvm.org/show_bug.cgi?id=45261">45261</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>phi inserted before landingpad by GCOVProfiling causes incorrect code generation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>amanieu@gmail.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=23265" name="attach_23265" title="IR of the function with the bug">attachment 23265</a> <a href="attachment.cgi?id=23265&action=edit" title="IR of the function with the bug">[details]</a></span>
IR of the function with the bug

Upstream bug: <a href="https://github.com/rust-lang/rust/issues/70148">https://github.com/rust-lang/rust/issues/70148</a>

rustc has a -Zprofile option which uses the "insert-gcov-profiling" LLVM pass
to insert profiling instrumentation to a program.

This pass generates the following IR for landing pads:

catch.i:                                          ; preds = %.noexc
  %120 = phi i64* [ getelementptr inbounds ([24 x i64], [24 x i64]*
@__llvm_gcov_ctr.27, i64 0, i64 11), %.noexc ]
  %121 = landingpad { i8*, i32 }
          catch i8* null
  %122 = load i64, i64* %120
  %123 = add i64 %122, 1
  store i64 %123, i64* %120

Which is then lowered (with llc -O0) to this:

.LBB0_14:                               # %catch.i
        movq    160(%rsp), %rcx         # 8-byte Reload
        movl    $1, %esi
.Ltmp2:
        movabsq $__llvm_gcov_ctr.27, %rdi
        addq    $120, %rdi
        movq    (%rcx), %r8
        addq    $1, %r8
        movq    %r8, (%rcx)

The unwinding data points to .Ltmp2 as the landing pad address, and .LBB0_14 is
unreachable. This results in %rcx being left uninitialized in the landing pad.</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>