]> granicus.if.org Git - clang/commitdiff
Track volatile aggregate copies better. I'm hoping someone else will decide
authorMike Stump <mrs@apple.com>
Sat, 23 May 2009 22:29:41 +0000 (22:29 +0000)
committerMike Stump <mrs@apple.com>
Sat, 23 May 2009 22:29:41 +0000 (22:29 +0000)
how to get the backend to know that the operation is volatile.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72348 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CodeGenFunction.h

index 3b7871390c903d08ac360a35dadcc3aec4a4840a..b37b7d284ed0692cdec1b3f5e19186a19c35e14d 100644 (file)
@@ -144,7 +144,8 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src) {
   // FIXME: Pass VolatileDest as well.  I think we also need to merge volatile
   // from the source as well, as we can't eliminate it if either operand
   // is volatile, unless copy has volatile for both source and destination..
-  CGF.EmitAggregateCopy(DestPtr, Src.getAggregateAddr(), E->getType());
+  CGF.EmitAggregateCopy(DestPtr, Src.getAggregateAddr(), E->getType(),
+                        VolatileDest|Src.isVolatileQualified());
 }
 
 /// EmitFinalDestCopy - Perform the final copy to DestPtr, if desired.
@@ -484,7 +485,8 @@ void CodeGenFunction::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
 }
 
 void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
-                                        llvm::Value *SrcPtr, QualType Ty) {
+                                        llvm::Value *SrcPtr, QualType Ty,
+                                        bool isVolatile) {
   assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
   
   // Aggregate assignment turns into llvm.memcpy.  This is almost valid per
@@ -520,7 +522,8 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
   // }
   //
   // either, we need to use a differnt call here, or the backend needs to be
-  // taught to not do this.
+  // taught to not do this.  We use isVolatile to indicate when either the
+  // source or the destination is volatile.
   Builder.CreateCall4(CGM.getMemCpyFn(),
                       DestPtr, SrcPtr,
                       // TypeInfo.first describes size in bits.
index 130bc369e3bc87aaf023e148b93e42ae51dbbef0..9a9ca05768670a255a06f42469b346514dca8e4b 100644 (file)
@@ -419,8 +419,12 @@ public:
   RValue EmitAnyExprToTemp(const Expr *E, llvm::Value *AggLoc = 0,
                            bool isAggLocVolatile = false);
 
+  /// EmitAggregateCopy - Emit an aggrate copy.
+  ///
+  /// \param isVolatile - True iff either the source or the destination is
+  /// volatile.
   void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
-                         QualType EltTy);
+                         QualType EltTy, bool isVolatile=false);
 
   void EmitAggregateClear(llvm::Value *DestPtr, QualType Ty);