[LLVMbugs] [Bug 126] NEW: llvmg++ generates casting code for member initialization

bugzilla-daemon at zion.cs.uiuc.edu bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 18 10:00:33 PST 2003


           Summary: llvmg++ generates casting code for member initialization
           Product: tools
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-g++
        AssignedTo: sabre at nondot.org
        ReportedBy: sabre at nondot.org

In this testcase, the 'A' object should be trivially eliminable:

struct A {
        A() : i(0) {}
        int getI() {return i;}
        int i;

int f(int j)
        A a;
        return j+a.getI();

But the optimizer is not doing this because we get nasty code like:

int %_Z1fi(int %j.1) {
        %a = alloca %struct.A           ; <%struct.A*> [#uses=1]
        %tmp.1.i = cast %struct.A* %a to uint           ; <uint> [#uses=1]
        %tmp.2.i = cast uint %tmp.1.i to %struct.A*             ; <%struct.A*>
        %tmp.3.i = getelementptr %struct.A* %tmp.2.i, long 0, ubyte 0          
; <int*> [#uses=1]
        store int 0, int* %tmp.3.i
        ret int %j.1

... note the pointless cast.  This can be solved two ways:

1. The instcombiner can be taught the size of a pointer.
2. The C++ front-end can be beaten over the head until this doesn't happen.

Doing both is obviously best!  :)


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