[LLVMbugs] [Bug 84] New: C/C++ Frontend emit nasty code for address of array element

bugzilla-daemon at zion.cs.uiuc.edu bugzilla-daemon at zion.cs.uiuc.edu
Mon Nov 3 13:37:02 PST 2003


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=84

           Summary: C/C++ Frontend emit nasty code for address of array
                    element
           Product: tools
           Version: 1.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: llvm-gcc
        AssignedTo: sabre at nondot.org
        ReportedBy: sabre at nondot.org


The following code:

---
char Global[100];
char *test1(unsigned i) {
  return &Global[i];
}
---

Turns into the following LLVM code:
---
        %tmp.1 = cast uint %i.1 to [100 x sbyte]*
        %tmp.4 = cast [100 x sbyte]* %tmp.1 to long
        %tmp.5 = add long %tmp.4, cast ([100 x sbyte]* %Global to long)
        %tmp.6 = cast long %tmp.5 to sbyte*
        ret sbyte* %tmp.6
---

This is disgusting, it should use a getelementptr instruction.  Testcase is:
test/Regression/CFrontend/2003-11-03-AddrArrayElement.c.tr


-Chris



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