Hi,

The -xalias_level flag indicates to the compiler that it is safe to assume a given level of aliasing for the entire source file. It is up to the developer to ensure that this is correct. This can be rather hard to prove.

The restrict qualifier tells the compiler at the declaration of a pointer that it can assume that nothing else points to that memory. This is a much more local block of code to check. It also has the advantage of appearing in the function declaration rather than being separately specified in the compile line.

Hence it's preferable (IMO) to use restrict qualified pointers where appropriate rather than using the broader -xalias_level flag.

So, yes you are correct that the using both would be unnecessary, but restrict qualified pointers are the probably the appropriate solution.

Regards,

Darryl.


On 06/16/10 03:05, Sad Clouds wrote:
Hi, I have a two-part question:

1)
During build of Solaris kernel + userland, what's the value of
compiler's -xalias_level flag? If -xalias_level=any are there any parts
in the code that selectively take advantage of strong aliasing feature
of C compiler?

2)
Suppose we know there are no aliasing issues in the code and we build
everything with -xalias_level=std flag, isn't 'restrict' pointer
qualifier in the following function prototype redundant? I mean compiler
knows those pointers point to different types, hence they can never
alias each other?

int pthread_rwlock_init(
        pthread_rwlock_t *restrict rwlock,
        const pthread_rwlockattr_t *restrict attr);
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

--
Darryl Gove
Compiler Performance Engineering
Blog : http://blogs.sun.com/d/
Books: http://www.sun.com/books/catalog/solaris_app_programming.xml
       http://my.safaribooksonline.com/0595352510
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to