diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index cb831ae5d54..adac8e2f334 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1655,12 +1655,27 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, void CWriter::visitLoadInst(LoadInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getOperand(0)->getType()); + Out << ")"; + } + writeOperand(I.getOperand(0)); + + if (I.isVolatile()) + Out << ")"; } void CWriter::visitStoreInst(StoreInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getPointerOperand()->getType()); + Out << ")"; + } writeOperand(I.getPointerOperand()); + if (I.isVolatile()) Out << ")"; Out << " = "; writeOperand(I.getOperand(0)); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index cb831ae5d54..adac8e2f334 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1655,12 +1655,27 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, void CWriter::visitLoadInst(LoadInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getOperand(0)->getType()); + Out << ")"; + } + writeOperand(I.getOperand(0)); + + if (I.isVolatile()) + Out << ")"; } void CWriter::visitStoreInst(StoreInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getPointerOperand()->getType()); + Out << ")"; + } writeOperand(I.getPointerOperand()); + if (I.isVolatile()) Out << ")"; Out << " = "; writeOperand(I.getOperand(0)); }