[llvm-commits] [126488] Fix PR1352 and CFrontend/2007-04-24-VolatileStructCopy.c

clattner at apple.com clattner at apple.com
Tue Apr 24 17:26:05 PDT 2007


Revision: 126488
Author:   clattner
Date:     2007-04-24 17:26:05 -0700 (Tue, 24 Apr 2007)

Log Message:
-----------
Fix PR1352 and CFrontend/2007-04-24-VolatileStructCopy.c

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-04-25 00:21:38 UTC (rev 126487)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-04-25 00:26:05 UTC (rev 126488)
@@ -2762,9 +2762,23 @@
     }
 
     // Non-bitfield aggregate value.
-    Emit(TREE_OPERAND(exp, 1), LV.Ptr);
-    if (DestLoc)
+    if (DestLoc) {
+      Emit(TREE_OPERAND(exp, 1), LV.Ptr);
       EmitAggregateCopy(DestLoc, LV.Ptr, TREE_TYPE(exp), isVolatile, false);
+    } else if (!isVolatile) {
+      Emit(TREE_OPERAND(exp, 1), LV.Ptr);
+    } else {
+      // Need to do a volatile store into TREE_OPERAND(exp, 1).  To do this, we
+      // emit it into a temporary memory location, them do a volatile copy into
+      // the real destination.  This is probably suboptimal in some cases, but
+      // it gets the volatile memory access right.  It would be better if the
+      // destloc pointer of 'Emit' had a flag that indicated it should be
+      // volatile.
+      Value *Tmp = CreateTemporary(ConvertType(TREE_TYPE(TREE_OPERAND(exp,1))));
+      Emit(TREE_OPERAND(exp, 1), Tmp);
+      EmitAggregateCopy(LV.Ptr, Tmp, TREE_TYPE(TREE_OPERAND(exp,1)),
+                        isVolatile, false);
+    }
     return 0;
   }
 





More information about the llvm-commits mailing list