[LLVMbugs] [Bug 1974] New: Anders pass can produce miscompiled code

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Feb 2 06:22:07 PST 2008


           Summary: Anders pass can produce miscompiled code
           Product: libraries
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P2
         Component: Global Analyses
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: robert.a.zeh at gmail.com
                CC: llvmbugs at cs.uiuc.edu

The attached bitcode is a little strange.  It's the result of combining a small
expression language with llvm.  The expression language uses dynamic_cast while
building up expressions, and I've inlined the gcc code for dynamic_cast.  I
expect the bitcode will only work when it is attached to the gnu tool chain
because it includes references to the GNU C++ runtime.

The expected (and correct) output of the attached bitcode is an empty file.
After running it through the anders pass, it incorrectly throws an exception. 
Here is what I'm talking about:

Macintosh:GQ robertzeh$ lli bad-2.bc
Macintosh:GQ robertzeh$ 

Fine, life is good.  Now I try to apply the anders pass along with a few other
pieces of code:
Macintosh:GQ robertzeh$ opt -f -anders-aa -load-vn -gcse -die bad-2.bc -o
Macintosh:GQ robertzeh$ lli bad-bad-2.bc
terminate called after throwing an instance of 'Q::Exception'
0   lli                                 0x00471f71
_ZN40_GLOBAL__N_Signals.cpp_00000000_257E67F615PrintStackTraceEv + 45
1   lli                                 0x00472317
_ZN40_GLOBAL__N_Signals.cpp_00000000_257E67F613SignalHandlerEi + 323
2   libSystem.B.dylib                   0x93c4097b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   libstdc++.6.dylib                   0x943f410c __gxx_personality_v0 + 1108
5   libstdc++.6.dylib                   0x943f414b _ZSt9terminatev + 29
6   libstdc++.6.dylib                   0x943f4261 __cxa_throw + 101
7   ???                                 0x01880358 0x0 + 25690968
8   lli                                 0x0013a2e3
+ 1101
9   lli                                 0x00002744 main + 1186
10  lli                                 0x00002236 start + 54

The problem isn't with the exception handling --- the problem is that the code
shouldn't be trying to throw an exception.

After running things through bugpoint (where happyOutput is an empty file):
bugpoint -run-cbe -anders-aa -load-vn -gcse -die bad-2.bc --output happyOutput

*** The following function is being miscompiled: 
<cbe><gcc>You can reproduce the problem with the command line: 
  lli -load ./bugpoint.safe.bc-CtCTaP.cbe.c.dylib bugpoint.test.bc-wYsqlo
The shared object was created with:
  llc -march=c bugpoint.safe.bc-CtCTaP -o temporary.c
  gcc -xc temporary.c -O2 -o ./bugpoint.safe.bc-CtCTaP.cbe.c.dylib -shared
Macintosh:GQ robertzeh$ 

The bugpoint reduced bitcode is only 2 bytes shorter, so I've attached the

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