[llvm-bugs] [Bug 45261] New: phi inserted before landingpad by GCOVProfiling causes incorrect code generation

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 20 05:16:46 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45261

            Bug ID: 45261
           Summary: phi inserted before landingpad by GCOVProfiling causes
                    incorrect code generation
           Product: libraries
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: amanieu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23265
  --> https://bugs.llvm.org/attachment.cgi?id=23265&action=edit
IR of the function with the bug

Upstream bug: https://github.com/rust-lang/rust/issues/70148

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200320/c00e125e/attachment.html>


More information about the llvm-bugs mailing list