[cfe-commits] [PATCH] Fixing bug for function calls w/ diff addr spaces
Tanya Lattner
lattner at apple.com
Thu Jun 21 16:57:44 PDT 2012
On Jun 15, 2012, at 3:31 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Thu, Jun 14, 2012 at 3:43 PM, Tanya Lattner <lattner at apple.com> 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
More information about the cfe-commits
mailing list