This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: objc_msgSend efficiency patch


Simple Objective C programs such as

#include <objc/Object.h>
void foo(void) {
  Object *o;
  [o++ free];
}

result in calling objc_msgSend indirectly through a pointer, instead
of directly as they did in 3.3. This seems to happen only at low optimization
levels; still, it's a performance regression. The reason is that the gimplifier
puts the result of the OBJ_TYPE_REF into a temp due to the postincrement.
I'm pretty sure this is unnecessary for ObjC, like this:


Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 1.1.2.146.2.17
diff -u -d -b -w -p -r1.1.2.146.2.17 gimplify.c
--- gimplify.c 27 Jan 2005 01:04:53 -0000 1.1.2.146.2.17
+++ gimplify.c 21 Feb 2005 20:34:39 -0000
@@ -3871,7 +3871,13 @@ gimplify_expr (tree *expr_p, tree *pre_p
case OBJ_TYPE_REF:
{
enum gimplify_status r0, r1;
- r0 = gimplify_expr (&OBJ_TYPE_REF_OBJECT (*expr_p), pre_p, post_p,
+ /* Postincrements in OBJ_TYPE_REF_OBJECT don't affect the
+ value of the OBJ_TYPE_REF, so force them to be emitted
+ during subexpression evaluation rather than after the
+ OBJ_TYPE_REF. This permits objc_msgSend calls in Objective
+ C to use direct rather than indirect calls when the
+ object expression has a postincrement. */
+ r0 = gimplify_expr (&OBJ_TYPE_REF_OBJECT (*expr_p), pre_p, NULL,
is_gimple_val, fb_rvalue);
r1 = gimplify_expr (&OBJ_TYPE_REF_EXPR (*expr_p), pre_p, post_p,
is_gimple_val, fb_rvalue);


However, I'm not sure whether the comment is accurate for C++. Can somebody
rule on that? Thanks.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]