[cfe-commits] r120905 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/exprs.c

John McCall rjmccall at apple.com
Sat Dec 4 04:43:25 PST 2010


Author: rjmccall
Date: Sat Dec  4 06:43:24 2010
New Revision: 120905

URL: http://llvm.org/viewvc/llvm-project?rev=120905&view=rev
Log:
Silly special case:  never load when dereferencing void*.


Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGen/exprs.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=120905&r1=120904&r2=120905&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Dec  4 06:43:24 2010
@@ -312,7 +312,11 @@
     // value as the "address".
     return EmitLValue(E->getSubExpr()).getAddress();
   }
-  Value *VisitUnaryDeref(const Expr *E) { return EmitLoadOfLValue(E); }
+  Value *VisitUnaryDeref(const UnaryOperator *E) {
+    if (E->getType()->isVoidType())
+      return Visit(E->getSubExpr()); // the actual value should be unused
+    return EmitLoadOfLValue(E);
+  }
   Value *VisitUnaryPlus(const UnaryOperator *E) {
     // This differs from gcc, though, most likely due to a bug in gcc.
     TestAndClearIgnoreResultAssign();

Modified: cfe/trunk/test/CodeGen/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exprs.c?rev=120905&r1=120904&r2=120905&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/exprs.c (original)
+++ cfe/trunk/test/CodeGen/exprs.c Sat Dec  4 06:43:24 2010
@@ -152,17 +152,17 @@
 }
 
 // CHECK: define void @f15
-void f15(void *v, const void *cv, volatile void *vv) {
-  extern void f15_helper(void);
-  f15_helper();
-  // CHECK: call void @f15_helper()
-  // FIXME: no loads from i8* should occur here at all!
-  *v; *v, *v; v ? *v : *v;
-  *cv; *cv, *cv; v ? *cv : *cv;
-  *vv; *vv, *vv; vv ? *vv : *vv;
-  // CHECK: volatile load i8*
-  // CHECK: volatile load i8*
-  // CHECK: volatile load i8*
-  // CHECK-NOT: load i8* %
+void f15() {
+  extern void f15_start(void);
+  f15_start();
+  // CHECK: call void @f15_start()
+
+  extern void *f15_v(void);
+  extern const void *f15_cv(void);
+  extern volatile void *f15_vv(void);
+  *f15_v(); *f15_v(), *f15_v(); f15_v() ? *f15_v() : *f15_v();
+  *f15_cv(); *f15_cv(), *f15_cv(); f15_cv() ? *f15_cv() : *f15_cv();
+  *f15_vv(); *f15_vv(), *f15_vv(); f15_vv() ? *f15_vv() : *f15_vv();
+  // CHECK-NOT: load
   // CHECK: ret void
 }





More information about the cfe-commits mailing list