[LLVMbugs] [Bug 84] C front-end doesn't emit getelementptr for address of array element

bugzilla-daemon at zion.cs.uiuc.edu bugzilla-daemon at zion.cs.uiuc.edu
Sat Nov 8 15:01:29 PST 2003


sabre at nondot.org changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

------- Additional Comments From sabre at nondot.org  2003-11-08 17:01 -------
Here's another horrible case, this one found in the pool allocator:

struct foo {
  int array[100];
  void *getAddr(unsigned i);

void *foo::getAddr(unsigned i) { 
  return &array[i];

This becomes:
sbyte* %_ZN3foo7getAddrEj(%struct.foo* %this.1, uint %i.1) {
entry:          ; No predecessors!
        %tmp.4 = shl uint %i.1, ubyte 2         ; <uint> [#uses=1]
        %tmp.5 = cast uint %tmp.4 to int*               ; <int*> [#uses=1]
        %tmp.6 = cast %struct.foo* %this.1 to long              ; <long> [#uses=1]
        %tmp.7 = cast int* %tmp.5 to long               ; <long> [#uses=1]
        %tmp.8 = add long %tmp.7, %tmp.6                ; <long> [#uses=1]
        %tmp.9 = cast long %tmp.8 to sbyte*             ; <sbyte*> [#uses=1]
        ret sbyte* %tmp.9

Testcase here: test/Regression/C++Frontend/2003-11-08-ArrayAddress.cpp.tr



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list