summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-02-15 05:52:14 +0000
committerChris Lattner <sabre@nondot.org>2005-02-15 05:52:14 +0000
commit3bef66fcf3cd6ded6cded2a4fe539212b3736146 (patch)
tree13e53d121cc6c49d722eb2541f1099e437922b38 /llvm/lib/Target/CBackend/Writer.cpp
parent1f031b20fe4cf10a34508e94281724fbe81f8a47 (diff)
downloadbcm5719-llvm-3bef66fcf3cd6ded6cded2a4fe539212b3736146.tar.gz
bcm5719-llvm-3bef66fcf3cd6ded6cded2a4fe539212b3736146.zip
Fix volatile load/store of pointers. Consider this testcase:
void %test(int** %P) { %A = volatile load int** %P ret void } void %test2(int*** %Q) { %P = load int*** %Q volatile store int** %P, int*** %Q ret void } instead of emitting: void test(int **l1_P) { int *l2_A; l2_A = (int **((volatile int **)l1_P)); return; } void test2(int ***l2_Q) { int **l1_P; l1_P = *l2_Q; *((volatile int ***)l2_Q) = l1_P; return; } ... which is loading/storing volatile pointers, not through volatile pointers, emit this (which is right): void test(int **l1_P) { int *l3_A; l3_A = *((int * volatile*)l1_P); return; } void test2(int ***l2_Q) { int **l1_P; l1_P = *l2_Q; *((int ** volatile*)l2_Q) = l1_P; return; } llvm-svn: 20191
Diffstat (limited to 'llvm/lib/Target/CBackend/Writer.cpp')
-rw-r--r--llvm/lib/Target/CBackend/Writer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Target/CBackend/Writer.cpp b/llvm/lib/Target/CBackend/Writer.cpp
index acb7736e45f..46f03357960 100644
--- a/llvm/lib/Target/CBackend/Writer.cpp
+++ b/llvm/lib/Target/CBackend/Writer.cpp
@@ -1656,9 +1656,9 @@ 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 << ")";
+ Out << "((";
+ printType(Out, I.getType());
+ Out << " volatile*)";
}
writeOperand(I.getOperand(0));
@@ -1670,9 +1670,9 @@ void CWriter::visitLoadInst(LoadInst &I) {
void CWriter::visitStoreInst(StoreInst &I) {
Out << '*';
if (I.isVolatile()) {
- Out << "((volatile ";
- printType(Out, I.getPointerOperand()->getType());
- Out << ")";
+ Out << "((";
+ printType(Out, I.getOperand(0)->getType());
+ Out << " volatile*)";
}
writeOperand(I.getPointerOperand());
if (I.isVolatile()) Out << ")";
OpenPOWER on IntegriCloud