From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3274 invoked by alias); 11 Oct 2006 01:05:25 -0000 Received: (qmail 3250 invoked by uid 48); 11 Oct 2006 01:05:16 -0000 Date: Wed, 11 Oct 2006 01:05:00 -0000 Message-ID: <20061011010516.3249.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/29415] [4.2 regression] ] bad code reordering around inline asm block In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-10/txt/msg00848.txt.bz2 List-Id: ------- Comment #4 from pinskia at gcc dot gnu dot org 2006-10-11 01:05 ------- (In reply to comment #3) > No, that's perfectly valid, you can't jump out of an asm or jump into it, > but if you enter the asm and exit it, it doesn't matter what branches or calls > were used inside it (of course if the function you call inside it is written > in C you need to add used attribute to it to make sure it is not optimized > out if it is not otherwise referenced). Not really, it is still questionable but it is unrelated to the problem as far as I can tell. The problem is related to struct aliasing, here is a short testcase which shows the problem (for PPC): typedef struct { int t; } pthread_mutex_t; int t; int f(pthread_mutex_t *a) { a->t = 1; asm("stw%X0 %1,%0" ::"r"(a->t) :"r"(3) : "memory"); return a->t + t; } int main(void) { pthread_mutex_t a; if (f(&a)!=3) __builtin_abort (); } We should not get 1+t but a->t + t in the .final_cleanup as the asm can clober memory. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dberlin at gcc dot gnu dot | |org, pinskia at gcc dot gnu | |dot org Severity|normal |blocker Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2006-10-11 01:05:16 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29415