From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15342 invoked by alias); 28 May 2009 17:48:40 -0000 Received: (qmail 15332 invoked by uid 22791); 28 May 2009 17:48:38 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_22,J_CHICKENPOX_31,J_CHICKENPOX_43 X-Spam-Check-By: sourceware.org Received: from web111606.mail.gq1.yahoo.com (HELO web111606.mail.gq1.yahoo.com) (67.195.23.48) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 28 May 2009 17:48:33 +0000 Received: (qmail 38594 invoked by uid 60001); 28 May 2009 17:48:31 -0000 Message-ID: <516867.32690.qm@web111606.mail.gq1.yahoo.com> Received: from [70.98.240.34] by web111606.mail.gq1.yahoo.com via HTTP; Thu, 28 May 2009 10:48:31 PDT Date: Thu, 28 May 2009 18:55:00 -0000 From: Jamie Prescott Subject: Forgetting return values To: gcc@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00660.txt.bz2 What am I missing? I have a simple: static inline int set_prop(char const *path, char const *name, void const *data, int size) { int error; asm volatile ("int\t11\n\t" : "=a0" (error): "a0" (path), "a1" (name), "a2" (data), "a3" (size)); return error; } extern int calc(int); int proc(int i) { int j = calc(i); return set_prop(0, 0, &j, sizeof(int)); } The aX classes maps to the rX registers, no problem for GCC in there. The code above, compiled with GCC 4.4.0 and -O3 produces: _proc: push FP mov SP,FP sub SP,4,SP call _calc mov 0,r0 mov 4,r3 add FP,-4,r2 mov r0,r1 ; APP ; 69 "xxxx.c" 1 int 11 ; NO_APP add SP,4,SP pop FP ret GCC forgets about the calc() return value, and passes an address (FP-4) that has never been written into. buf if I add a "memory" clobber to the asm inline, everything comes back to normal: _proc: push FP mov SP,FP sub SP,4,SP call _calc str.w r0,FP[-4] mov 0,r0 mov 4,r3 add FP,-4,r2 mov r0,r1 ; APP ; 69 "xxxx.c" 1 int 11 ; NO_APP add SP,4,SP pop FP ret Why is the memory clobber required, and why GCC does not understand to sync the value to memory when passing the address to a function? Thanks, - Jamie