This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/29415] [4.2 regression] ] bad code reordering around inline asm block
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Oct 2006 01:05:16 -0000
- Subject: [Bug tree-optimization/29415] [4.2 regression] ] bad code reordering around inline asm block
- References: <bug-29415-10561@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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