[LLVMdev] RFC: llvm-convert.cpp Patch

Duncan Sands baldrick at free.fr
Wed Nov 7 03:17:30 PST 2007


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



More information about the llvm-dev mailing list