From: Yaxun Liu Date: Mon, 17 Apr 2017 20:10:44 +0000 (+0000) Subject: CodeGen: Let byval parameter use alloca address space X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f2031f243b0978a11ffa1a52e4e79a63ee8d52d;p=clang CodeGen: Let byval parameter use alloca address space Differential Revision: https://reviews.llvm.org/D32133 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300487 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 8af32055fc..8e25dc2cd7 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -1586,9 +1586,10 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) { case ABIArgInfo::Indirect: { assert(NumIRArgs == 1); - // indirect arguments are always on the stack, which is addr space #0. + // indirect arguments are always on the stack, which is alloca addr space. llvm::Type *LTy = ConvertTypeForMem(it->type); - ArgTypes[FirstIRArg] = LTy->getPointerTo(); + ArgTypes[FirstIRArg] = LTy->getPointerTo( + CGM.getDataLayout().getAllocaAddrSpace()); break; } diff --git a/test/CodeGenOpenCL/byval.cl b/test/CodeGenOpenCL/byval.cl new file mode 100644 index 0000000000..1a8105c520 --- /dev/null +++ b/test/CodeGenOpenCL/byval.cl @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---amdgizcl %s | FileCheck %s -check-prefix=AMDGIZ + +struct A { + int x[100]; +}; + +int f(struct A a); + +int g() { + struct A a; + // CHECK: call i32 @f(%struct.A* byval{{.*}}%a) + // AMDGIZ: call i32 @f(%struct.A addrspace(5)* byval{{.*}}%a) + return f(a); +} + +// CHECK: declare i32 @f(%struct.A* byval{{.*}}) +// AMDGIZ: declare i32 @f(%struct.A addrspace(5)* byval{{.*}})