[llvm-bugs] [Bug 36587] New: [IPRA] wrong code

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 3 02:03:47 PST 2018


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

            Bug ID: 36587
           Summary: [IPRA] wrong code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Register Allocator
          Assignee: unassignedbugs at nondot.org
          Reporter: paulsson at linux.vnet.ibm.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19992
  --> https://bugs.llvm.org/attachment.cgi?id=19992&action=edit
reduced testcase

It seems that enabling interprocedural register allocation with (reduced)
csmith program gives wrong code:

bin/llc -mtriple=s390x-linux-gnu -mcpu=z13  tc_ipra_reduced.ll -o tc.s
-enable-ipra                                                                    
bin/clang -O3 -march=z13 tc.s -o a.out -w; ./a.out                              
checksum = 0                                   

bin/llc -mtriple=s390x-linux-gnu -mcpu=z13  tc_ipra_reduced.ll -o tc.s
bin/clang -O3 -march=z13 tc.s -o a.out -w; ./a.out                              
checksum = 5 
(checksum = 5 also with gcc -O0 and more)

At first glance, it seems that while fn2() actually uses %r0 (which is caller
saved), ipra (right) seems to result in %r0 being live accross the call to
fn2():

                                        IPRA

        lgrl    %r0, q       |          llihl   %r0, 0
        lgrl    %r1, o       |          stgrl   %r1, n
        larl    %r13, a      |          stg     %r1, 0(%r2)
        lhi     %r12, 0      <
        stgrl   %r0, n       <
        stg     %r0, 0(%r1)  <
        brasl   %r14, fn2 at PL            brasl   %r14, fn2 at PL
        larl    %r1, f                  larl    %r1, f
        chsi    0(%r1), 7               chsi    0(%r1), 7
        lgrl    %r1, m                  lgrl    %r1, m
        lochie  %r12, 1      |          lochhie %r0, 1
        st      %r12, 0(%r1) |          stfh    %r0, 0(%r1)


To the left, %r12 is used by first setting it to 0, then after fn2()
conditionally set it to 1, and then store it to @m.

To the right, %r0 is used the exact same way, which is incorrect since fn2()
changes its value.

-- 
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/20180303/580fd3d1/attachment.html>


More information about the llvm-bugs mailing list