Re: Miscellaneous XCode Questions
Re: Miscellaneous XCode Questions
- Subject: Re: Miscellaneous XCode Questions
- From: Eric Albert <email@hidden>
- Date: Thu, 11 May 2006 23:48:43 -0700
On May 11, 2006, at 11:16 PM, Ben Weiss wrote: On May 11, 2006, at 10:44 PM, Chris Espinosa wrote: On May 11, 2006, at 10:28 PM, Ben Weiss wrote:
3. When a pointer (to say, a char) is cast to a vUInt16* pointer, gcc implicitly assumes that it is 16-byte aligned, and loads data with movdqa. Is it legal for gcc to assume this? Do misaligned loads always have to be coded explicitly?
That depends processor model to processor model. Use the #pragma align directives to control alignment explicitly, but the compiler will never (knock wood) generate illegal instruction alignment for a particular processor.
This is for x86, where misaligned vector loads are legal, but use a different load instruction. My code is trying to read 16 contiguous bytes from an array, from an arbitrary (possibly misaligned) starting index. Something like this:
vuint8 load(uint8* p) { return *(vuint8*)p; }
The compiler assumes that p is aligned and generates an aligned load instruction, which causes an alignment exception and crash. I would think that the compiler, not knowing whether the pointer is aligned, should not be making this assumption... Most stack-based data is known at compile-time to be aligned, but not arbitrary pointers. I haven't found this behavior documented anywhere one way or the other.
What you've described would definitely be a codegen bug. Can you file a bug report? Attach a pre-processed version of the file (get it by passing -save-temps to the compiler -- it'll generate a .i or .ii file) and give us the command line used to invoke the compiler, which you can get from Xcode's detailed build log.
Thanks, Eric
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden