[cfe-commits] r72315 - /cfe/trunk/lib/CodeGen/CGExprAgg.cpp

Mike Stump mrs at apple.com
Fri May 22 21:13:59 PDT 2009


Author: mrs
Date: Fri May 22 23:13:59 2009
New Revision: 72315

URL: http://llvm.org/viewvc/llvm-project?rev=72315&view=rev
Log:
One step to fixing up codegen for a=b, where a is a volatile struct.

Modified:
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=72315&r1=72314&r2=72315&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri May 22 23:13:59 2009
@@ -247,7 +247,7 @@
                             RValue::getAggregate(AggLoc));
   } else {
     // Codegen the RHS so that it stores directly into the LHS.
-    CGF.EmitAggExpr(E->getRHS(), LHS.getAddress(), false /*FIXME: VOLATILE LHS*/);
+    CGF.EmitAggExpr(E->getRHS(), LHS.getAddress(), LHS.isVolatileQualified());
     
     if (DestPtr == 0)
       return;
@@ -519,6 +519,18 @@
   // FIXME: Handle variable sized types.
   const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
   
+  // FIXME: If we have a volatile struct, the optimizer can remove what might
+  // appear to be `extra' memory ops:
+  //
+  // volatile struct { int i; } a, b;
+  //
+  // int main() {
+  //   a = b;
+  //   a = b;
+  // }
+  //
+  // either, we need to use a differnt call here, or the backend needs to be
+  // taught to not do this.
   Builder.CreateCall4(CGM.getMemCpyFn(),
                       DestPtr, SrcPtr,
                       // TypeInfo.first describes size in bits.





More information about the cfe-commits mailing list