[llvm-branch-commits] [cfe-branch] r98298 - in /cfe/branches/release_27: lib/CodeGen/CGExprAgg.cpp test/CodeGen/init.c

Tanya Lattner tonic at nondot.org
Thu Mar 11 15:26:52 PST 2010


Author: tbrethou
Date: Thu Mar 11 17:26:52 2010
New Revision: 98298

URL: http://llvm.org/viewvc/llvm-project?rev=98298&view=rev
Log:
Merge 97981 from mainline.
add a codegen hack to work around an AST bug, allowing us to compile the
code in PR6537.  This should be reverted when the ast bug is fixed.

Modified:
    cfe/branches/release_27/lib/CodeGen/CGExprAgg.cpp
    cfe/branches/release_27/test/CodeGen/init.c

Modified: cfe/branches/release_27/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_27/lib/CodeGen/CGExprAgg.cpp?rev=98298&r1=98297&r2=98298&view=diff
==============================================================================
--- cfe/branches/release_27/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/branches/release_27/lib/CodeGen/CGExprAgg.cpp Thu Mar 11 17:26:52 2010
@@ -662,6 +662,16 @@
 
     return;
   }
+  
+  // If we're initializing the whole aggregate, just do it in place.
+  // FIXME: This is a hack around an AST bug (PR6537).
+  if (NumInitElements == 1 && E->getType() == E->getInit(0)->getType()) {
+    EmitInitializationToLValue(E->getInit(0),
+                               LValue::MakeAddr(DestPtr, Qualifiers()),
+                               E->getType());
+    return;
+  }
+  
 
   // Here we iterate over the fields; this makes it simpler to both
   // default-initialize fields and skip over unnamed fields.
@@ -680,8 +690,8 @@
     // We never generate write-barries for initialized fields.
     LValue::SetObjCNonGC(FieldLoc, true);
     if (CurInitVal < NumInitElements) {
-      // Store the initializer into the field
-      EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc, 
+      // Store the initializer into the field.
+      EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc,
                                  Field->getType());
     } else {
       // We're out of initalizers; default-initialize to null

Modified: cfe/branches/release_27/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_27/test/CodeGen/init.c?rev=98298&r1=98297&r2=98298&view=diff
==============================================================================
--- cfe/branches/release_27/test/CodeGen/init.c (original)
+++ cfe/branches/release_27/test/CodeGen/init.c Thu Mar 11 17:26:52 2010
@@ -29,3 +29,14 @@
   static const int g4 = 12;
   return g4;
 }
+
+// PR6537
+typedef union vec3 {
+  struct { double x, y, z; };
+  double component[3];
+} vec3;
+vec3 f5(vec3 value) {
+  return (vec3) {{
+    .x = value.x
+  }};
+}





More information about the llvm-branch-commits mailing list