public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mostrows at watson dot ibm dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/17972] New: const/pure functions result in bad asm Date: Wed, 13 Oct 2004 12:47:00 -0000 [thread overview] Message-ID: <20041013124723.17972.mostrows@watson.ibm.com> (raw) Snippet of shell session demonstrates how compiler generates bad asm (compare to result of compilation without -DBUG). Toolchain built using latest "crosstool" scripts. Sample code attached below. mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-g++ -c -o workqueue.o wq.C -O1 -DBUG mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-objdump -d workqueue.o workqueue.o: file format elf64-powerpc Disassembly of section .text: 0000000000000000 <._Z10queue_workP16workqueue_structP11work_struct>: 0: 7c 08 02 a6 mflr r0 4: f8 01 00 10 std r0,16(r1) 8: f8 21 ff 91 stdu r1,-112(r1) c: 7d a9 6b 78 mr r9,r13 10: e9 29 00 00 ld r9,0(r9) 14: 88 09 00 03 lbz r0,3(r9) 18: 2f a0 00 00 cmpdi cr7,r0,0 1c: 40 be 00 10 bne+ cr7,2c <._Z10queue_workP16workqueue_structP11work_struct+0x2c> 20: 48 00 00 01 bl 20 <._Z10queue_workP16workqueue_structP11work_struct+0x20> 24: 60 00 00 00 nop 28: 48 00 00 00 b 28 <._Z10queue_workP16workqueue_structP11work_struct+0x28> 2c: 48 00 00 00 b 2c <._Z10queue_workP16workqueue_structP11work_struct+0x2c> 30: 00 00 00 00 .long 0x0 34: 00 09 00 01 .long 0x90001 38: 80 00 00 00 lwz r0,0(0) mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-g++ -v Reading specs from /opt/crosstool/powerpc64-linux/gcc-3.4.2-glibc-2.3.3/lib/gcc/powerpc64-linux/3.4.2/specs Configured with: /home/mostrows/tools/crosstool-0.28-rc37/build/powerpc64-linux/gcc-3.4.2-glibc-2.3.3/gcc-3.4.2/configure --target=powerpc64-linux --host=powerpc64-host_unknown-linux-gnu --prefix=/opt/crosstool/powerpc64-linux/gcc-3.4.2-glibc-2.3.3 --disable-multilib --with-sysroot=/opt/crosstool/powerpc64-linux/gcc-3.4.2-glibc-2.3.3/powerpc64-linux/sys-root --with-local-prefix=/opt/crosstool/powerpc64-linux/gcc-3.4.2-glibc-2.3.3/powerpc64-linux/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.2 struct LinuxVPInfo_s { unsigned long physProc; }; typedef struct LinuxVPInfo_s LinuxVPInfo; extern LinuxVPInfo linuxVPInfo; struct cpu_workqueue_struct { int x; }; struct workqueue_struct { struct cpu_workqueue_struct cpu_wq[32]; }; struct work_struct { unsigned long pending; void (*func)(void *); void *data; void *wq_data; }; extern void __k42_spin_lock_irqsave(struct cpu_workqueue_struct* c, unsigned long *x); struct thread_info { int preempt_count; }; extern int test_and_set_bit(int x, unsigned long *y); #ifdef BUG static inline struct thread_info *current_thread_info(void) __attribute__((const)); static int smp_processor_id(void) __attribute__((pure)); #else static int smp_processor_id(void); static inline struct thread_info *current_thread_info(void); #endif static __inline__ int smp_processor_id(void) { return linuxVPInfo.physProc; } static inline struct thread_info *current_thread_info(void) { struct thread_info **ti; __asm__("mr %0,13" : "=r"(ti)); return *ti; } #define cti current_thread_info extern void lkBreakpoint(int line, const char* file, const char* fn); extern void __k42disable_preempt(); extern void __k42enable_preempt(); int queue_work(struct workqueue_struct *wq, struct work_struct *work) { unsigned long flags; int ret = 0; int cpu = ({ do { do { if (((cti()->preempt_count) & (((1UL << (8))-1) << 0))==0) { __k42disable_preempt(); (cti()->preempt_count)++; } else (cti()->preempt_count)++; } while (0); __asm__ __volatile__("": : :"memory"); } while (0); smp_processor_id(); }); struct cpu_workqueue_struct *cwq = wq->cpu_wq + cpu; if (!test_and_set_bit(0, &work->pending)) { do { if ((!work->wq_data)) { lkBreakpoint(103,"workqueue.C",(__func__)); } } while (0); work->wq_data = cwq; __k42_spin_lock_irqsave(cwq, &flags); ret = 1; } do { do { __asm__ __volatile__("": : :"memory"); do { if (((cti()->preempt_count) & (((1UL << (8))-1) << 0))==1) { (cti()->preempt_count)--; __k42enable_preempt(); } else (cti()->preempt_count)--; } while (0); } while (0); } while (0); return ret; } -- Summary: const/pure functions result in bad asm Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mostrows at watson dot ibm dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: ppc64-linux-gnu GCC host triplet: ppc-linux-gnu GCC target triplet: ppc64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17972
next reply other threads:[~2004-10-13 12:47 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-10-13 12:47 mostrows at watson dot ibm dot com [this message] 2004-10-13 14:51 ` [Bug rtl-optimization/17972] " pinskia at gcc dot gnu dot org 2004-10-13 21:45 ` mostrows at watson dot ibm dot com 2004-10-13 22:02 ` pinskia at gcc dot gnu dot org 2004-10-13 22:58 ` amodra at bigpond dot net dot au 2004-10-13 23:04 ` amodra at bigpond dot net dot au 2004-10-13 23:11 ` mostrows at watson dot ibm dot com 2004-10-13 23:25 ` [Bug rtl-optimization/17972] [3.4 Regression] " pinskia at gcc dot gnu dot org 2004-10-13 23:36 ` pinskia at gcc dot gnu dot org 2004-10-13 23:37 ` pinskia at gcc dot gnu dot org 2004-10-14 0:03 ` pinskia at gcc dot gnu dot org 2004-10-14 0:34 ` mostrows at watson dot ibm dot com 2004-10-14 0:43 ` pinskia at gcc dot gnu dot org 2004-10-14 0:59 ` mostrows at watson dot ibm dot com 2004-10-14 1:44 ` [Bug rtl-optimization/17972] [3.3 " pinskia at gcc dot gnu dot org 2004-10-15 6:47 ` amodra at bigpond dot net dot au 2004-10-15 23:12 ` [Bug c++/17972] [3.4 " pinskia at gcc dot gnu dot org 2004-10-16 2:21 ` pinskia at gcc dot gnu dot org 2004-10-16 10:58 ` amodra at bigpond dot net dot au 2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org 2004-12-06 17:15 ` ebotcazou at gcc dot gnu dot org 2004-12-06 23:32 ` amodra at bigpond dot net dot au 2004-12-07 8:01 ` ebotcazou at gcc dot gnu dot org 2004-12-07 8:30 ` ebotcazou at gcc dot gnu dot org 2004-12-10 3:29 ` pinskia at gcc dot gnu dot org 2004-12-15 19:15 ` cvs-commit at gcc dot gnu dot org 2004-12-15 19:18 ` cvs-commit at gcc dot gnu dot org 2004-12-15 19:19 ` ebotcazou at gcc dot gnu dot org 2005-02-24 17:10 ` mostrows at watson dot ibm dot com 2005-02-24 19:59 ` ebotcazou at gcc dot gnu dot org 2005-02-24 21:19 ` ebotcazou at gcc dot gnu dot org 2005-03-03 18:47 ` mark at codesourcery dot com 2005-03-03 19:25 ` ebotcazou at gcc dot gnu dot org 2005-03-03 19:34 ` mark at codesourcery dot com 2005-03-03 21:12 ` ebotcazou at gcc dot gnu dot org 2005-03-03 21:19 ` mark at codesourcery dot com 2005-03-03 22:02 ` ebotcazou at gcc dot gnu dot org 2005-03-07 9:54 ` ebotcazou at gcc dot gnu dot org 2005-03-10 8:05 ` ebotcazou at gcc dot gnu dot org 2005-03-12 16:06 ` ebotcazou at gcc dot gnu dot org 2005-05-19 17:29 ` mmitchel at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20041013124723.17972.mostrows@watson.ibm.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).