pro64-support
[Top] [All Lists]

misaligned load/stores

To: pro64-support@xxxxxxxxxxx
Subject: misaligned load/stores
From: Jon Hsu <jonhsu@xxxxxxxxxxxxx>
Date: Thu, 10 May 2001 17:57:40 -0700
Sender: owner-pro64-support@xxxxxxxxxxx
There seem to be situations where the Pro64 compiler generates
misaligned loads and stores when it doesn't need to. I've attached a
test case that demonstrates the problem. If you compile the test case
with "sgicc -S -O2 ll_rw_blk.i" and look at the assembly for the
function blk_queue_pluggable(), you'll see that the compiler uses 1-byte
stores instead of an 8-byte store. 

I believe the problem is that the front end see an incomplete structure
declaration, followed by a reference to a pointer to that structure, so
that it creates a pointer type to a structure of alignment 1. Then when
it sees the actual definition of the structure, it doesn't update the
pointer type.
struct request_queue;
typedef struct request_queue request_queue_t;
typedef struct elevator_s elevator_t;
struct elevator_s
{
        int read_latency;
        int write_latency;
        request_queue_t *dequeue_fn;
};
static inline int elevator_request_latency(elevator_t * elevator, int rw)
{
        int latency;
        latency = elevator->read_latency;
        if (rw != 0 )
                latency = elevator->write_latency;
        return latency;
}
struct request_queue
{
        void            * plug_device_fn;
};
struct blk_dev_struct {
         
        request_queue_t         request_queue;
};
struct blk_dev_struct blk_dev[255 ];  
void blk_queue_pluggable (request_queue_t * q, void *plug)
{
        q->plug_device_fn = plug;
}
<Prev in Thread] Current Thread [Next in Thread>