[LLVMdev] RFC: llvm-convert.cpp Patch
Duncan Sands
baldrick at free.fr
Wed Nov 7 08:36:32 PST 2007
Hi,
> > I don't get it Bill. llvm should be making memcpy with the right
> > alignment regardless of how Bar is formed. Changing the alignment of
> > bar papers over this problem, but we will still get improper alignment
> > for other cases. Also, DECL_USER_ALIGN isn't appropriate to tweak
> > here... the user isn't playing around with __attribute__((aligned))
>
> the fundamental problem is that the DestLoc argument to Emit doesn't
> come with alignment (or volatility for that matter). When emitting
> an aggregate into DestLoc only the alignment of the source is used,
> not that of DestLoc. But that's wrong if DestLoc is less aligned
> than the source (either because the source is highly aligned, eg
> because the user marked it as being highly aligned, or because the
> destination is little aligned as in the testcase). So why not pass
> the alignment and volatility in too? Probably Chris doesn't want
> to add extra arguments to Emit, so instead we could define a
> "DestLoc descriptor" struct:
> struct DLD {
> Value *Ptr;
> unsigned Alignment;
> bool Volatile;
> }
> declare one on the stack and pass its address, something like this:
> DLD D = { Ptr, Align, isVolatile };
> Emit(exp, &D);
I just did this in a sudden fit of activity. It was quite easy and
looks like it catches a ton of volatility and alignment bugs. Maybe
it will even work and fix the original problem :) I will let you
know later.
Ciao,
Duncan.
More information about the llvm-dev
mailing list