[LLVMbugs] [Bug 14941] New: LLVM-IR code shows correct flow of execution but generates x86 assembly language that is broken

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jan 12 21:09:20 PST 2013


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

             Bug #: 14941
           Summary: LLVM-IR code shows correct flow of execution but
                    generates x86 assembly language that is broken
           Product: libraries
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: chris.schaf at verizon.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9867
  --> http://llvm.org/bugs/attachment.cgi?id=9867
Unoptimized but correctly verified llvm-ir code generated by my common lisp
compiler

I'm using the latest release of LLVM 3.2 (trunk) on a MacBook pro running 10.8.

My compiler generates IR code that verifies but wasn't running properly. This
IR code is not run through any function-pass-manager because I'm debugging it.
It appears that when I optimize the IR code then the problem goes away (see
below).

 I generated x86 code using "llc" and I can see the problem in the assembler
code.
I inserted low level tracing code into the beginning of every block to trace
execution. Each block prints a number 4400xxx when it is entered.

If you look at the disassembly and context-free-graph of "complex1.bc" the
block "LET-normal-dest8" (low-level-trace value 44000006) flows into the
"tagbody-tagbody-::G6610-0" block (low-level-trace value 44000007.
If you look in "complex1.s" at line LBB0_3: you will see the low-level-trace
printing call for 44000006 immediately followed by a low-level-trace printing
call with the value 44000064.

This is exactly what this broken code generates:

thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000001]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000002]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[1]

1thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000003]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000004]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000005]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[2]

2thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000006]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000064]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000065]

*CRASH*



When I run the bitcode file through "opt -O1" the optimized code works fine and
generates:

thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000001]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000002]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[1]

1thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000003]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000004]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000005]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[2]

2thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000006]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000007]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[3]

3thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000008]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000009]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[4]

4thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000010]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000011]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000013]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[5]

5thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000014]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000015]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000016]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[6]

6thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000017]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000018]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000019]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[7]

7thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000020]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000021]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000031]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000032]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000035]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[8]

8thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000036]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000041]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000042]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000043]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[98765]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000044]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000045]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000009]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[4]

4thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000010]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000011]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000013]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[5]

5thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000014]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000015]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000016]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[6]

6thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000017]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000018]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000019]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[7]

7thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000020]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000021]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000031]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000032]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000035]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[8]

8thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000036]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000041]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000042]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000043]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[98765]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000044]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000045]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000009]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[4]

4thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000010]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000011]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000013]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[5]

5thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000014]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000015]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000016]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[6]

6thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000017]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000018]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000019]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[7]

7thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000020]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000021]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000031]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000032]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000035]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[8]

8thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000036]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000041]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000042]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000043]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[98765]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000044]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000045]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000009]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[4]

4thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000010]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000011]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000013]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[5]

5thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000014]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000015]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000016]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[6]

6thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000017]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000018]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000019]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[7]

7thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000020]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000021]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000031]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000032]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000035]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[8]

8thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000036]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000041]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000042]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000043]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[98765]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000044]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000045]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000009]
thunks.cc:736 ++++DEBUG-PRINT-I32 i32[4]

4thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000010]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000011]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000012]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000039]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000040]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000050]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000051]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000054]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000055]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000062]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000063]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000066]
thunks.cc:742 ++++LOW-LEVEL-TRACE i32[44000071]

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