[LLVMbugs] [Bug 14027] New: PBQP generates invalid allocation to register clobbered by call

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 4 13:31:48 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14027

             Bug #: 14027
           Summary: PBQP generates invalid allocation to register
                    clobbered by call
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: willdtz at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Simple program "test.c":

-----------------------
#include <stdio.h>

int main(int argc, char * argv[]) {
  int a = argc;
  if (a > 1) {
    printf("test\n");
  }
  printf("%d\n", a);
}
-----------------------

When built with basic regalloc:
$ llc test.ll -o test.s -regalloc=basic; gcc test.s -o test; ./test; ./test arg
1
test
2

When using PBQP:
$ llc test.ll -o test.s -regalloc=pbqp; gcc test.s -o test; ./test; ./test arg
1
test
-1

-----------------------

Looking at the assembly generated, PBQP puts 'a' in ecx and expects it to live
through the call to puts... which is certainly invalid:

main:                                   # @main
        .cfi_startproc
# BB#0:                                 # %entry
        pushq   %rax
.Ltmp1:
        .cfi_def_cfa_offset 16
        movl    %edi, %ecx
        cmpl    $2, %ecx
        jl      .LBB0_2
# BB#1:                                 # %if.then
        movl    $.Lstr, %edi
        callq   puts
.LBB0_2:                                # %if.end
        movl    $.L.str1, %edi
        movl    %ecx, %esi
        xorb    %al, %al
        callq   printf
        xorl    %eax, %eax
        popq    %rdx
        ret

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list