[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
Thu Nov 6 22:21:55 PST 2003


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

sabre at nondot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
            Summary|C frontend doesn't emit     |C front-end doesn't emit
                   |getelementptr for address of|getelementptr for address of
                   |array element               |array element



------- Additional Comments From sabre at nondot.org  2003-11-07 00:21 -------
This turned out to be easier than I thought.  I wish there was some way to find
ALL of them though.  :(

$ diff -u c-typeck.c~ c-typeck.c
--- c-typeck.c~ 2003-08-19 17:22:52.000000000 -0500
+++ c-typeck.c  2003-11-07 00:11:04.000000000 -0600
@@ -2379,7 +2379,7 @@
        }
 
       /* For &x[y], return x+y */
-      if (TREE_CODE (arg) == ARRAY_REF)
+      if (TREE_CODE (arg) == ARRAY_REF && !EMIT_LLVM)
        {
          if (!c_mark_addressable (TREE_OPERAND (arg, 0)))
            return error_mark_node;

---

The testcase now produces:
sbyte* %test1(uint %i.1) {
        %tmp.1 = cast uint %i.1 to long        
        %tmp.2 = getelementptr [100 x sbyte]* %Global, long 0, long %tmp.1     
        
        ret sbyte* %tmp.2
}

... as expected.  Long live uncollapsed DSNodes!

-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