On Jun 15, 2012, at 3:31 PM, Eli Friedman <[email protected]> wrote:

> On Thu, Jun 14, 2012 at 3:43 PM, Tanya Lattner <[email protected]> wrote:
>> 
>> The attached patch fixes a crash in CodeGen when a struct is passed 
>> indirectly by value to another function by converting the address space. 
>> I've included a test case.
>> 
>> Please review.
> 
> Here's a testcase which actually fails unpatched on x86-64:
> 
> // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o %t
> typedef struct {
>  long long s;
>  float loc[8];
> } AStruct;
> void foo(AStruct s);
> kernel void StructTest(__global AStruct *s_in )
> {
>  foo(s_in[0]);
> }
> 
> IIRC, we can't just blindly bitcast: address space 0 isn't compatible
> with every other address space on every platform.

Yes, you are right. I believe that this should throw an error at the bare 
minimum here right? Should this be caught in Sema somewhere instead?

-Tanya

> 
> The additional code here isn't in the right place; the place where we
> create a temporary in other cases where we can't just use byval
> directly is in CodeGenFunction::EmitCall; see the comment starting "We
> want to avoid creating an unnecessary temporary+copy here".
> 
> -Eli

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to