From 8673657275819f80a34fec9afe112d061ee6e8e3 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Sat, 23 May 2009 04:13:59 +0000 Subject: [PATCH] One step to fixing up codegen for a=b, where a is a volatile struct. llvm-svn: 72315 --- clang/lib/CodeGen/CGExprAgg.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 81e1a12de7a2..13559acc0df3 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -247,7 +247,7 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { 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 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr, // 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.