On Thu, Jun 21, 2012 at 4:57 PM, Tanya Lattner <[email protected]> wrote:
>
> 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?

The given testcase is semantically sound: the __global qualifier
disappears once we perform an lvalue-to-rvalue conversion.  It's just
that byval in LLVM IR has slightly strange semantics, which means we
have to introduce an extra copy into the IR.

-Eli

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

Reply via email to