[cfe-commits] [PATCH] Fixing bug for function calls w/ diff addr spaces

Eli Friedman eli.friedman at gmail.com
Fri Jun 15 15:31:00 PDT 2012


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.

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