[llvm-bugs] [Bug 47811] New: LR not correctly saved for inline assembly clobbering LR

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 12 16:18:50 PDT 2020


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

            Bug ID: 47811
           Summary: LR not correctly saved for inline assembly clobbering
                    LR
           Product: libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: programmerjake at gmail.com
                CC: llvm-bugs at lists.llvm.org, nemanja.i.ibm at gmail.com

The following IR is miscompiled:
https://gcc.godbolt.org/z/s6c6vT

target triple = "powerpc64le-unknown-linux-gnu"

define void @f() {
  call void asm sideeffect "mtlr 31", "~{lr}"()
  ret void
}

Generated Assembly (trimmed to just f()):
f:                                      # @f
.Lfunc_begin0:
        .cfi_startproc
# %bb.0:
        #APP
        mtlr    31
        #NO_APP
        blr

This causes f to return to whatever address was in r31 instead of to the
caller. I expect LLVM to instead store the return address that was in LR to
another register or to the stack and restore it before returning.

-- 
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/20201012/a0011d4e/attachment.html>


More information about the llvm-bugs mailing list