First Last Prev Next    No search results available
Details
: [llvm-gcc] Incorrect code generation for pointer subtraction
Bug#: 268
: tools
: llvm-gcc
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: normal
: 1.2

:
: miscompilation
:
:
  Show dependency tree - Show dependency graph
People
Reporter: John T. Criswell <criswell@uiuc.edu>
Assigned To: John T. Criswell <criswell@uiuc.edu>
:

Attachments
C code to regenerate the error. (82 bytes, text/plain)
2004-03-02 12:52, John T. Criswell
Details
Incorrect output generated (22.73 KB, text/plain)
2004-03-02 12:52, John T. Criswell
Details


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2004-03-02 12:51
The llvm-gcc program mis-compiles certain pointer arithmetic expressions. 
Namely, it seems to generate incorrect LLVM code for expressions which subtract
from pointer values.

The attached C and corresponding LLVM code demonstrate the problem: The expression:

argv[0] - 5

...becomes:

%tmp.3 = getelementptr sbyte* %tmp.2, long 4294967291    ; ty=sbyte*

Note that the -5 is represented as an unsigned number (4294967291).  This might
work, except that long's in LLVM are 64 bits and are translated as such in the
CBE and LLC.

This causes the hbd program to segfault under certain conditions, and it might
be causing other subtle failures in other programs.
------- Comment #1 From John T. Criswell 2004-03-02 12:52:01 -------
Created an attachment (id=89) [details]
C code to regenerate the error.
------- Comment #2 From John T. Criswell 2004-03-02 12:52:59 -------
Created an attachment (id=90) [details]
Incorrect output generated

This is the incorrect output generated when you run the following:

llvm-gcc -S -o test.ll test.c

Note that the subtraction of 5 is generated incorrectly.
------- Comment #3 From Chris Lattner 2004-03-02 12:53:23 -------
Nice catch!  This is definitely a 1.2 bug.

-Chris
------- Comment #4 From John T. Criswell 2004-03-02 13:15:35 -------
Assigning myself as I'm currently looking into what the problem might be.
------- Comment #5 From Chris Lattner 2004-03-03 14:50:57 -------
Just a note that this bug is also the one that caused us to miscompile 'gmake'.

-Chris
------- Comment #6 From Chris Lattner 2004-03-08 18:39:03 -------
John's patch fixed this bug.  Thanks John!!

-Chris

First Last Prev Next    No search results available