[LLVMbugs] [Bug 14732] New: Bad machine code: Reading virtual register without a def

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 28 06:18:02 PST 2012


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

             Bug #: 14732
           Summary: Bad machine code: Reading virtual register without a
                    def
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: antoine.balestrat at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Hello ! The following testcase fails to compile, using LLVM/Clang 3.3 as of
r171179.

$ cat blag.c
int a, b, c, d;

void f(void)
{
    int i;

    for(; i; i++)
    {
        int *pi = &i;
        char h = 0;

        for(c = 0; c < 1; a++)
        {
            if(i)
                for(*pi = 0; *pi < 1;)
                    i = 0;

            else
            {
                pi = 0;

                if(!h++)
                    b = 1;

                if(b)
                    return;
            }
        }

        if(0)
        {
            for(; b; b++)
            {
                short *p2 = &i;

                while(d)
                    p2 = pi;

                if(a++)
                    if(*p2)
label:
                        p2;
            }
        }

        if(*pi)
            goto label;
    }

    i = 1;
    c && (a = 0);
    goto label;
}

$ xclang -O1 -w blag.c

# Machine code for function f: Post SSA
Frame Objects:
  fi#0: size=4, align=4, at location [SP+4]

BB#0: derived from LLVM BB %entry
    %vreg0<def> = MOV32rm <fi#0>, 1, %noreg, 0, %noreg; mem:LD4[%i] GR32:%vreg0
    %vreg11<def> = LEA32r <fi#0>, 1, %noreg, 0, %noreg; GR32:%vreg11
    %vreg13<def> = COPY %vreg0<kill>; GR32:%vreg13,%vreg0
    Successors according to CFG: BB#1

BB#1: derived from LLVM BB %for.cond
    Predecessors according to CFG: BB#0 BB#15
    %vreg1<def> = COPY %vreg13<kill>; GR32:%vreg1,%vreg13
    TEST32rr %vreg1<kill>, %vreg1, %EFLAGS<imp-def>; GR32:%vreg1
    JE_4 <BB#16>, %EFLAGS<imp-use,kill>
    JMP_4 <BB#2>
    Successors according to CFG: BB#16(124) BB#2(4)

[...]

*** Bad machine code: Reading virtual register without a def ***
- function:    f
- basic block: BB#14 if.end30 (0xa071ff0)
- instruction: CMP32mi8 %vreg8, 1, %noreg, 0, %noreg, 0, %EFLAGS<imp-def>;
mem:LD4[%pi.3.ph](tbaa=!"int") GR32:%vreg8
- operand 0:   %vreg8
fatal error: error in backend: Found 1 machine code errors.
clang: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 3.3 (trunk 171179)
Target: i386-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.

Don't hesitate to ask me for further details !

-- 
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