This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/29415] [4.2 regression] ] bad code reordering around inline asm block



------- 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


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