[llvm-bugs] [Bug 38306] New: [GlobalISel][x86_64] 4th argument clobbered by shifts of 5th arg

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 25 02:04:38 PDT 2018


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

            Bug ID: 38306
           Summary: [GlobalISel][x86_64] 4th argument clobbered by shifts
                    of 5th arg
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: GlobalISel
          Assignee: unassignedbugs at nondot.org
          Reporter: aivchenk at gmail.com
                CC: llvm-bugs at lists.llvm.org

int foo(int a, int b, int c, int d, short e)
{
  return a + b + c + d + e;
}

int main() {
  int a = 1;
  int b = 1;
  int c = 1;
  int d = 1;
  int e = 1;

  return foo(a, b, c, d, e);
}

> clang test.c -mllvm -global-isel
> ./a.out
> echo $?
20

> clang test.c
> ./a.out
> echo $?
5


global isel generated:
..
        movl    -8(%rbp), %edi
        movl    -12(%rbp), %esi
        movl    -16(%rbp), %edx
        movl    -20(%rbp), %ecx
        movl    -24(%rbp), %eax
        movl    $16, %r8d
        movl    %r8d, %ecx  << Already set up argument is clobbered by this
                                        # kill: def $cl killed $ecx
        shll    %cl, %eax
        movl    %r8d, %ecx
                                        # kill: def $cl killed $ecx
        sarl    %cl, %eax
        movl    %eax, %r8d
        callq   foo
..


fast isel generated:
..
        movl    -8(%rbp), %edi
        movl    -12(%rbp), %esi
        movl    -16(%rbp), %edx
        movl    -20(%rbp), %ecx
        movl    -24(%rbp), %eax
        movw    %ax, %r8w
        movswl  %r8w, %r8d
        callq   foo
..

-- 
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/20180725/c99f7740/attachment.html>


More information about the llvm-bugs mailing list