Skip to content

Commit

Permalink
Prepare kernel calls lowering for upstream
Browse files Browse the repository at this point in the history
Change-Id: Ie01c49ac04575b9ce5b74d0169ed5ad9b3450acb
  • Loading branch information
rampitec committed Aug 16, 2019
1 parent 07e097a commit 202d308
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
//===-- AMDGPULowerKernelCalls.cpp - Fix kernel-calling-kernel in HSAIL ------===//
//===-- AMDGPULowerKernelCalls.cpp - Fix kernel calls ---------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// \file
//
// \brief replace calls to OpenCL kernels with equivalent non-kernel
// functions
//
// In OpenCL, a kernel may call another kernel as if it was a
// non-kernel function. But in HSAIL, such a call is not allowed. To
// fix this, we copy the body of kernel A into a new non-kernel
// function fA, if we encounter a call to A. All calls to A are then
// transferred to fA.
// In OpenCL, a kernel may call another kernel as if it was a non-kernel
// function. However, kernels and functions have different ABI. To fix this,
// we copy the body of kernel A into a new non-kernel function fA, if we
// encounter a call to A. All calls to A are then transferred to fA.
//
//===----------------------------------------------------------------------===//
#include "AMDGPU.h"
Expand Down Expand Up @@ -60,10 +64,6 @@ AMDGPULowerKernelCalls::AMDGPULowerKernelCalls() : ModulePass(ID) {

static void setNameForBody(Function *FBody, const Function &FKernel) {
StringRef Name = FKernel.getName();
if (Name.startswith("__OpenCL_")) {
assert(Name.endswith("_kernel"));
Name = Name.slice(strlen("__OpenCL_"), Name.size() - strlen("_kernel"));
}
SmallString<128> NewName("__amdgpu_");
NewName += Name;
NewName += "_kernel_body";
Expand Down

0 comments on commit 202d308

Please sign in to comment.